Spaces:
Runtime error
Runtime error
Ahsen Khaliq commited on
Commit ·
f1d72e1
1
Parent(s): 5eda779
Update app.py
Browse files23 unmodified lines242526272829303132336 unmodified lines404142434445465 unmodified lines5253545556575823 unmodified linesrun_cmd("pip install basicsr")run_cmd("pip freeze")#run_cmd("python setup.py develop")def inference(img):_id = randint(1, 10000)INPUT_DIR = "/tmp/input_image" + str(_id) + "/"OUTPUT_DIR = "/tmp/output_image" + str(_id) + "/"6 unmodified lineshsize = int((float(img.size[1])*float(wpercent)))img = img.resize((basewidth,hsize), Image.ANTIALIAS)img.save(INPUT_DIR + "1.jpg", "JPEG")run_cmd("python inference_realesrgan.py --model_path RealESRGAN_x4plus.pth --input "+ INPUT_DIR + " --output " + OUTPUT_DIR + " --netscale 4 --outscale 4")return os.path.join(OUTPUT_DIR, "1_out.jpg")5 unmodified linesgr.Interface(inference,[gr.inputs.Image(type="pil", label="Input")],gr.outputs.Image(type="file", label="Output"),title=title,description=description,23 unmodified lines242526272829303132336 unmodified lines404142434445464748495 unmodified lines5556575859606123 unmodified linesrun_cmd("pip install basicsr")run_cmd("pip freeze")os.system("wget https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth -P .")def inference(img,mode):_id = randint(1, 10000)INPUT_DIR = "/tmp/input_image" + str(_id) + "/"OUTPUT_DIR = "/tmp/output_image" + str(_id) + "/"6 unmodified lineshsize = int((float(img.size[1])*float(wpercent)))img = img.resize((basewidth,hsize), Image.ANTIALIAS)img.save(INPUT_DIR + "1.jpg", "JPEG")if mode == "base":run_cmd("python inference_realesrgan.py --model_path RealESRGAN_x4plus.pth --input "+ INPUT_DIR + " --output " + OUTPUT_DIR + " --netscale 4 --outscale 4")else:os.system("python inference_realesrgan.py -n RealESRGAN_x4plus_anime_6B -i "+ INPUT_DIR + " --output " + OUTPUT_DIR)return os.path.join(OUTPUT_DIR, "1_out.jpg")5 unmodified linesgr.Interface(inference,[gr.inputs.Image(type="pil", label="Input"),gradio.inputs.Radio(["base","anime"], type="value", default="base", label="model type")],gr.outputs.Image(type="file", label="Output"),title=title,description=description,
app.py+7-4