Spaces:
Sleeping
Sleeping
added output to be jpeg
Browse files
app.py
CHANGED
|
@@ -46,24 +46,27 @@ def swin2sr_upscale(input_image: Image.Image, mode: str):
|
|
| 46 |
sr_array = (sr_tensor.mul(255).byte().cpu().permute(1, 2, 0).numpy())
|
| 47 |
sr_image = Image.fromarray(sr_array)
|
| 48 |
|
|
|
|
|
|
|
|
|
|
| 49 |
return sr_image
|
| 50 |
|
| 51 |
# ---- Gradio UI ----
|
| 52 |
with gr.Blocks() as demo:
|
| 53 |
gr.Markdown("# Image Super-Resolution (Swin2SR x4)")
|
| 54 |
gr.Markdown(
|
| 55 |
-
"Choose **
|
| 56 |
"or **Smooth (fine-tuned)** for the Swin2SR version we fine-tuned on DIV2K patches."
|
| 57 |
)
|
| 58 |
|
| 59 |
with gr.Row():
|
| 60 |
input_image = gr.Image(type="pil", label="Upload low-res image")
|
| 61 |
-
output_image = gr.Image(type="pil", label="4x Super-resolved image")
|
| 62 |
|
| 63 |
mode_dropdown = gr.Dropdown(
|
| 64 |
label="Style",
|
| 65 |
-
choices=["
|
| 66 |
-
value="
|
| 67 |
interactive=True,
|
| 68 |
)
|
| 69 |
|
|
|
|
| 46 |
sr_array = (sr_tensor.mul(255).byte().cpu().permute(1, 2, 0).numpy())
|
| 47 |
sr_image = Image.fromarray(sr_array)
|
| 48 |
|
| 49 |
+
# ---ensure JPEG-compatible mode ---
|
| 50 |
+
sr_image = sr_image.convert("RGB")
|
| 51 |
+
|
| 52 |
return sr_image
|
| 53 |
|
| 54 |
# ---- Gradio UI ----
|
| 55 |
with gr.Blocks() as demo:
|
| 56 |
gr.Markdown("# Image Super-Resolution (Swin2SR x4)")
|
| 57 |
gr.Markdown(
|
| 58 |
+
"Choose **Clear (pretrained)** for the original Swin2SR model, "
|
| 59 |
"or **Smooth (fine-tuned)** for the Swin2SR version we fine-tuned on DIV2K patches."
|
| 60 |
)
|
| 61 |
|
| 62 |
with gr.Row():
|
| 63 |
input_image = gr.Image(type="pil", label="Upload low-res image")
|
| 64 |
+
output_image = gr.Image(type="pil",format="jpeg", label="4x Super-resolved image")
|
| 65 |
|
| 66 |
mode_dropdown = gr.Dropdown(
|
| 67 |
label="Style",
|
| 68 |
+
choices=["Clear (OFtB)", "Smooth (Over Smoothing | tuned_1)"],
|
| 69 |
+
value="Clear (OFtB)",
|
| 70 |
interactive=True,
|
| 71 |
)
|
| 72 |
|