Spaces:
Runtime error
Runtime error
Upload 2 files
Browse files- index.html +20 -0
- style.css +20 -0
index.html
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from diffusers import StableDiffusionPipeline
|
2 |
+
import torch
|
3 |
+
import random
|
4 |
+
|
5 |
+
def generate_image(prompt):
|
6 |
+
# Use updated model loading syntax
|
7 |
+
pipe = StableDiffusionPipeline.from_pretrained(
|
8 |
+
"stabilityai/stable-diffusion-2-1",
|
9 |
+
torch_dtype=torch.float16, # Add this for better performance
|
10 |
+
use_auth_token="YOUR_HF_TOKEN", # Replace with your token
|
11 |
+
safety_checker=None # Optional: disable safety filter
|
12 |
+
)
|
13 |
+
|
14 |
+
# Generate random seed
|
15 |
+
seed = random.randint(0, 1000000)
|
16 |
+
generator = torch.Generator().manual_seed(seed)
|
17 |
+
|
18 |
+
# Generate image
|
19 |
+
image = pipe(prompt, generator=generator).images[0]
|
20 |
+
return image
|
style.css
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from diffusers import StableDiffusionPipeline
|
2 |
+
import torch
|
3 |
+
import random
|
4 |
+
|
5 |
+
def generate_image(prompt):
|
6 |
+
# Use updated model loading syntax
|
7 |
+
pipe = StableDiffusionPipeline.from_pretrained(
|
8 |
+
"stabilityai/stable-diffusion-2-1",
|
9 |
+
torch_dtype=torch.float16, # Add this for better performance
|
10 |
+
use_auth_token="YOUR_HF_TOKEN", # Replace with your token
|
11 |
+
safety_checker=None # Optional: disable safety filter
|
12 |
+
)
|
13 |
+
|
14 |
+
# Generate random seed
|
15 |
+
seed = random.randint(0, 1000000)
|
16 |
+
generator = torch.Generator().manual_seed(seed)
|
17 |
+
|
18 |
+
# Generate image
|
19 |
+
image = pipe(prompt, generator=generator).images[0]
|
20 |
+
return image
|