File size: 1,253 Bytes
7091ee2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import gradio as gr
from diffusers import DiffusionPipeline

# Load the pipeline and LoRA weights

def load_cust(base_model, models_sec):
    pipeline = DiffusionPipeline.from_pretrained(base_model)
    pipeline.load_lora_weights(models_sec)

def generate_image(prompt, negative_prompt):
    # Generate the image with the provided prompts
    image = pipeline(prompt, negative_prompt=negative_prompt).images[0]
    return image

# Define the Gradio interface
with gr.Blocks() as demo:
    gr.Markdown("# Text to Image Generation Custom models Demo")
    prompt = gr.Textbox(label="Prompt", placeholder="Enter your text prompt here")
    negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="Enter your negative prompt here")
    submit_button = gr.Button("Generate Image")
    with gr.Accordion('load your custom models first'):
        basem = gr.Textbox(label="your models adapter")
        secondm = gr.Textbox(label="your main models")
        exports = gr.Button("load your models")
        exports.click(load_cust, inputs=[basem, secondm], outputs=[])
    output_image = gr.Image(label="Generated Image")
    submit_button.click(generate_image, inputs=[prompt, negative_prompt], outputs=output_image)

# Launch the demo
demo.launch()