Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,20 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from diffusers import DiffusionPipeline
|
| 3 |
|
| 4 |
-
#
|
|
|
|
| 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 |
|
|
@@ -18,10 +24,10 @@ with gr.Blocks() as 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('
|
| 22 |
-
basem = gr.Textbox(label="
|
| 23 |
-
secondm = gr.Textbox(label="
|
| 24 |
-
exports = gr.Button("
|
| 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)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from diffusers import DiffusionPipeline
|
| 3 |
|
| 4 |
+
# Initialize the pipeline variable globally
|
| 5 |
+
pipeline = None
|
| 6 |
|
| 7 |
+
# Load the pipeline and LoRA weights
|
| 8 |
def load_cust(base_model, models_sec):
|
| 9 |
+
global pipeline
|
| 10 |
pipeline = DiffusionPipeline.from_pretrained(base_model)
|
| 11 |
pipeline.load_lora_weights(models_sec)
|
| 12 |
|
| 13 |
def generate_image(prompt, negative_prompt):
|
| 14 |
+
global pipeline
|
| 15 |
# Generate the image with the provided prompts
|
| 16 |
+
if pipeline is None:
|
| 17 |
+
return "Pipeline not loaded. Please load the models first."
|
| 18 |
image = pipeline(prompt, negative_prompt=negative_prompt).images[0]
|
| 19 |
return image
|
| 20 |
|
|
|
|
| 24 |
prompt = gr.Textbox(label="Prompt", placeholder="Enter your text prompt here")
|
| 25 |
negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="Enter your negative prompt here")
|
| 26 |
submit_button = gr.Button("Generate Image")
|
| 27 |
+
with gr.Accordion('Load your custom models first'):
|
| 28 |
+
basem = gr.Textbox(label="Your base model", value='John6666/pony-diffusion-v6-xl-sdxl-spo')
|
| 29 |
+
secondm = gr.Textbox(label="Your LoRA model", value='Blane187/miyako-saitou-s1-ponyxl-lora-nochekaiser')
|
| 30 |
+
exports = gr.Button("Load your models")
|
| 31 |
exports.click(load_cust, inputs=[basem, secondm], outputs=[])
|
| 32 |
output_image = gr.Image(label="Generated Image")
|
| 33 |
submit_button.click(generate_image, inputs=[prompt, negative_prompt], outputs=output_image)
|