Update app.py
Browse filesn_prompt embedded to avoid confusion among newcomers
inference on all FFusion models at the same time.
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 |
-
|
62 |
-
|
63 |
-
|
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
|
69 |
-
|
70 |
-
|
71 |
-
|
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,
|
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,
|
86 |
-
|
|
|
87 |
|
88 |
# Create the interface
|
89 |
iface = gr.Interface(
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
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 |
-
|
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()
|