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
|