Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,15 +4,21 @@ import threading
|
|
4 |
import base64
|
5 |
from io import BytesIO
|
6 |
from groq import Groq
|
|
|
|
|
7 |
|
8 |
# ๐น Initialize Groq API Client (FREE)
|
9 |
groq_client = Groq(api_key=os.getenv("GROQ_API_KEY"))
|
10 |
|
11 |
-
# ๐น Load Text-to-Image Models (
|
12 |
model1 = gr.load("models/prithivMLmods/SD3.5-Turbo-Realism-2.0-LoRA")
|
13 |
model2 = gr.load("models/Purz/face-projection")
|
14 |
-
model3 = gr.load("models/stablediffusion/stable-diffusion-2-1") # โ
Fixed model
|
15 |
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
# ๐น Stop Event for Threading
|
18 |
stop_event = threading.Event()
|
@@ -52,7 +58,10 @@ def generate_images(prompt):
|
|
52 |
stop_event.clear()
|
53 |
img1 = model1.predict(prompt)
|
54 |
img2 = model2.predict(prompt)
|
55 |
-
|
|
|
|
|
|
|
56 |
return img1, img2, img3
|
57 |
|
58 |
# ๐น Clear All Fields
|
|
|
4 |
import base64
|
5 |
from io import BytesIO
|
6 |
from groq import Groq
|
7 |
+
from diffusers import StableDiffusionPipeline
|
8 |
+
import torch
|
9 |
|
10 |
# ๐น Initialize Groq API Client (FREE)
|
11 |
groq_client = Groq(api_key=os.getenv("GROQ_API_KEY"))
|
12 |
|
13 |
+
# ๐น Load Text-to-Image Models (Updated to use diffusers for Stable Diffusion)
|
14 |
model1 = gr.load("models/prithivMLmods/SD3.5-Turbo-Realism-2.0-LoRA")
|
15 |
model2 = gr.load("models/Purz/face-projection")
|
|
|
16 |
|
17 |
+
# โ
Load Stable Diffusion Model Properly (Using diffusers)
|
18 |
+
model3 = StableDiffusionPipeline.from_pretrained(
|
19 |
+
"stablediffusion/stable-diffusion-2-1",
|
20 |
+
torch_dtype=torch.float16
|
21 |
+
).to("cuda") # Move to GPU if available
|
22 |
|
23 |
# ๐น Stop Event for Threading
|
24 |
stop_event = threading.Event()
|
|
|
58 |
stop_event.clear()
|
59 |
img1 = model1.predict(prompt)
|
60 |
img2 = model2.predict(prompt)
|
61 |
+
|
62 |
+
# โ
Fix: Use Stable Diffusion correctly
|
63 |
+
img3 = model3(prompt).images[0] # Get first image
|
64 |
+
|
65 |
return img1, img2, img3
|
66 |
|
67 |
# ๐น Clear All Fields
|