Hev832 commited on
Commit
7091ee2
·
verified ·
1 Parent(s): cd64a0f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from diffusers import DiffusionPipeline
3
+
4
+ # Load the pipeline and LoRA weights
5
+
6
+ def load_cust(base_model, models_sec):
7
+ pipeline = DiffusionPipeline.from_pretrained(base_model)
8
+ pipeline.load_lora_weights(models_sec)
9
+
10
+ def generate_image(prompt, negative_prompt):
11
+ # Generate the image with the provided prompts
12
+ image = pipeline(prompt, negative_prompt=negative_prompt).images[0]
13
+ return image
14
+
15
+ # Define the Gradio interface
16
+ with gr.Blocks() as demo:
17
+ gr.Markdown("# Text to Image Generation Custom models Demo")
18
+ prompt = gr.Textbox(label="Prompt", placeholder="Enter your text prompt here")
19
+ negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="Enter your negative prompt here")
20
+ submit_button = gr.Button("Generate Image")
21
+ with gr.Accordion('load your custom models first'):
22
+ basem = gr.Textbox(label="your models adapter")
23
+ secondm = gr.Textbox(label="your main models")
24
+ exports = gr.Button("load your models")
25
+ exports.click(load_cust, inputs=[basem, secondm], outputs=[])
26
+ output_image = gr.Image(label="Generated Image")
27
+ submit_button.click(generate_image, inputs=[prompt, negative_prompt], outputs=output_image)
28
+
29
+ # Launch the demo
30
+ demo.launch()