Spaces:
Configuration error
Configuration error
Update index.html
Browse files- index.html +17 -48
index.html
CHANGED
@@ -1,48 +1,17 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
// Add parameters for randomness
|
20 |
-
const response = await fetch(
|
21 |
-
"https://api-inference.huggingface.co/models/runwayml/stable-diffusion-v1-5",
|
22 |
-
{
|
23 |
-
method: "POST",
|
24 |
-
headers: {
|
25 |
-
"Authorization": `Bearer ${HF_TOKEN}`,
|
26 |
-
"Content-Type": "application/json",
|
27 |
-
},
|
28 |
-
body: JSON.stringify({
|
29 |
-
inputs: prompt,
|
30 |
-
parameters: {
|
31 |
-
seed: randomSeed, // Random seed for variation
|
32 |
-
guidance_scale: 7.5, // Controls creativity (7-15)
|
33 |
-
num_inference_steps: 50 // More steps = more details (20-100)
|
34 |
-
}
|
35 |
-
}),
|
36 |
-
}
|
37 |
-
);
|
38 |
-
|
39 |
-
if (!response.ok) throw new Error("API error: " + response.status);
|
40 |
-
|
41 |
-
const imageBlob = await response.blob();
|
42 |
-
const imageUrl = URL.createObjectURL(imageBlob);
|
43 |
-
imageContainer.innerHTML = `<img src="${imageUrl}" style="max-width:100%;">`;
|
44 |
-
} catch (error) {
|
45 |
-
imageContainer.innerHTML = "Error: " + error.message;
|
46 |
-
}
|
47 |
-
}
|
48 |
-
</script>
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from diffusers import StableDiffusionPipeline
|
3 |
+
import torch
|
4 |
+
|
5 |
+
# Load the model
|
6 |
+
model_id = "runwayml/stable-diffusion-v1-5"
|
7 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id)
|
8 |
+
pipe = pipe.to("cuda") # Runs on Hugging Face's GPU servers
|
9 |
+
|
10 |
+
# Streamlit UI
|
11 |
+
st.title("Free AI Image Generator")
|
12 |
+
prompt = st.text_input("Describe your image...")
|
13 |
+
|
14 |
+
if prompt:
|
15 |
+
with st.spinner("Generating..."):
|
16 |
+
image = pipe(prompt).images[0]
|
17 |
+
st.image(image, caption=prompt, use_column_width=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|