Spaces:
Runtime error
Runtime error
File size: 700 Bytes
f3dc4e3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import gradio as gr
import torch
import cv2
import numpy as np
from realesrgan import RealESRGAN
def upscale_image(image):
model = RealESRGAN(torch.device('cpu'), scale=4)
model.load_weights('weights/RealESRGAN_x4.pth', download=True)
image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
upscaled_image = model.predict(image)
upscaled_image = cv2.cvtColor(upscaled_image, cv2.COLOR_BGR2RGB)
return upscaled_image
iface = gr.Interface(
fn=upscale_image,
inputs=gr.Image(type="numpy"),
outputs=gr.Image(type="numpy"),
title="Upscaling IA con Real-ESRGAN",
description="Carica un'immagine e migliorala con l'intelligenza artificiale!"
)
iface.launch()
|