Spaces:
Running
Running
import gradio as gr | |
import cv2 | |
import numpy as np | |
from gfpgan import GFPGANer | |
# GFPGANerの初期化 | |
restorer = GFPGANer(model_path='https://github.com/TencentARC/GFPGAN/releases/download/v1.3.4/GFPGANv1.4.pth', | |
upscale=2, arch='clean', channel_multiplier=2) | |
# 画像補正関数 | |
def restore_faces(input_img): | |
# 入力画像を処理 | |
img = np.array(input_img) | |
_, restored_img, _ = restorer.enhance(img, has_aligned=False, only_center_face=False) | |
# 補正後の画像を返す | |
return restored_img | |
# Gradioインターフェースの作成 | |
iface = gr.Interface(fn=restore_faces, | |
inputs=gr.Image(type="numpy"), | |
outputs="image", | |
title="AI生成顔をGFPGANで補正", | |
description="AIで生成された顔画像をGFPGANを使って補正します。") | |
# アプリケーションを起動 | |
iface.launch() | |