Spaces:
Runtime error
Runtime error
Ahsen Khaliq commited on
Commit ·
433d043
1
Parent(s): 6893fd0
Update app.py
Browse files12343 unmodified lines89101112131429 unmodified lines444546474849505152535455565758596061626364659 unmodified lines7576777879import osimport randomimport gradio as grfrom PIL import Image3 unmodified linesfrom subprocess import callimport psutiltorch.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):print(psutil.virtual_memory())global inferences_runningcurrent = inferences_runningif current >= 1: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 inference(image)finally:print("Inference finished")inferences_running -= 1print(psutil.virtual_memory())title = "Real-ESRGAN"9 unmodified linesarticle=article,examples=[['bear.jpg']]).launch(debug=True)1234563 unmodified lines10111213141529 unmodified lines454647484950519 unmodified lines616263646566import osos.system('pip install gradio --upgrade')os.system('pip freeze')import randomimport gradio as grfrom PIL import Image3 unmodified linesfrom subprocess import callimport psutiltorch.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"9 unmodified linesarticle=article,examples=[['bear.jpg']],enable_queue=True).launch(debug=True)
app.py+6-19