|
import streamlit as st |
|
from diffusers import StableDiffusionPipeline |
|
|
|
|
|
def generate_image(prompt, width, height): |
|
pipeline = StableDiffusionPipeline.from_single_file( |
|
"https://huggingface.co/Geek7/testing/blob/main/dreamshaper_8.safetensors" |
|
) |
|
|
|
|
|
image = pipeline.run(prompt=prompt, width=width, height=height) |
|
|
|
return image |
|
|
|
|
|
def main(): |
|
st.title("AI Image Generator") |
|
|
|
|
|
prompt = st.text_input("Enter prompt") |
|
width = st.number_input("Width", min_value=1, step=1) |
|
height = st.number_input("Height", min_value=1, step=1) |
|
|
|
if st.button("Generate Image"): |
|
|
|
if prompt: |
|
|
|
generated_image = generate_image(prompt, width, height) |
|
|
|
st.image(generated_image, caption='Generated Image', use_column_width=True) |
|
else: |
|
st.error("Please enter a prompt.") |
|
|
|
if __name__ == "__main__": |
|
main() |