codeslake commited on
Commit
bf86791
1 Parent(s): d9b11af

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -8
app.py CHANGED
@@ -25,11 +25,19 @@ os.makedirs(Ref_path)
25
  os.makedirs(Ref_path_T)
26
  os.makedirs('result')
27
 
28
- def resize(width,img):
29
- basewidth = width
30
- wpercent = (basewidth/float(img.size[0]))
31
- hsize = int((float(img.size[1])*float(wpercent)))
32
- img = img.resize((basewidth,hsize), Image.ANTIALIAS)
 
 
 
 
 
 
 
 
33
  return img
34
 
35
  def inference(LR, Ref):
@@ -58,10 +66,10 @@ title="RefVSR"
58
  #description="Demo application for Reference-based Video Super-Resolution (RefVSR).\nInstruction: Upload a low-resolution frame and a reference frame to 'LR' and 'Ref' input windows, respectively.\nNote 1: This demo only supports RefVSR for a single LR and Ref frame due to computational complexity. Hence, the model might not take advantage of temporal frames. \nNote 2: The model is our small 8K model trained with the proposed two-stage training strategy. \nNote 3: The spatial size of input LR and Ref frames is 1920x1080 (HD), in the PNG format."
59
  description="Demo application for Reference-based Video Super-Resolution (RefVSR). Upload a low-resolution frame and a reference frame to 'LR' and 'Ref' input windows, respectively."
60
 
61
- article = "<p style='text-align: center'>This demo only supports RefVSR for a single LR and Ref frame due to computational complexity. Hence, the model might not take advantage of temporal frames.</p><p style='text-align: center'>The model is our small 8K model trained with the proposed two-stage training strategy.</p><p style='text-align: center'>The spatial size of input LR and Ref frames is 1920x1080 (HD), in the PNG format.</p><p style='text-align: center'><a href='https://junyonglee.me/projects/RefVSR' target='_blank'>Project</a> | <a href='https://arxiv.org/abs/2203.14537' target='_blank'>arXiv</a> | <a href='https://github.com/codeslake/RefVSR' target='_blank'>Github</a></p>"
62
 
63
- LR = resize(256, 'LR.png')
64
- Ref = resize(256, 'Ref.png')
65
  LR.save('LR.png')
66
  Ref.save('Ref.png')
67
 
25
  os.makedirs(Ref_path_T)
26
  os.makedirs('result')
27
 
28
+ def resize(max_side,img):
29
+ #basewidth = max_side
30
+ #wpercent = (basewidth/float(img.size[0]))
31
+ #hsize = int((float(img.size[1])*float(wpercent)))
32
+ #img = img.resize((basewidth,hsize), Image.ANTIALIAS)
33
+ h = img.size[0]
34
+ w = img.size[1]
35
+ if max(h, w) > max_side:
36
+ scale_ratio = max_side / max(h, w)
37
+ wsize=int(w*scale_ratio)
38
+ hsize=int(h*scale_ratio)
39
+ img = img.resize((wsize,hsize), Image.ANTIALIAS)
40
+
41
  return img
42
 
43
  def inference(LR, Ref):
66
  #description="Demo application for Reference-based Video Super-Resolution (RefVSR).\nInstruction: Upload a low-resolution frame and a reference frame to 'LR' and 'Ref' input windows, respectively.\nNote 1: This demo only supports RefVSR for a single LR and Ref frame due to computational complexity. Hence, the model might not take advantage of temporal frames. \nNote 2: The model is our small 8K model trained with the proposed two-stage training strategy. \nNote 3: The spatial size of input LR and Ref frames is 1920x1080 (HD), in the PNG format."
67
  description="Demo application for Reference-based Video Super-Resolution (RefVSR). Upload a low-resolution frame and a reference frame to 'LR' and 'Ref' input windows, respectively."
68
 
69
+ article = "<p style='text-align: center'>This demo only supports RefVSR for a single LR and Ref frame due to computational complexity. Hence, the model will not take advantage of temporal LR and Ref frames.</p><p style='text-align: center'>The model is our small 8K model trained with the proposed two-stage training strategy.</p><p style='text-align: center'>The spatial size of input LR and Ref frames is 1920x1080 (HD), in the PNG format.</p><p style='text-align: center'><a href='https://junyonglee.me/projects/RefVSR' target='_blank'>Project</a> | <a href='https://arxiv.org/abs/2203.14537' target='_blank'>arXiv</a> | <a href='https://github.com/codeslake/RefVSR' target='_blank'>Github</a></p>"
70
 
71
+ LR = resize(256, Image.open('LR.png'))
72
+ Ref = resize(256, Image.open('Ref.png'))
73
  LR.save('LR.png')
74
  Ref.save('Ref.png')
75