Ahsen Khaliq commited on
Commit
75c7e64
1 Parent(s): d408b90

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -16
app.py CHANGED
@@ -8,7 +8,6 @@ import sys
8
  from subprocess import call
9
 
10
 
11
- torch.hub.download_url_to_file('https://i.imgur.com/tXrot31.jpg', 'cpu.jpg')
12
 
13
  torch.hub.download_url_to_file('http://people.csail.mit.edu/billf/project%20pages/sresCode/Markov%20Random%20Fields%20for%20Super-Resolution_files/100075_lowres.jpg', 'bear.jpg')
14
 
@@ -44,27 +43,13 @@ def inference(img):
44
  return os.path.join(OUTPUT_DIR, "1_out.jpg")
45
 
46
 
47
- inferences_running = 0
48
- def throttled_inference(image):
49
- global inferences_running
50
- current = inferences_running
51
- if current >= 5:
52
- print(f"Rejected inference when we already had {current} running")
53
- return "cpu.jpg"
54
- print(f"Inference starting when we already had {current} running")
55
- inferences_running += 1
56
- try:
57
- return inference(image)
58
- finally:
59
- print("Inference finished")
60
- inferences_running -= 1
61
 
62
  title = "Real-ESRGAN"
63
  description = "Gradio demo for Real-ESRGAN. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below."
64
  article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2107.10833'>Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data</a> | <a href='https://github.com/xinntao/Real-ESRGAN'>Github Repo</a></p>"
65
 
66
  gr.Interface(
67
- throttled_inference,
68
  [gr.inputs.Image(type="pil", label="Input")],
69
  gr.outputs.Image(type="file", label="Output"),
70
  title=title,
 
8
  from subprocess import call
9
 
10
 
 
11
 
12
  torch.hub.download_url_to_file('http://people.csail.mit.edu/billf/project%20pages/sresCode/Markov%20Random%20Fields%20for%20Super-Resolution_files/100075_lowres.jpg', 'bear.jpg')
13
 
 
43
  return os.path.join(OUTPUT_DIR, "1_out.jpg")
44
 
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
  title = "Real-ESRGAN"
48
  description = "Gradio demo for Real-ESRGAN. To use it, simply upload your image, or click one of the examples to load them. Read more at the links below."
49
  article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2107.10833'>Real-ESRGAN: Training Real-World Blind Super-Resolution with Pure Synthetic Data</a> | <a href='https://github.com/xinntao/Real-ESRGAN'>Github Repo</a></p>"
50
 
51
  gr.Interface(
52
+ inference,
53
  [gr.inputs.Image(type="pil", label="Input")],
54
  gr.outputs.Image(type="file", label="Output"),
55
  title=title,