Spaces:
Runtime error
Runtime error
import os | |
from PIL import Image | |
from imageio import imwrite | |
import gradio as gr | |
from torchvision import transforms | |
import easydict | |
import torch | |
import numpy as np | |
import cv2 | |
from subprocess import call | |
def run_cmd(command): | |
try: | |
print(command) | |
call(command, shell=True) | |
except KeyboardInterrupt: | |
print("Process interrupted") | |
sys.exit(1) | |
run_cmd("pip install basicsr") | |
run_cmd("pip freeze") | |
from basicsr.archs.rrdbnet_arch import RRDBNet | |
from realesrgan import RealESRGANer | |
from realesrgan.archs.srvgg_arch import SRVGGNetCompact | |
import train | |
esrgan_model = train.build_esrgan() | |
pix2pix_model = train.build_pix2pix() | |
def pipeline(img, vivid): | |
img = train.image_preprosses(img, vivid) | |
if type(img) is np.ndarray: | |
img, _ = esrgan_model.enhance(img, outscale=4) | |
img = Image.fromarray(cv2.cvtColor(img, cv2.COLOR_BGR2RGB)) | |
img = train.test_pix2pix(img, pix2pix_model) | |
imwrite('filename.png', img) | |
return 'filename.png' | |
description = "์ ๋๋ฉ์ด์ ํ ์ด๋ฏธ์ง๋ฅผ ๋ณผ์งค์ฝ ์คํ์ผ๋ก ๋ฐ๊พธ๋ Pix2pixHD๋ชจ๋ธ์ ๋๋ค. ์ด๋ฏธ์ง ์ ๋ก๋ ํ ๋์ค๋ ์ฐ์ธก ์๋จ์ ์ฐํ๋ชจ์ ํด๋ฆญํด์ ์ผ๊ตด ์ชฝ์ ์ ์ฌ๊ฐํ์ผ๋ก ์๋ฅด๊ณ submit ํ๋ฉด ๋ฉ๋๋ค. ์ถ๋ ฅ ์ด๋ฏธ์ง๊ฐ ํ๋ฆฌ๊ฒ ๋์ค๋ฉด ํ์ง๊ฐ์ ์ฒดํฌํ์๋ฉด ๋ฉ๋๋ค." | |
examples=[['siroko_out.png',False]] | |
gr.Interface(pipeline, [gr.inputs.Image(type="pil"),gr.inputs.Checkbox(default=False, label="ํ์ง ๊ฐ์ ")], gr.outputs.Image(type="file"),description=description,allow_flagging=False,examples=examples,allow_screenshot=False,enable_queue=False).launch() | |