Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,59 +1,45 @@
|
|
1 |
import streamlit as st
|
|
|
2 |
|
3 |
-
from utils import
|
4 |
|
5 |
-
|
6 |
-
st.
|
7 |
-
|
8 |
-
|
9 |
-
)
|
10 |
|
11 |
-
## Barra lateral
|
12 |
-
st.sidebar.subheader("隆Esta mariposa no existe! Ni en Am茅rica Latina 馃く.")
|
13 |
-
## st.sidebar.image("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)."
|
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 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
|
30 |
-
|
31 |
-
|
|
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
with st.spinner("Generando, espera un poco..."):
|
36 |
-
ims = genera(modelo_gan, n_mariposas)
|
37 |
-
st.session_state["ims"] = ims
|
38 |
|
|
|
|
|
|
|
|
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
corre()
|
44 |
|
45 |
-
|
46 |
-
ims = st.session_state["ims"]
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
help="Estamos en pleno vuelo, puede tardar unos segundos.",
|
53 |
)
|
54 |
|
55 |
if ims is not None:
|
56 |
-
cols = st.columns(
|
57 |
for j, im in enumerate(ims):
|
58 |
-
i = j %
|
59 |
cols[i].image(im, use_column_width=True)
|
|
|
1 |
import streamlit as st
|
2 |
+
import os
|
3 |
|
4 |
+
from utils import load_model, generate
|
5 |
|
6 |
+
st.title('Image Generator with GAN')
|
7 |
+
st.markdown('Butterflies generator')
|
8 |
+
|
9 |
+
st.write("Token Access:", st.secrets["access_token"])
|
|
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
# Sidebar
|
13 |
+
st.sidebar.subheader('This butterfly does not exist, it is completely generated!')
|
14 |
+
st.sidebar.image('assets/logo.jpeg', width=200)
|
15 |
+
st.sidebar.caption('Demo was just created.')
|
16 |
|
17 |
+
# Loading model
|
18 |
+
repo_id = 'ceyda/butterfly_cropped_uniq1K_512'
|
19 |
+
gan_model = load_model(repo_id)
|
20 |
|
21 |
+
# Generate 4 butterflies
|
22 |
+
n_butterflies = 4
|
|
|
|
|
|
|
23 |
|
24 |
+
def run():
|
25 |
+
with st.spinner('Generating...'):
|
26 |
+
ims = generate(gan_model, n_butterflies)
|
27 |
+
st.session_state['ims'] = ims
|
28 |
|
29 |
+
if 'ims' not in st.session_state:
|
30 |
+
st.session_state['ims'] = None
|
31 |
+
run()
|
|
|
32 |
|
33 |
+
ims = st.session_state['ims']
|
|
|
34 |
|
35 |
+
run_button = st.button(
|
36 |
+
'Generate butterflies',
|
37 |
+
on_click=run,
|
38 |
+
help='We are about to start to generate'
|
|
|
39 |
)
|
40 |
|
41 |
if ims is not None:
|
42 |
+
cols = st.columns(n_butterflies)
|
43 |
for j, im in enumerate(ims):
|
44 |
+
i = j % n_butterflies
|
45 |
cols[i].image(im, use_column_width=True)
|