my-static-app / index.html
man08man's picture
Update index.html
6d480e2 verified
raw
history blame
869 Bytes
import streamlit as st
from diffusers import StableDiffusionPipeline
import torch
# Load the model
model_id = "runwayml/stable-diffusion-v2-1"
pipe = StableDiffusionPipeline.from_pretrained(model_id)
pipe = pipe.to("cuda") # Runs on Hugging Face's GPU servers
# Streamlit UI
st.title("Free AI Image Generator")
prompt = st.text_input("Describe your image...")
if prompt:
with st.spinner("Generating..."):
image = pipe(prompt).images[0]
st.image(image, caption=prompt, use_column_width=True)
<button onclick="randomizePrompt()">Surprise Me</button>
<script>
function randomizePrompt() {
const adjectives = ["cartoon", "realistic", "cyberpunk", "watercolor"];
const randomAdjective = adjectives[Math.floor(Math.random() * adjectives.length)];
document.getElementById("prompt").value = `${randomAdjective} dog`;
}
</script>