Spaces:
Runtime error
Runtime error
File size: 770 Bytes
0d7de2e 5e08d25 0d7de2e 5e08d25 17cfe57 5e08d25 0d7de2e 5e08d25 0d7de2e 5e08d25 0d7de2e 5e08d25 0d7de2e 11ba83b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import os
import gradio as gr
from run_cmd import run_cmd
from PIL import Image
import tempfile
import uuid
temp_path = tempfile.gettempdir()
def inference(img, size, type):
if not img:
raise Exception("No image!")
OUTPUT_PATH = os.path.join(temp_path, f"{str(uuid.uuid4())[0:12]}_{size}.png")
img.save(OUTPUT_PATH)
if type == "Manga":
run_cmd(f"python inference_manga_v2.py {OUTPUT_PATH}")
else:
run_cmd(f"python inference.py {OUTPUT_PATH} {type}")
img_out = Image.open(OUTPUT_PATH)
if size == "x2":
img_out = img_out.resize((img_out.width // 2, img_out.height // 2), resample=Image.BICUBIC)
img_out.thumbnail((600, 600), Image.ANTIALIAS)
return img_out, gr.File.update(value=OUTPUT_PATH) |