irebmann commited on
Commit
73722a9
·
verified ·
1 Parent(s): 3fb9cf2

added output to be jpeg

Browse files
Files changed (1) hide show
  1. app.py +7 -4
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 **Crystal clear (pretrained)** for the original Swin2SR model, "
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=["Crystal clear (pretrained)", "Smooth (fine-tuned)"],
66
- value="Crystal clear (pretrained)",
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