| import gradio as gr |
| import cv2 |
| import numpy as np |
| from PIL import Image |
|
|
| |
| def upscale_image(input_image, upscale_factor): |
| |
| input_image = np.array(input_image) |
| |
| |
| output_image = cv2.resize(input_image, None, fx=upscale_factor, fy=upscale_factor, interpolation=cv2.INTER_CUBIC) |
| |
| return Image.fromarray(output_image) |
|
|
| |
| def process_image(image, upscale_factor): |
| |
| upscaled_image = upscale_image(image, upscale_factor) |
| |
| |
| return upscaled_image |
|
|
| |
| demo = gr.Interface( |
| fn=process_image, |
| inputs=[gr.Image(type="pil",sources=["upload","webcam"]), gr.Slider(2, 10, step=2, label="Upscale Factor")], |
| outputs=gr.Image(type="pil",show_share_button=False,show_fullscreen_button=False), |
| title="Image Upscaler", |
| description="Upload an image and select an upscale factor to upscale your image.", |
| css="footer {visibility: hidden}" |
| ) |
| |
| demo.launch() |