Spaces:
Runtime error
Runtime error
Ahsen Khaliq commited on
Commit ·
04cc780
1
Parent(s): cf58652
Update app.py
Browse files6 unmodified lines78910111229 unmodified lines4243444546471 unmodified line495051525354556 unmodified linesimport sysfrom subprocess import calltorch.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')29 unmodified linesrun_cmd("python inference_realesrgan.py --model_path RealESRGAN_x4plus.pth --input "+ INPUT_DIR + " --output " + OUTPUT_DIR + " --netscale 4 --outscale 3.5")return os.path.join(OUTPUT_DIR, "1_out.jpg")title = "Real-ESRGAN"1 unmodified linearticle = "<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>"gr.Interface(inference,[gr.inputs.Image(type="pil", label="Input")],gr.outputs.Image(type="file", label="Output"),title=title,6 unmodified lines7891011121329 unmodified lines43444546474849505152535455565758596061621 unmodified line646566676869706 unmodified linesimport sysfrom subprocess import calltorch.hub.download_url_to_file('https://i.imgur.com/tXrot31.jpg', 'cpu.jpg')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')29 unmodified linesrun_cmd("python inference_realesrgan.py --model_path RealESRGAN_x4plus.pth --input "+ INPUT_DIR + " --output " + OUTPUT_DIR + " --netscale 4 --outscale 3.5")return os.path.join(OUTPUT_DIR, "1_out.jpg")inferences_running = 0def throttled_inference(image):global inferences_runningcurrent = inferences_runningif current >= 5:print(f"Rejected inference when we already had {current} running")return "cpu.jpg"print(f"Inference starting when we already had {current} running")inferences_running += 1try:return gradio_inference(image)finally:print("Inference finished")inferences_running -= 1title = "Real-ESRGAN"1 unmodified linearticle = "<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>"gr.Interface(throttled_inference,[gr.inputs.Image(type="pil", label="Input")],gr.outputs.Image(type="file", label="Output"),title=title,
app.py+16-1