fatema.upscale / app.py
Mehedi258456's picture
Update app.py
ff71f47 verified
raw
history blame contribute delete
901 Bytes
import gradio as gr
from PIL import Image
import tempfile
def upscale(image, scale):
width, height = image.size
new_width = int(width * scale)
new_height = int(height * scale)
upscaled = image.resize((new_width, new_height), Image.BICUBIC)
# Save to a temp JPG file
temp_file = tempfile.NamedTemporaryFile(suffix=".jpg", delete=False)
upscaled.convert("RGB").save(temp_file.name, format="JPEG", quality=95)
return temp_file.name
title = "Simple Image Upscaler (JPG Download)"
description = "Upload an image and choose scale (2x, 4x, 8x). The image will be resized and downloaded as JPG."
interface = gr.Interface(
fn=upscale,
inputs=[
gr.Image(type="pil"),
gr.Slider(2, 8, step=2, label="Upscale Factor (2x to 8x)")
],
outputs=gr.File(label="Download Upscaled JPG"),
title=title,
description=description
)
interface.launch()