Spaces:
Sleeping
Sleeping
File size: 2,552 Bytes
9dce852 0b952c9 9dce852 0b952c9 9dce852 0b952c9 9dce852 0b952c9 9dce852 0b952c9 9dce852 |
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# -*- coding: utf-8 -*-
"""
Jos茅 Carlos Machicao
GestioDin谩mica
Fecha de producci贸n: 2021_08_28
Fecha de actualizaci贸n 2021_12_29
Ubicaci贸n Original: PythonScripts/gdmk_facerecog/
"""
import streamlit as st
import face_recognition
from PIL import Image
import numpy as np
import pandas as pd
import datetime
import base64
import pickle
# FUNCTIONS
def genera_imagenes_base(up_files):
ims = []
lista_fotos = []
codes = []
for imk in up_files:
lista_fotos.append(imk.name)
imagex = face_recognition.load_image_file(imk)
facecodex = face_recognition.face_encodings(imagex)[0]
codes.append(facecodex)
imsh = Image.open(imk)
ims.append(imsh)
codtot = pd.DataFrame()
codtot['lista'] = lista_fotos
codtot['imagenes'] = ims
codtot['codigos'] = codes
return codtot
# BODY
st.image('images/uc_logo.jpg', width=150)
st.subheader('Aplicativos de Reconocimiento Facial')
st.title('Generaci贸n de Base Tensores')
# 1. IDENTIDAD BASE
st.subheader('**Procedimiento: Generaci贸n de Identidad Digital Base**')
up_files = st.file_uploader('Elija archivos base hasta 50 items: ', accept_multiple_files=True)
if not up_files:
l_pics = 1
for i, col in enumerate(st.columns(1)):
col.image('images/void.jpg', width=150)
else:
codtotx = genera_imagenes_base(up_files)
n_fil = 5
l_pics = int(len(codtotx.lista))
filas = int(np.round(l_pics/n_fil,0)) + 1
st.write(l_pics)
st.write('Procesando imagenes...')
imagenes = list(codtotx.imagenes)
for fila in range(filas):
st.write(fila)
for i, col in enumerate(st.columns(n_fil)):
try:
col.image(up_files[i+fila*n_fil], width=150)
except:
pass
st.write('Reportando: Archivo Base Generado')
timestamp = datetime.datetime.now()
ts = timestamp.strftime('%Y_%m_%d_%H_%M')
#nom_archivo = 'tensores_base_' + ts + '_' + nom_oper + '.pkl'
st.write('Archivo generado por: ', nom_oper)
st.write('Tiempo de generaci贸n: ', ts)
output_pkl = pickle.dumps(codtotx)
b64 = base64.b64encode(output_pkl).decode()
href = f'<a href="data:file/output_model;base64,{b64}" download="tensores.pkl">Descargar Tensores PKL</a>'
st.markdown(href, unsafe_allow_html=True)
c1, c2, c3 = st.columns(3)
with c1:
st.write(' ')
with c2:
st.write(' ')
with c3:
st.write(' ')
st.image('images/gdmk.png', width=100, caption='Designed and Powered by GestioDin谩mica')
|