Spaces:
Sleeping
Sleeping
File size: 1,004 Bytes
b6bab6d 5b4747f b6bab6d 3f83623 |
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 |
import streamlit as st
from utils import load_model, generate
# main page
st.title("Butterflies generator")
st.write("LightGan Model to generate Butterflies")
# sidebar
st.sidebar.subheader("Butterfly generated with AI")
st.sidebar.image("assets/logo.png", width=200)
st.sidebar.caption("Demo")
# Load model
repo_id = "ceyda/butterfly_cropped_uniq1K_512"
model_version = "57d36a15546909557d9f967f47713236c8288838"
model_gan = load_model(repo_id, model_version)
# Generate 4 btfs
n_btfs = 4
def run():
with st.spinner("Generating... "):
ims = generate(model_gan, n_btfs)
st.session_state["ims"] = ims
if "ims" not in st.session_state:
st.session_state["ims"] = None
run()
ims = st.session_state["ims"]
run_button = st.button(
"Generate Butterfly",
on_click = run,
help = "... flying ..."
)
if ims is not None:
cols = st.columns(n_btfs)
for j, im in enumerate(ims):
i = j % n_btfs
cols[i].image(im, use_column_width=True)
|