Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- app.py +27 -0
- requirements.txt +6 -0
app.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# gradio_app.py
|
| 2 |
+
|
| 3 |
+
import torch
|
| 4 |
+
from diffusers import DiffusionPipeline
|
| 5 |
+
import gradio as gr
|
| 6 |
+
|
| 7 |
+
# Load model
|
| 8 |
+
pipe = DiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", torch_dtype=torch.float16)
|
| 9 |
+
pipe.to("cuda")
|
| 10 |
+
pipe.load_lora_weights("EliKet/train_text_to_img")
|
| 11 |
+
|
| 12 |
+
# Generation function
|
| 13 |
+
def generate_image(prompt):
|
| 14 |
+
image = pipe(prompt).images[0]
|
| 15 |
+
return image
|
| 16 |
+
|
| 17 |
+
# Gradio Interface
|
| 18 |
+
demo = gr.Interface(
|
| 19 |
+
fn=generate_image,
|
| 20 |
+
inputs=gr.Textbox(lines=2, placeholder="Enter your image prompt here..."),
|
| 21 |
+
outputs="image",
|
| 22 |
+
title="🐾 Lynx Text-to-Image Generator",
|
| 23 |
+
description="Type a prompt (e.g., 'A majestic lynx in a snowy forest') and get an AI-generated image using Stable Diffusion + LoRA."
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
# Launch app
|
| 27 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
torch>=2.0
|
| 2 |
+
transformers>=4.36.0
|
| 3 |
+
diffusers>=0.25.0
|
| 4 |
+
accelerate
|
| 5 |
+
gradio
|
| 6 |
+
safetensors
|