|
import streamlit as st |
|
import base64 |
|
import os.path |
|
import cv2 |
|
import random |
|
|
|
|
|
os.system("mkdir _input") |
|
os.system("mkdir _output") |
|
os.system("mkdir _outputf") |
|
os.system("ls") |
|
col1, col2 = st.columns(2) |
|
|
|
title = "Melhoria de imagens" |
|
st.title(title) |
|
os.system("ls") |
|
description = "Sistema para automação。" |
|
st.header(description) |
|
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>" |
|
|
|
@st.experimental_memo |
|
def chamada(): |
|
percent_complete=0 |
|
my_bar = st.progress(0) |
|
percent_complete= percent_complete+ 10 |
|
with col1: |
|
my_bar.progress(percent_complete ) |
|
|
|
st.write("ffmpeg separando imagens") |
|
|
|
os.system("ffmpeg -i vivi.mp4 -compression_level 10 -pred mixed -pix_fmt rgb24 -sws_flags +accurate_rnd+full_chroma_int -s 1480x2560 -r 30 ./_input/imagem-%4d.png") |
|
percent_complete= percent_complete+ 30 |
|
with col1: |
|
my_bar.progress(percent_complete ) |
|
st.write("testando imagem") |
|
input_img = cv2.imread("./_input/imagem-0002.png" , cv2.IMREAD_COLOR) |
|
input_img= cv2.cvtColor(input_img,cv2.COLOR_BGR2RGB) |
|
with col1: |
|
st.image(input_img) |
|
|
|
os.system("ls ./_input") |
|
if 'myVar' not in globals(): |
|
myVar="" |
|
st.write("melhorando faces") |
|
with col2: |
|
with st.spinner('Wait for it...'): |
|
|
|
os.system("python3 inference_gfpgan.py -i _input -o _output -v 1.3 -s 2") |
|
with col1: |
|
percent_complete= percent_complete+ 30 |
|
my_bar.progress(percent_complete ) |
|
|
|
os.system("ls ./_output") |
|
os.system("echo ----") |
|
os.system("ls ./_output/cmp") |
|
os.system("echo ----") |
|
os.system("ls ./_output/restored_imgs") |
|
os.system("echo ----") |
|
|
|
with col1: |
|
st.write("recompilando video") |
|
|
|
os.system("ffmpeg -y -r 30 -f image2 -i _output/restored_imgs/imagem-%4d.png -pix_fmt yuv420p ./videoSaida/output.mp4") |
|
os.system("ls ./videoSaida") |
|
|
|
with col1: |
|
st.write("preparando para download do video") |
|
percent_complete= percent_complete+ 30 |
|
my_bar.progress(percent_complete ) |
|
with col2: |
|
with open("./videoSaida/output.mp4", "rb") as file: |
|
st.video(file) |
|
|
|
btn = st.download_button( |
|
|
|
label="Download video", |
|
|
|
data=file, |
|
|
|
file_name="output.png", |
|
|
|
mime="video/mp4" |
|
|
|
) |
|
|
|
|
|
|
|
|
|
with col2 |
|
st.write("demonstrando imagem restaurada") |
|
input_img = cv2.imread("./_output/restored_imgs/imagem-0002.png" , cv2.IMREAD_COLOR) |
|
input_img= cv2.cvtColor(input_img,cv2.COLOR_BGR2RGB) |
|
|
|
st.image(input_img) |
|
exec=False |
|
|
|
load = st.checkbox("load") |
|
|
|
if load: |
|
chamada() |
|
|
|
|
|
exec=True |
|
|