Spaces:
Runtime error
Runtime error
File size: 2,005 Bytes
52e93af dda50ed 52e93af dda50ed 52e93af dda50ed 52e93af dda50ed 52e93af 27cd65b 52e93af dda50ed 52e93af dda50ed 52e93af dda50ed 52e93af dda50ed 52e93af |
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 |
import streamlit as st
from utils import carga_modelo, genera
## P谩gina principal
st.title("Butterfly GAN (GAN de mariposas)")
st.write(
"Modelo Light-GAN entrenado con 1000 im谩genes de mariposas tomadas de la colecci贸n del Museo Smithsonian."
)
## Barra lateral
st.sidebar.subheader("隆Esta mariposa no existe! Ni en Am茅rica Latina 馃く.")
st.sidebar.image("assets/logo.png", width=200)
st.sidebar.caption(
f"[Modelo](https://huggingface.co/ceyda/butterfly_cropped_uniq1K_512) y [Dataset](https://huggingface.co/datasets/huggan/smithsonian_butterflies_subset) usados."
)
st.sidebar.caption(f"*Disclaimers:*")
st.sidebar.caption(
"* 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)."
)
st.sidebar.caption(
"* Modelo basado en el [paper](https://openreview.net/forum?id=1Fqg133qRaI) *Towards Faster and Stabilized GAN Training for High-fidelity Few-shot Image Synthesis*."
)
## Cargamos modelo
repo_id = "ceyda/butterfly_cropped_uniq1K_512"
version_modelo = "57d36a15546909557d9f967f47713236c8288838"
modelo_gan = carga_modelo(repo_id, version_modelo)
## Generamos 4 mariposas
n_mariposas = 4
def corre():
with st.spinner("Generando, espero un poco..."):
ims = genera(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(
"Genera mariposas porfa",
on_click=corre,
help="Estamos en vuelo, abrocha tu cintur贸n."
)
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) |