doevent commited on
Commit
6987132
1 Parent(s): a9c53c3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -10
app.py CHANGED
@@ -22,6 +22,15 @@ def setup_model(args):
22
 
23
  def main(img):
24
 
 
 
 
 
 
 
 
 
 
25
  # setup folder and path
26
  #basewidth = 256
27
  #wpercent = (basewidth/float(img.size[0]))
@@ -336,13 +345,15 @@ if __name__ == '__main__':
336
  article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2209.11345' target='_blank'>Swin2SR: SwinV2 Transformer for Compressed Image Super-Resolution and Restoration</a> | <a href='https://github.com/mv-lab/swin2sr' target='_blank'>Github Repo</a></p>"
337
 
338
  examples= glob.glob("testsets/real-inputs/*.jpg")
339
- gr.Interface(
340
- main,
341
- #gr.Image().style(full_width=True, height=60),
342
- gr.inputs.Image(type="pil", label="Input").style(height=260),
343
- gr.inputs.Image(type="pil", label="Ouput").style(height=240),
344
- title=title,
345
- description=description,
346
- article=article,
347
- examples=examples,
348
- ).launch(enable_queue=True)
 
 
 
22
 
23
  def main(img):
24
 
25
+ # Checking Image Aspect Ratio
26
+ with Image.open(img) as im:
27
+ #image size
28
+ ratio_width = im.size[0]
29
+ ratio_height = im.size[1]
30
+ print(f"Aspect ratio: {ratio_width}x{ratio_height} px")
31
+ if ratio_width >= 1026 or ratio_height >= 1026:
32
+ raise gr.Error("Image aspect ratio must not exceed width: 1024 px and height: 1024 px.")
33
+
34
  # setup folder and path
35
  #basewidth = 256
36
  #wpercent = (basewidth/float(img.size[0]))
 
345
  article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2209.11345' target='_blank'>Swin2SR: SwinV2 Transformer for Compressed Image Super-Resolution and Restoration</a> | <a href='https://github.com/mv-lab/swin2sr' target='_blank'>Github Repo</a></p>"
346
 
347
  examples= glob.glob("testsets/real-inputs/*.jpg")
348
+ demo = gr.Interface(
349
+ main,
350
+ #gr.Image().style(full_width=True, height=60),
351
+ gr.Image(type="pil", label="Input").style(height=260),
352
+ gr.Image(type="pil", label="Ouput").style(height=240),
353
+ title=title,
354
+ description=description,
355
+ article=article,
356
+ examples=examples,
357
+ ).launch(enable_queue=True)
358
+ demo.queue()
359
+ demo.launch()