|
import streamlit as st |
|
|
|
from utils import carga_modelo, genera |
|
|
|
|
|
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." |
|
) |
|
|
|
|
|
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*." |
|
) |
|
|
|
|
|
repo_id = "ceyda/butterfly_cropped_uniq1K_512" |
|
version_modelo = "57d36a15546909557d9f967f47713236c8288838" |
|
modelo_gan = carga_modelo(repo_id, version_modelo) |
|
|
|
|
|
n_mariposas = 4 |
|
|
|
|
|
def corre(): |
|
|
|
with st.spinner("Generando, espera 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 pleno vuelo, puede tardar.", |
|
) |
|
|
|
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) |