Ahsen Khaliq commited on
Commit
433d043
1 Parent(s): 6893fd0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -19
app.py CHANGED
@@ -1,4 +1,6 @@
1
  import os
 
 
2
  import random
3
  import gradio as gr
4
  from PIL import Image
@@ -8,7 +10,6 @@ import sys
8
  from subprocess import call
9
  import psutil
10
 
11
- torch.hub.download_url_to_file('https://i.imgur.com/tXrot31.jpg', 'cpu.jpg')
12
 
13
 
14
  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')
@@ -44,22 +45,7 @@ def inference(img):
44
  run_cmd("python inference_realesrgan.py --model_path RealESRGAN_x4plus.pth --input "+ INPUT_DIR + " --output " + OUTPUT_DIR + " --netscale 4 --outscale 3.5")
45
  return os.path.join(OUTPUT_DIR, "1_out.jpg")
46
 
47
- inferences_running = 0
48
- def throttled_inference(image):
49
- print(psutil.virtual_memory())
50
- global inferences_running
51
- current = inferences_running
52
- if current >= 1:
53
- print(f"Rejected inference when we already had {current} running")
54
- return "cpu.jpg"
55
- print(f"Inference starting when we already had {current} running")
56
- inferences_running += 1
57
- try:
58
- return inference(image)
59
- finally:
60
- print("Inference finished")
61
- inferences_running -= 1
62
- print(psutil.virtual_memory())
63
 
64
 
65
  title = "Real-ESRGAN"
@@ -75,5 +61,6 @@ gr.Interface(
75
  article=article,
76
  examples=[
77
  ['bear.jpg']
78
- ]
79
- ).launch(debug=True)
 
 
1
  import os
2
+ os.system('pip install gradio --upgrade')
3
+ os.system('pip freeze')
4
  import random
5
  import gradio as gr
6
  from PIL import Image
 
10
  from subprocess import call
11
  import psutil
12
 
 
13
 
14
 
15
  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')
 
45
  run_cmd("python inference_realesrgan.py --model_path RealESRGAN_x4plus.pth --input "+ INPUT_DIR + " --output " + OUTPUT_DIR + " --netscale 4 --outscale 3.5")
46
  return os.path.join(OUTPUT_DIR, "1_out.jpg")
47
 
48
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
 
51
  title = "Real-ESRGAN"
 
61
  article=article,
62
  examples=[
63
  ['bear.jpg']
64
+ ],
65
+ enable_queue=True
66
+ ).launch(debug=True)