Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,22 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from diffusers import StableDiffusionPipeline
|
| 2 |
+
import torch
|
| 3 |
+
|
| 4 |
+
# Load the Stable Diffusion 3.5 model
|
| 5 |
+
model_id = "stabilityai/stable-diffusion-3.5"
|
| 6 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
| 7 |
+
pipe.to("cuda")
|
| 8 |
+
|
| 9 |
+
# Define the path to the LoRA model (since it's in the main directory)
|
| 10 |
+
lora_model_path = "lora_model.pth" # Path to the uploaded LoRA model
|
| 11 |
|
| 12 |
+
# Load the LoRA model weights into the pipeline
|
| 13 |
+
pipe.load_lora_model(lora_model_path) # Integrate the LoRA weights
|
| 14 |
|
| 15 |
+
# Function to generate an image from a text prompt
|
| 16 |
+
def generate_image(prompt):
|
| 17 |
+
image = pipe(prompt).images[0]
|
| 18 |
+
return image
|
| 19 |
+
|
| 20 |
+
import gradio as gr
|
| 21 |
+
iface = gr.Interface(fn=generate_image, inputs="text", outputs="image")
|
| 22 |
+
iface.launch()
|