File size: 1,002 Bytes
e7c7ece
f6e2254
e7c7ece
f6e2254
e7c7ece
148921f
 
f6e2254
 
 
148921f
be13489
148921f
f6e2254
 
 
 
 
 
 
 
 
 
 
148921f
bb3df88
f6e2254
 
 
 
 
 
 
148921f
2314784
148921f
f6e2254
 
 
2314784
f1849a7
f6e2254
8cdc429
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, genera

## pagina principal

st.title("Butterfly Generator")
st.write("Generate your butterflies with one click!")

##Barra lateral

st.sidebar.subheader("ButterflyGAN")
st.sidebar.image("assets/mariposa.png", width = 200)
st.sidebar.caption("My first demo using Streamlit")


## Cargamos el modelo
repo_id = "ceyda/butterfly_cropped_uniq1K_512"
modelo_gan = carga_modelo(repo_id)

##Generamos 4 mariposas
n_mariposas = 4


def run_model():
    with st.spinner("Crafting your new butterfly :"):
        ims = genera(modelo_gan, n_mariposas)
    st.session_state["ims"] = ims
if "ims" not in st.session_state:
    st.session_state["ims"] = None
    run_model()
ims = st.session_state["ims"]

run_model_button = st.button(
"Generate",
on_click = run_model(),
help="Still in process"
)

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)