Spaces:
Runtime error
Runtime error
Commit
路
dda50ed
1
Parent(s):
0f893f0
Update app.py
Browse files
app.py
CHANGED
@@ -3,15 +3,26 @@ import streamlit as st
|
|
3 |
from utils import carga_modelo, genera
|
4 |
|
5 |
## P谩gina principal
|
6 |
-
st.title("
|
7 |
-
st.write(
|
|
|
|
|
8 |
|
9 |
## Barra lateral
|
10 |
-
st.sidebar.subheader("
|
11 |
st.sidebar.image("assets/logo.png", width=200)
|
12 |
-
st.sidebar.caption(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
-
## Cargamos
|
15 |
repo_id = "ceyda/butterfly_cropped_uniq1K_512"
|
16 |
version_modelo = "57d36a15546909557d9f967f47713236c8288838"
|
17 |
modelo_gan = carga_modelo(repo_id, version_modelo)
|
@@ -19,25 +30,23 @@ modelo_gan = carga_modelo(repo_id, version_modelo)
|
|
19 |
## Generamos 4 mariposas
|
20 |
n_mariposas = 4
|
21 |
|
|
|
|
|
22 |
def corre():
|
23 |
-
with st.spinner("Generando,
|
24 |
ims = genera(modelo_gan, n_mariposas)
|
25 |
st.session_state["ims"] = ims
|
26 |
|
27 |
-
|
28 |
-
## Si no hay una imagen generada entonces generala
|
29 |
if "ims" not in st.session_state:
|
30 |
st.session_state["ims"] = None
|
31 |
corre()
|
32 |
|
33 |
-
## ims contiene las im谩genes generadas
|
34 |
ims = st.session_state["ims"]
|
35 |
|
36 |
-
## Si la usuaria da click en el bot贸n entonces corremos la funci贸n genera()
|
37 |
corre_boton = st.button(
|
38 |
-
"Genera mariposas
|
39 |
on_click=corre,
|
40 |
-
help="Estamos en
|
41 |
)
|
42 |
|
43 |
if ims is not None:
|
|
|
3 |
from utils import carga_modelo, genera
|
4 |
|
5 |
## P谩gina principal
|
6 |
+
st.title("Butterfly GAN (GAN de mariposas)")
|
7 |
+
st.write(
|
8 |
+
"Modelo Light-GAN entrenado con 1000 im谩genes de mariposas tomadas de la colecci贸n del Museo Smithsonian."
|
9 |
+
)
|
10 |
|
11 |
## Barra lateral
|
12 |
+
st.sidebar.subheader("隆Esta mariposa no existe! Ni en Am茅rica Latina 馃く.")
|
13 |
st.sidebar.image("assets/logo.png", width=200)
|
14 |
+
st.sidebar.caption(
|
15 |
+
f"[Modelo](https://huggingface.co/ceyda/butterfly_cropped_uniq1K_512) y [Dataset](https://huggingface.co/datasets/huggan/smithsonian_butterflies_subset) usados."
|
16 |
+
)
|
17 |
+
st.sidebar.caption(f"*Disclaimers:*")
|
18 |
+
st.sidebar.caption(
|
19 |
+
"* Este demo es una versi贸n simplificada del creado por [Ceyda Cinarel](https://github.com/cceyda) y [Jonathan Whitaker](https://datasciencecastnet.home.blog/) ([link](https://huggingface.co/spaces/huggan/butterfly-gan)) durante el hackathon [HugGan](https://github.com/huggingface/community-events). Cualquier error se atribuye a [Omar Espejel](https://twitter.com/espejelomar)."
|
20 |
+
)
|
21 |
+
st.sidebar.caption(
|
22 |
+
"* Modelo basado en el [paper](https://openreview.net/forum?id=1Fqg133qRaI) *Towards Faster and Stabilized GAN Training for High-fidelity Few-shot Image Synthesis*."
|
23 |
+
)
|
24 |
|
25 |
+
## Cargamos modelo
|
26 |
repo_id = "ceyda/butterfly_cropped_uniq1K_512"
|
27 |
version_modelo = "57d36a15546909557d9f967f47713236c8288838"
|
28 |
modelo_gan = carga_modelo(repo_id, version_modelo)
|
|
|
30 |
## Generamos 4 mariposas
|
31 |
n_mariposas = 4
|
32 |
|
33 |
+
|
34 |
+
|
35 |
def corre():
|
36 |
+
with st.spinner("Generando, espero un poco..."):
|
37 |
ims = genera(modelo_gan, n_mariposas)
|
38 |
st.session_state["ims"] = ims
|
39 |
|
|
|
|
|
40 |
if "ims" not in st.session_state:
|
41 |
st.session_state["ims"] = None
|
42 |
corre()
|
43 |
|
|
|
44 |
ims = st.session_state["ims"]
|
45 |
|
|
|
46 |
corre_boton = st.button(
|
47 |
+
"Genera mariposas porfa",
|
48 |
on_click=corre,
|
49 |
+
help="Estamos en vuelo, abrocha tu cintur贸n."
|
50 |
)
|
51 |
|
52 |
if ims is not None:
|