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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -4,10 +4,11 @@ from diffusers import DiffusionPipeline
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
 
 
4
  def generate_image(modelsyu, prompt, negative_prompt):
5
  pipeline = DiffusionPipeline.from_pretrained(modelsyu)
6
  pipeline.to("cpu")
7
+ # Attempt to generate an image with the negative prompt if supported
8
+ try:
9
  image = pipeline(prompt, negative_prompt=negative_prompt).images[0]
10
+ except TypeError:
11
+ # Fallback if negative_prompt is not supported
12
  image = pipeline(prompt).images[0]
13
  return image
14