Spaces:
Runtime error
Runtime error
Commit
·
44ba841
1
Parent(s):
a126527
Add text-to-image model app and dependencies
Browse files- app.py +17 -0
- requirements.txt +4 -0
app.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from diffusers import StableDiffusionPipeline
|
3 |
+
import torch
|
4 |
+
|
5 |
+
# Load your LoRA fine-tuned model
|
6 |
+
model_id = "signupting/blak-lora"
|
7 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
8 |
+
pipe.to("cuda") # Use GPU if available
|
9 |
+
|
10 |
+
# Function to generate images
|
11 |
+
def generate_image(prompt):
|
12 |
+
image = pipe(prompt).images[0]
|
13 |
+
return image
|
14 |
+
|
15 |
+
# Gradio Interface
|
16 |
+
demo = gr.Interface(fn=generate_image, inputs="text", outputs="image", title="Text-to-Image Generator")
|
17 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
torch
|
2 |
+
gradio
|
3 |
+
diffusers
|
4 |
+
accelerate
|