rahul7star commited on
Commit
d7195c9
·
verified ·
1 Parent(s): 2b61eb9

Update app_lora1.py

Browse files
Files changed (1) hide show
  1. app_lora1.py +71 -80
app_lora1.py CHANGED
@@ -147,134 +147,123 @@ def generate_image(prompt, height, width, steps, seed, guidance_scale):
147
  # GRADIO UI
148
  # ============================================================
149
  css = """
150
- #container {
151
- max-width: 1200px;
152
- margin: auto;
153
  }
154
 
155
  .section {
156
- margin-top: 16px;
157
- margin-bottom: 8px;
158
  }
159
 
160
  .generate-btn {
161
  background: linear-gradient(90deg, #4b6cb7, #182848) !important;
162
  color: white !important;
163
- border-radius: 8px !important;
164
  font-weight: 600;
165
- height: 44px;
 
166
  }
167
 
168
  .secondary-btn {
169
- border-radius: 8px !important;
170
- height: 44px;
171
  }
172
 
173
- input, textarea {
174
- border-radius: 8px !important;
175
  }
176
  """
177
 
178
  with gr.Blocks(
179
- title="Z-Image-Turbo (LoRA Safe)",
180
  css=css,
181
  ) as demo:
182
 
183
  gr.Markdown(
184
  """
185
  # 🎨 Z-Image-Turbo
186
- **Runtime LoRA · Safe Mode · Production UI**
187
- """,
188
- elem_classes="section"
189
  )
190
 
191
- with gr.Column(elem_id="container"):
 
 
 
 
 
 
192
 
193
- # ===============================
194
- # PROMPT
195
- # ===============================
196
- with gr.Column(elem_classes="section"):
197
  prompt = gr.Textbox(
198
  label="Prompt",
199
  value="boat in ocean",
200
- lines=3,
201
- placeholder="Describe what you want to generate…",
202
- )
203
-
204
- # ===============================
205
- # PARAMETERS
206
- # ===============================
207
- with gr.Row(elem_classes="section"):
208
- width = gr.Slider(256, 2048, value=1024, step=8, label="Width")
209
- height = gr.Slider(256, 2048, value=1024, step=8, label="Height")
210
-
211
- with gr.Row():
212
- steps = gr.Slider(1, 50, value=20, step=1, label="Inference Steps")
213
- guidance = gr.Slider(0, 10, value=0.0, step=0.5, label="Guidance Scale")
214
- seed = gr.Number(value=42, label="Seed", precision=0)
215
-
216
- # ===============================
217
- # ACTION BUTTON
218
- # ===============================
219
- with gr.Row(elem_classes="section"):
220
- run_btn = gr.Button("🚀 Generate Image", elem_classes="generate-btn")
221
-
222
- # ===============================
223
- # OUTPUT
224
- # ===============================
225
- with gr.Row(elem_classes="section"):
226
- final_image = gr.Image(
227
- label="Final Image",
228
- height=420,
229
  )
230
 
231
- gallery = gr.Gallery(
232
- label="Generation Steps",
233
- columns=4,
234
- height=260,
235
- )
236
-
237
- # ===============================
238
- # LORA CONTROLS
239
- # ===============================
240
- gr.Markdown("## 🧩 LoRA Controls", elem_classes="section")
241
 
242
- with gr.Row():
243
  lora_repo = gr.Textbox(
244
  label="LoRA Repository",
245
  value=DEFAULT_LORA_REPO,
246
- placeholder="username/repo",
 
247
  )
248
 
249
- with gr.Row():
250
  lora_dropdown = gr.Dropdown(
251
- label="Available LoRA Files",
252
  choices=[],
253
  interactive=True,
254
  )
255
 
256
- with gr.Row():
257
- refresh_btn = gr.Button("🔄 Refresh LoRA List", elem_classes="secondary-btn")
258
- clear_lora_btn = gr.Button("❌ Clear LoRA", elem_classes="secondary-btn")
259
-
260
- # ===============================
261
- # LOGS
262
- # ===============================
263
- logs_box = gr.Textbox(
264
- label="Logs",
265
- lines=14,
266
- interactive=False,
267
- )
268
 
269
- # ==================================================
270
- # CALLBACKS
271
- # ==================================================
 
 
 
 
 
 
 
 
272
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
273
  def refresh_loras(repo):
274
  files = list_loras_from_repo(repo)
275
  return gr.update(
276
  choices=files,
277
- value=files[0] if files else None
278
  )
279
 
280
  refresh_btn.click(
@@ -305,7 +294,7 @@ with gr.Blocks(
305
  pass
306
  return (
307
  gr.update(value=None),
308
- "🧹 LoRA cleared. Next generation will be base model only."
309
  )
310
 
311
  clear_lora_btn.click(
@@ -321,6 +310,8 @@ with gr.Blocks(
321
 
322
  demo.launch()
323
 
 
 
324
  # with gr.Blocks(title="Z-Image-Turbo (LoRA Safe)") as demo:
325
  # gr.Markdown("# 🎨 Z-Image-Turbo — Runtime LoRA (SAFE MODE)")
326
 
 
147
  # GRADIO UI
148
  # ============================================================
149
  css = """
150
+ .gradio-container {
151
+ max-width: 100% !important;
152
+ padding: 16px 32px !important;
153
  }
154
 
155
  .section {
156
+ margin-bottom: 12px;
 
157
  }
158
 
159
  .generate-btn {
160
  background: linear-gradient(90deg, #4b6cb7, #182848) !important;
161
  color: white !important;
 
162
  font-weight: 600;
163
+ height: 46px;
164
+ border-radius: 10px;
165
  }
166
 
167
  .secondary-btn {
168
+ height: 42px;
169
+ border-radius: 10px;
170
  }
171
 
172
+ textarea, input {
173
+ border-radius: 10px !important;
174
  }
175
  """
176
 
177
  with gr.Blocks(
178
+ title="Z-Image-Turbo (Runtime LoRA)",
179
  css=css,
180
  ) as demo:
181
 
182
  gr.Markdown(
183
  """
184
  # 🎨 Z-Image-Turbo
185
+ **Runtime LoRA · Safe Mode · Full-Width UI**
186
+ """
 
187
  )
188
 
189
+ # ======================================================
190
+ # MAIN LAYOUT
191
+ # ======================================================
192
+ with gr.Row():
193
+
194
+ # ================= LEFT PANEL =================
195
+ with gr.Column(scale=5):
196
 
197
+ # -------- Prompt --------
 
 
 
198
  prompt = gr.Textbox(
199
  label="Prompt",
200
  value="boat in ocean",
201
+ lines=4,
202
+ placeholder="Describe the image you want to generate…",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  )
204
 
205
+ # -------- LoRA Controls (NEXT TO PROMPT) --------
206
+ gr.Markdown("### 🧩 LoRA Controls")
 
 
 
 
 
 
 
 
207
 
 
208
  lora_repo = gr.Textbox(
209
  label="LoRA Repository",
210
  value=DEFAULT_LORA_REPO,
211
+ lines=2,
212
+ placeholder="username/repo (e.g. rahul7star/ZImageLora)",
213
  )
214
 
 
215
  lora_dropdown = gr.Dropdown(
216
+ label="LoRA File",
217
  choices=[],
218
  interactive=True,
219
  )
220
 
221
+ with gr.Row():
222
+ refresh_btn = gr.Button("🔄 Refresh LoRA List", elem_classes="secondary-btn")
223
+ clear_lora_btn = gr.Button("❌ Clear LoRA", elem_classes="secondary-btn")
 
 
 
 
 
 
 
 
 
224
 
225
+ # -------- Generation Controls --------
226
+ gr.Markdown("### ⚙️ Generation Settings")
227
+
228
+ with gr.Row():
229
+ width = gr.Slider(256, 2048, value=1024, step=8, label="Width")
230
+ height = gr.Slider(256, 2048, value=1024, step=8, label="Height")
231
+
232
+ with gr.Row():
233
+ steps = gr.Slider(1, 50, value=20, step=1, label="Steps")
234
+ guidance = gr.Slider(0, 10, value=0.0, step=0.5, label="Guidance")
235
+ seed = gr.Number(value=42, label="Seed", precision=0)
236
 
237
+ run_btn = gr.Button("🚀 Generate Image", elem_classes="generate-btn")
238
+
239
+ logs_box = gr.Textbox(
240
+ label="Logs",
241
+ lines=10,
242
+ interactive=False,
243
+ )
244
+
245
+ # ================= RIGHT PANEL =================
246
+ with gr.Column(scale=7):
247
+
248
+ final_image = gr.Image(
249
+ label="Final Image",
250
+ height=520,
251
+ )
252
+
253
+ gallery = gr.Gallery(
254
+ label="Generation Steps",
255
+ columns=4,
256
+ height=260,
257
+ )
258
+
259
+ # ======================================================
260
+ # CALLBACKS
261
+ # ======================================================
262
  def refresh_loras(repo):
263
  files = list_loras_from_repo(repo)
264
  return gr.update(
265
  choices=files,
266
+ value=files[0] if files else None,
267
  )
268
 
269
  refresh_btn.click(
 
294
  pass
295
  return (
296
  gr.update(value=None),
297
+ "🧹 LoRA cleared base model will be used."
298
  )
299
 
300
  clear_lora_btn.click(
 
310
 
311
  demo.launch()
312
 
313
+ demo.launch()
314
+
315
  # with gr.Blocks(title="Z-Image-Turbo (LoRA Safe)") as demo:
316
  # gr.Markdown("# 🎨 Z-Image-Turbo — Runtime LoRA (SAFE MODE)")
317