Spaces:
Sleeping
Sleeping
File size: 2,425 Bytes
19e3f0f |
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
"""
This file is the main file of the project.
"""
# imports
import streamlit as st
from text_to_image import generate_image
def setup():
"""
Streamlit related setup. This has to be run for each page.
"""
# hide hamburger menu
hide_streamlit_style = """
<style>
#MainMenu {visibility: hidden;}
footer {visibility: hidden;}
</style>
"""
st.markdown(hide_streamlit_style, unsafe_allow_html=True)
def main():
"""
Main function of the app.
"""
setup()
# title, subheader, and description
st.title("Text2Canvas")
st.subheader("A tool that demonstrates the power of Diffusion")
# horizontal line and line break
st.markdown("<hr>", unsafe_allow_html=True)
st.markdown("<br>", unsafe_allow_html=True)
# sidebar
st.sidebar.title("Navigation")
mode = st.sidebar.radio("Select a mode", ["Home", "Text2Image", "Feature2Sprite"])
# st.sidebar.write("Select a mode to get started")
# main content
if mode == "Home":
st.write(
"""
This tool is a demonstration of the power of Diffusion. It helps you generate images from text. There are two modes:
1. **Text2Image**: This mode generates high quality image based on a given prompt. It uses a pretrained model.
2. **Feature2Sprite**: This mode generates 16*16 images of sprites based on a combination of features. It uses a custom model trained on a dataset of sprites.
To get started, select a mode from the sidebar.
"""
)
elif mode == "Text2Image":
st.write(
"""
This mode generates high quality image based on a given prompt. It uses a pretrained model from huggingface.
"""
)
form = st.form(key="my_form")
prompt = form.text_input("Enter a prompt", value="A painting of a cat")
submit_button = form.form_submit_button(label="Generate")
if submit_button:
st.write("Generating image...")
image = generate_image(prompt)
st.image(image, caption="Generated Image", use_column_width=True)
elif mode == "Feature2Sprite":
st.write(
"""
This mode generates 16*16 images of sprites based on a combination of features. It uses a custom model trained on a dataset of sprites.
"""
)
if __name__ == "__main__":
main()
|