|
import streamlit as st |
|
import os |
|
os.system("pip install git+https://github.com/TencentARC/GFPGAN.git") |
|
|
|
|
|
|
|
import random |
|
import gradio as gr |
|
from PIL import Image |
|
import torch |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cv2 |
|
import glob |
|
import numpy as np |
|
from basicsr.utils import imwrite |
|
from gfpgan import GFPGANer |
|
|
|
bg_upsampler = None |
|
|
|
|
|
|
|
|
|
restorer = GFPGANer( |
|
model_path='GFPGANv1.3.pth', |
|
upscale=2, |
|
arch='clean', |
|
channel_multiplier=2, |
|
bg_upsampler=bg_upsampler) |
|
|
|
|
|
def inference(img): |
|
input_img = cv2.imread(img, cv2.IMREAD_COLOR) |
|
cropped_faces, restored_faces, restored_img = restorer.enhance( |
|
input_img, has_aligned=False, only_center_face=False, paste_back=True) |
|
|
|
|
|
return Image.fromarray(restored_img[:, :, ::-1]) |
|
|
|
title = "Melhoria de imagens" |
|
|
|
|
|
description = "Sistema para automação。" |
|
|
|
article = "<p style='text-align: center'><a href='https://huggingface.co/spaces/akhaliq/GFPGAN/' target='_blank'>clone from akhaliq@huggingface with little change</a> | <a href='https://github.com/TencentARC/GFPGAN' target='_blank'>GFPGAN Github Repo</a></p><center><img src='https://visitor-badge.glitch.me/badge?page_id=akhaliq_GFPGAN' alt='visitor badge'></center>" |
|
|
|
gr.Interface( |
|
inference, |
|
[gr.inputs.Image(type="filepath", label="Input")], |
|
gr.outputs.Image(type="pil", label="Output"), |
|
title=title, |
|
description=description, |
|
examples=[ |
|
|
|
['edison.jpg'], |
|
['pessoa3.jpg'] |
|
] |
|
).launch(enable_queue=True,cache_examples=True,share=True) |
|
|