Jordan Legg commited on
Commit
b9bd528
β€’
1 Parent(s): 6f5f495

updated gradio UI

Browse files
Files changed (1) hide show
  1. app.py +98 -54
app.py CHANGED
@@ -67,89 +67,133 @@ examples = [
67
  "an anime illustration of a wiener schnitzel",
68
  ]
69
 
70
- css="""
71
  #col-container {
72
  margin: 0 auto;
73
- max-width: 520px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  }
75
  """
76
 
77
  with gr.Blocks(css=css) as demo:
78
-
79
  with gr.Column(elem_id="col-container"):
80
- gr.Markdown(f"""# FLUX.1 [schnell]
81
- 12B param rectified flow transformer distilled from [FLUX.1 [pro]](https://blackforestlabs.ai/) for 4 step generation
82
- [[blog](https://blackforestlabs.ai/announcing-black-forest-labs/)] [[model](https://huggingface.co/black-forest-labs/FLUX.1-schnell)]
83
- """)
 
 
 
 
 
 
 
84
 
85
- with gr.Row():
86
-
87
  prompt = gr.Text(
88
- label="Prompt",
89
- show_label=False,
90
- max_lines=1,
91
- placeholder="Enter your prompt",
92
- container=False,
93
  )
94
-
95
- run_button = gr.Button("Run", scale=0)
96
 
97
- result = gr.Image(label="Result", show_label=False)
98
 
99
  with gr.Accordion("Advanced Settings", open=False):
100
-
101
- seed = gr.Slider(
102
- label="Seed",
103
- minimum=0,
104
- maximum=MAX_SEED,
105
- step=1,
106
- value=0,
107
- )
108
-
109
- randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
110
-
111
- with gr.Row():
112
-
113
- width = gr.Slider(
114
- label="Width",
115
- minimum=256,
116
- maximum=MAX_IMAGE_SIZE,
117
- step=32,
118
- value=1024,
119
  )
 
120
 
121
- height = gr.Slider(
122
- label="Height",
123
- minimum=256,
124
- maximum=MAX_IMAGE_SIZE,
125
- step=32,
126
- value=1024,
127
- )
128
-
129
- with gr.Row():
 
 
 
 
 
 
130
 
131
-
132
  num_inference_steps = gr.Slider(
133
  label="Number of inference steps",
134
  minimum=1,
135
  maximum=50,
136
  step=1,
137
  value=4,
 
138
  )
139
 
 
 
 
 
 
 
 
 
 
 
 
140
  gr.Examples(
141
- examples = examples,
142
- fn = infer,
143
- inputs = [prompt],
144
- outputs = [result, seed],
145
  cache_examples="lazy"
146
  )
147
-
148
  gr.on(
149
  triggers=[run_button.click, prompt.submit],
150
- fn = infer,
151
- inputs = [prompt, seed, randomize_seed, width, height, num_inference_steps],
152
- outputs = [result, seed]
153
  )
154
 
155
  demo.launch()
 
67
  "an anime illustration of a wiener schnitzel",
68
  ]
69
 
70
+ css = """
71
  #col-container {
72
  margin: 0 auto;
73
+ max-width: 720px;
74
+ }
75
+ .container {
76
+ margin: 0 auto;
77
+ padding: 20px;
78
+ border-radius: 10px;
79
+ background-color: #f0f0f0;
80
+ }
81
+ .title {
82
+ text-align: center;
83
+ color: #2c3e50;
84
+ margin-bottom: 20px;
85
+ }
86
+ .subtitle {
87
+ text-align: center;
88
+ color: #34495e;
89
+ margin-bottom: 30px;
90
+ }
91
+ .speed-info {
92
+ background-color: #e74c3c;
93
+ color: white;
94
+ padding: 10px;
95
+ border-radius: 5px;
96
+ text-align: center;
97
+ margin-bottom: 20px;
98
+ }
99
+ .prompt-container {
100
+ display: flex;
101
+ gap: 10px;
102
+ margin-bottom: 20px;
103
+ }
104
+ .advanced-settings {
105
+ background-color: #ecf0f1;
106
+ padding: 15px;
107
+ border-radius: 5px;
108
+ margin-top: 20px;
109
  }
110
  """
111
 
112
  with gr.Blocks(css=css) as demo:
 
113
  with gr.Column(elem_id="col-container"):
114
+ gr.HTML(
115
+ """
116
+ <div class="container">
117
+ <h1 class="title">FLUX.1 [schnell] - Mixed Precision Edition</h1>
118
+ <h3 class="subtitle">12B param rectified flow transformer optimized for maximum inference speed</h3>
119
+ <div class="speed-info">
120
+ <strong>Mixed Precision Pipeline:</strong> FP32 Text Encoders + FP16 Core for optimal speed and quality
121
+ </div>
122
+ </div>
123
+ """
124
+ )
125
 
126
+ with gr.Column(elem_id="prompt-container"):
 
127
  prompt = gr.Text(
128
+ label="Enter your prompt",
129
+ placeholder="A futuristic cityscape with flying cars",
130
+ lines=2
 
 
131
  )
132
+ run_button = gr.Button("Generate Image", variant="primary")
 
133
 
134
+ result = gr.Image(label="Generated Image")
135
 
136
  with gr.Accordion("Advanced Settings", open=False):
137
+ with gr.Column(elem_id="advanced-settings"):
138
+ seed = gr.Slider(
139
+ label="Seed",
140
+ minimum=0,
141
+ maximum=MAX_SEED,
142
+ step=1,
143
+ value=0,
144
+ info="Set to 0 for random seed"
 
 
 
 
 
 
 
 
 
 
 
145
  )
146
+ randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
147
 
148
+ with gr.Row():
149
+ width = gr.Slider(
150
+ label="Width",
151
+ minimum=256,
152
+ maximum=MAX_IMAGE_SIZE,
153
+ step=32,
154
+ value=1024,
155
+ )
156
+ height = gr.Slider(
157
+ label="Height",
158
+ minimum=256,
159
+ maximum=MAX_IMAGE_SIZE,
160
+ step=32,
161
+ value=1024,
162
+ )
163
 
 
164
  num_inference_steps = gr.Slider(
165
  label="Number of inference steps",
166
  minimum=1,
167
  maximum=50,
168
  step=1,
169
  value=4,
170
+ info="Lower values = faster generation, higher values = potentially better quality"
171
  )
172
 
173
+ gr.Markdown(
174
+ """
175
+ ### About FLUX.1 [schnell]
176
+ - Distilled from [FLUX.1 [pro]](https://blackforestlabs.ai/)
177
+ - Optimized for 4-step generation
178
+ - Mixed precision pipeline for maximum speed
179
+
180
+ [[Blog]](https://blackforestlabs.ai/announcing-black-forest-labs/) | [[Model]](https://huggingface.co/black-forest-labs/FLUX.1-schnell)
181
+ """
182
+ )
183
+
184
  gr.Examples(
185
+ examples=examples,
186
+ fn=infer,
187
+ inputs=[prompt],
188
+ outputs=[result, seed],
189
  cache_examples="lazy"
190
  )
191
+
192
  gr.on(
193
  triggers=[run_button.click, prompt.submit],
194
+ fn=infer,
195
+ inputs=[prompt, seed, randomize_seed, width, height, num_inference_steps],
196
+ outputs=[result, seed]
197
  )
198
 
199
  demo.launch()