upscayl-web / app.py
Example88's picture
Initial Upscayl-Web (Gradio) on HF Spaces
1c00921
raw
history blame contribute delete
754 Bytes
import gradio as gr
import torch
from PIL import Image
from realesrgan import RealESRGAN
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# ุญู…ู‘ู„ ุงู„ู†ู…ูˆุฐุฌ ูˆูˆุฒู†ู‡ (ูŠูู†ุฒู‘ูŽู„ ุชู„ู‚ุงุฆูŠุงู‹ ุฃูˆู„ ู…ุฑุฉ)
model = RealESRGAN(device, scale=4)
model.load_weights("RealESRGAN_x4plus.pth", download=True)
def upscale(img: Image.Image) -> Image.Image:
return model.predict(img)
demo = gr.Interface(
fn=upscale,
inputs=gr.Image(type="pil", label="Upload image"),
outputs=gr.Image(type="pil", label="Upscaled ร—4"),
title="Upscayl-Web",
description="Open-source image upscaler powered by Real-ESRGAN (ร—4).",
)
if __name__ == "__main__":
demo.launch(server_name="0.0.0.0", server_port=7860)