idlebg commited on
Commit
8cca5bd
1 Parent(s): 585b27a

Update app.py

Browse files

n_prompt embedded to avoid confusion among newcomers
inference on all FFusion models at the same time.

Files changed (1) hide show
  1. app.py +27 -31
app.py CHANGED
@@ -54,48 +54,44 @@ class Model:
54
  images = [PIL.Image.fromarray(np.array(img)) for img in images]
55
  return images
56
 
57
-
58
-
59
-
60
-
61
- def generateImage(prompt, n_prompt, modelName, schedulerName):
62
- images = models[modelName].process(prompt, n_prompt)
63
- images = [np.array(img) for img in images]
64
- return images[0] # Return the first image
65
 
66
  def create_demo():
67
  # Settings are defined here
68
- prompt = gr.inputs.Textbox(label='Prompt',default='a sprinkled donut sitting on top of a table, blender donut tutorial, colorful hyperrealism, everything is made of candy, hyperrealistic digital painting, covered in sprinkles and crumbs, vibrant colors hyper realism, colorful smoke explosion background')
69
- n_prompt = gr.inputs.Textbox(
70
- label='Negative Prompt',
71
- default='(disfigured), ((bad art)), ((deformed)), ((extra limbs)), (((duplicate))), ((morbid)), ((mutilated)), out of frame, extra fingers, mutated hands, poorly drawn eyes, ((poorly drawn hands)), ((poorly drawn face)), (((mutation))), ((ugly)), blurry, ((bad anatomy)), (((bad proportions))), cloned face, body out of frame, out of frame, bad anatomy, gross proportions, (malformed limbs), ((missing arms)), ((missing legs)), (((extra arms))), (((extra legs))), (fused fingers), (too many fingers), (((long neck))), Deformed, blurry'
72
- )
73
- modelName = gr.inputs.Dropdown(choices=list(models.keys()),
74
- label="FFusion Test Model",
75
- default=list(models.keys())[0]) # Set the default model
76
  schedulerName = gr.inputs.Dropdown(choices=list(schedulers.keys()),
77
  label="Scheduler",
78
  default=list(schedulers.keys())[0]) # Set the default scheduler
79
- inputs = [prompt, n_prompt, modelName, schedulerName]
80
 
81
  # Images are displayed here
82
- result = gr.outputs.Image(label='Output', type="numpy")
83
 
84
  # Define the function to run when the button is clicked
85
- def run(prompt, n_prompt, modelName, schedulerName):
86
- return generateImage(prompt, n_prompt, modelName, schedulerName)
 
87
 
88
  # Create the interface
89
  iface = gr.Interface(
90
- fn=run,
91
- inputs=inputs,
92
- outputs=result,
93
- layout=[
94
- gr.Markdown("### FFusion.AI - beta Playground"),
95
- inputs,
96
- result
97
- ]
98
- )
99
 
100
  return iface
101
 
@@ -103,7 +99,7 @@ if __name__ == '__main__':
103
  models = {
104
  "FFUSION.ai-768-BaSE": Model("FFusion/FFusion-BaSE", list(schedulers.keys())[0]),
105
  "FFUSION.ai-v2.1-768-BaSE-alpha-preview": Model("FFusion/di.FFUSION.ai-v2.1-768-BaSE-alpha", list(schedulers.keys())[0]),
106
- "FFusion.ai.Beta-512": Model("FFusion/di.ffusion.ai.Beta512", list(schedulers.keys())[0])
107
  }
108
  demo = create_demo()
109
- demo.launch()
 
54
  images = [PIL.Image.fromarray(np.array(img)) for img in images]
55
  return images
56
 
57
+ def generateImage(prompt, modelNames, schedulerName):
58
+ n_prompt = '(disfigured), ((bad art)), ((deformed)), ((extra limbs)), (((duplicate))), ((morbid)), ((mutilated)), out of frame, extra fingers, mutated hands, poorly drawn eyes, ((poorly drawn hands)), ((poorly drawn face)), (((mutation))), ((ugly)), blurry, ((bad anatomy)), (((bad proportions))), cloned face, body out of frame, out of frame, bad anatomy, gross proportions, (malformed limbs), ((missing arms)), ((missing legs)), (((extra arms))), (((extra legs))), (fused fingers), (too many fingers), (((long neck))), Deformed, blurry'
59
+ images = []
60
+ for modelName in modelNames:
61
+ image = models[modelName].process(prompt, n_prompt)
62
+ images.append(np.array(image[0])) # Return the first image
63
+ return images
 
64
 
65
  def create_demo():
66
  # Settings are defined here
67
+ prompt = gr.inputs.Textbox(label='Prompt',default='a sprinkled donut sitting on top of a purple cherry apple, colorful hyperrealism')
68
+ modelNames = gr.inputs.CheckboxGroup(choices=list(models.keys()),
69
+ label="FFusion Test Models",
70
+ default=list(models.keys())) # Set all models as default
 
 
 
 
71
  schedulerName = gr.inputs.Dropdown(choices=list(schedulers.keys()),
72
  label="Scheduler",
73
  default=list(schedulers.keys())[0]) # Set the default scheduler
74
+ inputs = [prompt, modelNames, schedulerName]
75
 
76
  # Images are displayed here
77
+ result = [gr.outputs.Image(label=f'Output from {model}', type="numpy") for model in models.keys()]
78
 
79
  # Define the function to run when the button is clicked
80
+ def run(prompt, modelNames, schedulerName):
81
+ images = generateImage(prompt, modelNames, schedulerName)
82
+ return images
83
 
84
  # Create the interface
85
  iface = gr.Interface(
86
+ fn=run,
87
+ inputs=inputs,
88
+ outputs=result,
89
+ layout=[
90
+ gr.Markdown("### FFusion.AI - beta Playground"),
91
+ inputs,
92
+ result
93
+ ]
94
+ )
95
 
96
  return iface
97
 
 
99
  models = {
100
  "FFUSION.ai-768-BaSE": Model("FFusion/FFusion-BaSE", list(schedulers.keys())[0]),
101
  "FFUSION.ai-v2.1-768-BaSE-alpha-preview": Model("FFusion/di.FFUSION.ai-v2.1-768-BaSE-alpha", list(schedulers.keys())[0]),
102
+ "FFusion.ai.Beta-512": Model("FFusion/di.ffusion.ai.Beta512", list(schedulers.keys())[0])
103
  }
104
  demo = create_demo()
105
+ demo.launch()