Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,16 +3,18 @@ import torch
|
|
3 |
import random
|
4 |
|
5 |
def generate_image(prompt):
|
6 |
-
#
|
7 |
pipe = StableDiffusionPipeline.from_pretrained(
|
8 |
"stabilityai/stable-diffusion-2-1",
|
9 |
-
|
|
|
|
|
10 |
)
|
11 |
|
12 |
-
#
|
13 |
seed = random.randint(0, 1000000)
|
14 |
generator = torch.Generator().manual_seed(seed)
|
15 |
|
16 |
# Generate image
|
17 |
image = pipe(prompt, generator=generator).images[0]
|
18 |
-
return image
|
|
|
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
|