DonImages commited on
Commit
feabc9a
·
verified ·
1 Parent(s): d561504

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -5
app.py CHANGED
@@ -1,7 +1,22 @@
1
- import gradio as gr
 
 
 
 
 
 
 
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
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()