File size: 1,033 Bytes
63488c4
 
 
 
 
 
cc3f1c4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ae14405
cc3f1c4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st

from utils import carga_modelo, general

## Página principal 
st.title("generador de mariposas")
st.write("Modelo de Ligth Gan en streamlit")

## Barra Lateral
st.sidebar.subheader("Mariposa Inventada por matematicas")
st.sidebar.image("assets/logo.png", width=200)
st.sidebar.caption("Rodrigo Rosales")

## Carga del Modelo
repo_id = "ceyda/butterfly_cropped_uniq1K_512"
model_gan = carga_modelo(repo_id)

## Cantidad de Mariposas
n_mariposas = 4

## Principal
def corre():
    with st.spinner("Generandose, tranquilo fiera!!!"):
        ims = general(modelo_gan, n_mariposas)
        st.session_state["ims"] = ims

if "ims" not in st.session_state:
    st.session_state["ims"] = None
    corre()

ims = st.session_state["ims"]

corre_boton = st.button(
    "Generar mariposas",
    on_click=corre,
    help="Click para generar mariposas",
)

if ims is not None:
    cols = st.columns(n_mariposas)
    for j, im in enumerate(ims):
        i = j % n_mariposas
        cols[i].image(im, use_column_width=True)