File size: 934 Bytes
e38d403
68b971d
e38d403
68b971d
e38d403
68b971d
 
 
 
 
 
 
 
 
e38d403
68b971d
 
e38d403
 
68b971d
 
 
 
 
e38d403
68b971d
e38d403
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
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()