Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import spaces
|
2 |
import gradio as gr
|
3 |
|
@@ -5,11 +6,13 @@ from diffusers import StableDiffusionPipeline
|
|
5 |
|
6 |
|
7 |
repo = "Tramac/style-portrait-v1-5"
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
13 |
|
14 |
@spaces.GPU(enable_queue=True)
|
15 |
def generate_image(prompt, neg_prompt):
|
|
|
1 |
+
import torch
|
2 |
import spaces
|
3 |
import gradio as gr
|
4 |
|
|
|
6 |
|
7 |
|
8 |
repo = "Tramac/style-portrait-v1-5"
|
9 |
+
# Ensure model and scheduler are initialized in GPU-enabled function
|
10 |
+
if torch.cuda.is_available():
|
11 |
+
pipeline = StableDiffusionPipeline.from_pretrained(
|
12 |
+
repo,
|
13 |
+
torch_dtype=torch.float16,
|
14 |
+
variant="fp16"
|
15 |
+
).to("cuda")
|
16 |
|
17 |
@spaces.GPU(enable_queue=True)
|
18 |
def generate_image(prompt, neg_prompt):
|