Hev832 commited on
Commit
f33aefe
·
verified ·
1 Parent(s): 0bbc490

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -1,18 +1,19 @@
1
  import gradio as gr
2
  from diffusers import DiffusionPipeline
3
 
4
-
5
  def generate_image(modelsyu, prompt, negative_prompt):
6
-
7
- modelslo = [modelsyu]
8
- pipeline = DiffusionPipeline.from_pretrained(modelslo)
9
  pipeline.to("cpu")
10
- image = pipeline(prompt, negative_prompt=negative_prompt).images[0]
 
 
 
 
11
  return image
12
 
13
  # Define the Gradio interface
14
  with gr.Blocks() as demo:
15
- gr.Markdown("# Text to Image Generation Custom models Demo")
16
  prompt = gr.Textbox(label="Prompt", placeholder="Enter your text prompt here")
17
  negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="Enter your negative prompt here")
18
  submit_button = gr.Button("Generate Image")
 
1
  import gradio as gr
2
  from diffusers import DiffusionPipeline
3
 
 
4
  def generate_image(modelsyu, prompt, negative_prompt):
5
+ pipeline = DiffusionPipeline.from_pretrained(modelsyu)
 
 
6
  pipeline.to("cpu")
7
+ # Check if negative_prompt is supported by the pipeline
8
+ if 'negative_prompt' in pipeline.parameters:
9
+ image = pipeline(prompt, negative_prompt=negative_prompt).images[0]
10
+ else:
11
+ image = pipeline(prompt).images[0]
12
  return image
13
 
14
  # Define the Gradio interface
15
  with gr.Blocks() as demo:
16
+ gr.Markdown("# Text to Image Generation Custom Models Demo")
17
  prompt = gr.Textbox(label="Prompt", placeholder="Enter your text prompt here")
18
  negative_prompt = gr.Textbox(label="Negative Prompt", placeholder="Enter your negative prompt here")
19
  submit_button = gr.Button("Generate Image")