AparnaVelvet commited on
Commit
3129546
·
verified ·
1 Parent(s): 1b503e0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +112 -190
app.py CHANGED
@@ -26,8 +26,10 @@ print("Pipeline loaded successfully!")
26
  @spaces.GPU(duration=30)
27
  def generate_single_image(prompt, seed):
28
  generator = torch.Generator("cuda").manual_seed(int(seed))
 
29
  image = pipe(
30
  prompt=prompt,
 
31
  num_inference_steps=9,
32
  guidance_scale=0.0,
33
  generator=generator,
@@ -40,210 +42,138 @@ def generate_single_image(prompt, seed):
40
  def generate_one_ui(prompt, randomize_seed, manual_seed):
41
  if not prompt.strip():
42
  return None, "⚠️ ERROR: INPUT REQUIRED."
43
-
44
  if randomize_seed:
45
  seed = torch.randint(0, 2**32 - 1, (1,)).item()
46
  else:
47
  seed = int(manual_seed)
48
-
49
  image = generate_single_image(prompt, seed)
50
  return image, f"✅ EXECUTION COMPLETE. SEED: {seed}"
51
 
52
  # ==========================================
53
- # 4. Logic for Batch Mode
54
  # ==========================================
55
- def batch_process(txt_file, randomize_seed, progress=gr.Progress()):
56
- if txt_file is None:
57
- return None, "⚠️ ERROR: NO DATA FILE UPLOADED."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
 
 
 
 
59
  with open(txt_file.name, "r", encoding="utf-8") as f:
60
  content = f.read()
61
-
62
  raw_prompts = content.split('*')
63
- prompts = []
64
- for p in raw_prompts:
65
- cleaned = p.replace('\n', ' ').replace('\r', ' ').strip()
66
- if cleaned:
67
- prompts.append(cleaned)
68
-
69
  if not prompts:
70
- return None, "⚠️ ERROR: INVALID FORMAT. USE *PROMPT*."
71
-
72
- total = len(prompts)
73
- temp_dir = tempfile.mkdtemp()
74
- generated_files = []
75
-
76
- for i, prompt in enumerate(prompts):
77
- progress((i, total), desc=f"PROCESSING {i+1} OF {total}...")
78
 
79
- if randomize_seed:
80
- seed = torch.randint(0, 2**32 - 1, (1,)).item()
81
- else:
82
- seed = 42
83
-
84
- image = generate_single_image(prompt, seed)
85
 
86
- filename = f"{i+1:04d}.png"
87
- filepath = os.path.join(temp_dir, filename)
88
- image.save(filepath)
89
- generated_files.append(filepath)
90
-
91
- zip_path = os.path.join(temp_dir, "batch_images.zip")
92
- with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as zipf:
93
- for filepath in generated_files:
94
- zipf.write(filepath, arcname=os.path.basename(filepath))
95
- zipf.write(txt_file.name, arcname="original_prompts.txt")
96
-
97
- return zip_path, f"✅ BATCH COMPLETE. {total} FILES SECURED."
98
 
99
  # ==========================================
100
- # 5. The Cyberpunk HUD CSS (Nuclear Override)
101
  # ==========================================
102
  custom_css = """
103
- /* FORCE DARK BACKGROUND & FONT */
104
  body, .gradio-container, .main {
105
  background-color: #050505 !important;
106
- background-image:
107
- linear-gradient(rgba(255, 0, 60, 0.05) 1px, transparent 1px),
108
- linear-gradient(90deg, rgba(255, 0, 60, 0.05) 1px, transparent 1px) !important;
109
  background-size: 20px 20px !important;
110
  color: #ff3333 !important;
111
  font-family: 'Courier New', monospace !important;
112
  }
113
-
114
- /* KILL ALL INNER GREY WRAPPERS */
115
- .block, .form, .wrap, fieldset, .panel {
116
- background: transparent !important;
117
- border: none !important;
118
- box-shadow: none !important;
119
- }
120
-
121
- /* GLASS PANELS (OUTER CONTAINERS ONLY) */
122
  .glass-panel {
123
  background: rgba(15, 0, 0, 0.7) !important;
124
  backdrop-filter: blur(10px) !important;
125
- -webkit-backdrop-filter: blur(10px) !important;
126
  border: 1px solid rgba(255, 0, 60, 0.3) !important;
127
  box-shadow: 0 0 15px rgba(255, 0, 60, 0.1), inset 0 0 20px rgba(255, 0, 60, 0.05) !important;
128
  border-radius: 4px !important;
129
  margin-bottom: 15px !important;
130
  padding: 15px !important;
131
  }
132
-
133
- /* GLOWING HEADER */
134
- h1, h2, h3, .prose h1, .prose h3 {
135
- color: #ff003c !important;
136
- text-transform: uppercase !important;
137
- letter-spacing: 2px !important;
138
- text-shadow: 0 0 10px rgba(255, 0, 60, 0.7) !important;
139
- text-align: center !important;
140
- }
141
-
142
- /* FORCE RADIO BUTTONS HORIZONTAL & STYLE THEM */
143
- .gr-radio-group {
144
- display: flex !important;
145
- flex-direction: row !important;
146
- gap: 10px !important;
147
- width: 100% !important;
148
- background: transparent !important;
149
- justify-content: center !important;
150
- }
151
- .gr-radio-group .wrap {
152
- display: flex !important;
153
- flex-direction: row !important;
154
- gap: 10px !important;
155
- width: 100% !important;
156
- background: transparent !important;
157
- }
158
- .gr-radio-group label {
159
- background: rgba(30, 0, 0, 0.8) !important;
160
- border: 1px solid #550000 !important;
161
- color: #ff6666 !important;
162
- padding: 10px 15px !important;
163
- border-radius: 4px !important;
164
- cursor: pointer !important;
165
- flex: 1 !important;
166
- text-align: center !important;
167
- transition: all 0.3s !important;
168
- box-shadow: none !important;
169
- }
170
- .gr-radio-group label.selected {
171
- background: rgba(255, 0, 60, 0.2) !important;
172
- border-color: #ff003c !important;
173
- color: #ffffff !important;
174
- box-shadow: 0 0 15px #ff003c !important;
175
- }
176
  .gr-radio-group input[type="radio"] { display: none !important; }
177
-
178
- /* FIX CHECKBOXES (Kill the blue) */
179
- input[type="checkbox"] {
180
- accent-color: #ff003c !important;
181
- background-color: #000 !important;
182
- border: 1px solid #ff003c !important;
183
- }
184
-
185
- /* KILL THE ORANGE BUTTON -> NEON RED */
186
- button.primary, .gr-button-primary {
187
- background: linear-gradient(90deg, #550000, #ff003c, #550000) !important;
188
- background-size: 200% auto !important;
189
- border: 1px solid #ff003c !important;
190
- color: #ffffff !important;
191
- box-shadow: 0 0 15px rgba(255, 0, 60, 0.5) !important;
192
- font-weight: bold !important;
193
- text-transform: uppercase !important;
194
- letter-spacing: 2px !important;
195
- transition: 0.5s !important;
196
- }
197
- button.primary:hover, .gr-button-primary:hover {
198
- background-position: right center !important;
199
- box-shadow: 0 0 30px #ff003c !important;
200
- }
201
-
202
- /* INPUT BOXES */
203
- textarea, input[type="text"], input[type="number"] {
204
- background: rgba(0, 0, 0, 0.9) !important;
205
- border: 1px solid #800000 !important;
206
- color: #ff003c !important;
207
- font-family: monospace !important;
208
- box-shadow: inset 0 0 10px rgba(255,0,0,0.2) !important;
209
- }
210
- textarea:focus, input:focus {
211
- border-color: #ff003c !important;
212
- box-shadow: 0 0 15px #ff003c !important;
213
- }
214
-
215
- /* FILE UPLOAD GLOW */
216
- .file-preview {
217
- border: 1px dashed #ff003c !important;
218
- background: rgba(10, 0, 0, 0.8) !important;
219
- }
220
-
221
- /* HIDE FOOTER */
222
  footer { display: none !important; }
223
  """
224
 
225
  # ==========================================
226
  # 6. Gradio UI Construction
227
  # ==========================================
228
- with gr.Blocks(theme=gr.themes.Base(), css=custom_css, title="Aparna's Image Generator") as demo:
229
 
230
  with gr.Column(elem_classes="glass-panel"):
231
- gr.Markdown(
232
- """
233
- # ⬡ APARNA'S HIGH-SPEED IMAGEGEN ⬡
234
- *SYSTEM STATUS: ONLINE // AWAITING INPUT*
235
- """
236
- )
237
-
238
- mode_selector = gr.Radio(
239
- choices=["🖼️ SINGLE IMAGE", "📦 BATCH GENERATE"],
240
- value="🖼️ SINGLE IMAGE",
241
- label="SELECT OPERATION MODE",
242
- interactive=True,
243
- elem_classes="gr-radio-group"
244
- )
245
 
246
- # --- SINGLE MODE VIEW ---
247
  with gr.Column(visible=True, elem_classes="glass-panel") as single_view:
248
  with gr.Row():
249
  with gr.Column(scale=1):
@@ -252,44 +182,40 @@ with gr.Blocks(theme=gr.themes.Base(), css=custom_css, title="Aparna's Image Gen
252
  single_randomize = gr.Checkbox(label="RANDOMIZE SEED", value=True)
253
  single_seed = gr.Number(label="MANUAL SEED", value=42, precision=0)
254
  single_btn = gr.Button("⚡ INITIALIZE GENERATION", variant="primary")
255
-
256
  with gr.Column(scale=1):
257
  single_output_img = gr.Image(label="VISUAL OUTPUT", interactive=False)
258
  single_status = gr.Textbox(label="SYSTEM LOG", interactive=False)
 
259
 
260
- single_btn.click(
261
- fn=generate_one_ui,
262
- inputs=[single_prompt, single_randomize, single_seed],
263
- outputs=[single_output_img, single_status]
264
- )
265
-
266
- # --- BATCH MODE VIEW ---
267
  with gr.Column(visible=False, elem_classes="glass-panel") as batch_view:
268
  with gr.Row():
269
  with gr.Column(scale=1):
270
- # NEW CLEAR INSTRUCTIONS
271
- gr.Markdown(
272
- """
273
- ### 📁 DATA INGESTION PROTOCOL
274
- 1. Open a notes app or text editor.
275
- 2. Type your prompts, wrapping each one in **asterisks (`*`)**.
276
- 3. *Example:* `*A cyberpunk city* *A glowing dragon* *A neon forest*`
277
- 4. Save the file as a **`.txt`** file and upload it below.
278
- """
279
- )
280
  txt_input = gr.File(label="UPLOAD TXT FILE", file_types=[".txt"])
281
  randomize_cb = gr.Checkbox(label="RANDOMIZE SEED", value=True)
282
- run_btn = gr.Button("⚡ EXECUTE BATCH SEQUENCE", variant="primary")
283
-
 
284
  with gr.Column(scale=1):
285
  status_text = gr.Textbox(label="SYSTEM LOG", interactive=False, lines=3)
286
- zip_output = gr.File(label="DOWNLOAD SECURE ARCHIVE (.ZIP)", interactive=False)
 
 
 
 
287
 
288
- run_btn.click(
289
- fn=batch_process,
290
- inputs=[txt_input, randomize_cb],
291
- outputs=[zip_output, status_text]
292
- )
 
 
 
 
 
 
293
 
294
  # --- THE SWITCH LOGIC ---
295
  def toggle_view(mode):
@@ -298,11 +224,7 @@ with gr.Blocks(theme=gr.themes.Base(), css=custom_css, title="Aparna's Image Gen
298
  else:
299
  return gr.update(visible=False), gr.update(visible=True)
300
 
301
- mode_selector.change(
302
- fn=toggle_view,
303
- inputs=[mode_selector],
304
- outputs=[single_view, batch_view]
305
- )
306
 
307
  if __name__ == "__main__":
308
  demo.launch(footer_links=[])
 
26
  @spaces.GPU(duration=30)
27
  def generate_single_image(prompt, seed):
28
  generator = torch.Generator("cuda").manual_seed(int(seed))
29
+ negative_prompt = "overlapping fingers, deformed hands, extra limbs, fused fingers, mutated hands, malformed limbs, bad anatomy, disfigured, low quality, worst quality"
30
  image = pipe(
31
  prompt=prompt,
32
+ negative_prompt=negative_prompt,
33
  num_inference_steps=9,
34
  guidance_scale=0.0,
35
  generator=generator,
 
42
  def generate_one_ui(prompt, randomize_seed, manual_seed):
43
  if not prompt.strip():
44
  return None, "⚠️ ERROR: INPUT REQUIRED."
 
45
  if randomize_seed:
46
  seed = torch.randint(0, 2**32 - 1, (1,)).item()
47
  else:
48
  seed = int(manual_seed)
 
49
  image = generate_single_image(prompt, seed)
50
  return image, f"✅ EXECUTION COMPLETE. SEED: {seed}"
51
 
52
  # ==========================================
53
+ # 4. Chunked Batch Processing Logic
54
  # ==========================================
55
+ def process_chunk(remaining_prompts, all_generated_files, session_dir, randomize_seed, batch_num, progress=gr.Progress()):
56
+ chunk = remaining_prompts[:10]
57
+ new_remaining = remaining_prompts[10:]
58
+
59
+ chunk_files = []
60
+
61
+ for i, prompt in enumerate(chunk):
62
+ progress((i, len(chunk)), desc=f"Generating {i+1}/{len(chunk)} in Batch {batch_num}...")
63
+ seed = torch.randint(0, 2**32 - 1, (1,)).item() if randomize_seed else 42
64
+ image = generate_single_image(prompt, seed)
65
+
66
+ img_idx = len(all_generated_files) + i + 1
67
+ filename = f"{img_idx:04d}.png"
68
+ filepath = os.path.join(session_dir, filename)
69
+ image.save(filepath)
70
+ chunk_files.append(filepath)
71
+
72
+ all_generated_files.extend(chunk_files)
73
+
74
+ # Create ZIP for this specific chunk
75
+ zip_path = os.path.join(session_dir, f"batch_{batch_num}.zip")
76
+ with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as zipf:
77
+ for fpath in chunk_files:
78
+ zipf.write(fpath, arcname=os.path.basename(fpath))
79
+
80
+ full_zip_path = None
81
+ status = f"✅ Batch {batch_num} complete ({len(chunk_files)} images)."
82
+
83
+ # Check if we are completely done
84
+ if not new_remaining:
85
+ status = f"✅ ALL BATCHES COMPLETE. Total: {len(all_generated_files)} images."
86
+ full_zip_path = os.path.join(session_dir, "FULL_ARCHIVE.zip")
87
+ with zipfile.ZipFile(full_zip_path, "w", zipfile.ZIP_DEFLATED) as zipf:
88
+ for fpath in all_generated_files:
89
+ zipf.write(fpath, arcname=os.path.basename(fpath))
90
+ zipf.write(os.path.join(session_dir, "prompts.txt"), arcname="original_prompts.txt")
91
+ continue_visible = False
92
+ else:
93
+ status += f" {len(new_remaining)} prompts remaining. Click Continue."
94
+ continue_visible = True
95
+
96
+ return (
97
+ gr.update(value=chunk_files, visible=True),
98
+ gr.update(value=zip_path, visible=True),
99
+ gr.update(value=full_zip_path, visible=full_zip_path is not None),
100
+ status,
101
+ gr.update(visible=continue_visible),
102
+ new_remaining,
103
+ all_generated_files,
104
+ batch_num + 1
105
+ )
106
 
107
+ def start_batch_wrapper(txt_file, randomize_seed):
108
+ if txt_file is None:
109
+ return [], None, None, "⚠️ ERROR: NO DATA FILE.", gr.update(visible=False), [], [], 1, ""
110
+
111
  with open(txt_file.name, "r", encoding="utf-8") as f:
112
  content = f.read()
113
+
114
  raw_prompts = content.split('*')
115
+ prompts = [p.replace('\n', ' ').replace('\r', ' ').strip() for p in raw_prompts if p.strip()]
116
+
 
 
 
 
117
  if not prompts:
118
+ return [], None, None, "⚠️ ERROR: INVALID FORMAT. USE *PROMPT*.", gr.update(visible=False), [], [], 1, ""
119
+
120
+ session_dir = tempfile.mkdtemp()
121
+ with open(os.path.join(session_dir, "prompts.txt"), "w", encoding="utf-8") as f:
122
+ f.write("\n".join(prompts))
 
 
 
123
 
124
+ res = process_chunk(prompts, [], session_dir, randomize_seed, 1)
125
+ return (*res, session_dir)
 
 
 
 
126
 
127
+ def continue_batch_wrapper(state_remaining, state_all_files, state_session_dir, randomize_seed, state_batch_num):
128
+ res = process_chunk(state_remaining, state_all_files, state_session_dir, randomize_seed, state_batch_num)
129
+ return (*res, state_session_dir)
 
 
 
 
 
 
 
 
 
130
 
131
  # ==========================================
132
+ # 5. The Cyberpunk HUD CSS
133
  # ==========================================
134
  custom_css = """
 
135
  body, .gradio-container, .main {
136
  background-color: #050505 !important;
137
+ background-image: linear-gradient(rgba(255, 0, 60, 0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 0, 60, 0.05) 1px, transparent 1px) !important;
 
 
138
  background-size: 20px 20px !important;
139
  color: #ff3333 !important;
140
  font-family: 'Courier New', monospace !important;
141
  }
142
+ .block, .form, .wrap, fieldset, .panel { background: transparent !important; border: none !important; box-shadow: none !important; }
 
 
 
 
 
 
 
 
143
  .glass-panel {
144
  background: rgba(15, 0, 0, 0.7) !important;
145
  backdrop-filter: blur(10px) !important;
 
146
  border: 1px solid rgba(255, 0, 60, 0.3) !important;
147
  box-shadow: 0 0 15px rgba(255, 0, 60, 0.1), inset 0 0 20px rgba(255, 0, 60, 0.05) !important;
148
  border-radius: 4px !important;
149
  margin-bottom: 15px !important;
150
  padding: 15px !important;
151
  }
152
+ h1, h2, h3, .prose h1, .prose h3 { color: #ff003c !important; text-transform: uppercase !important; letter-spacing: 2px !important; text-shadow: 0 0 10px rgba(255, 0, 60, 0.7) !important; text-align: center !important; }
153
+ .gr-radio-group { display: flex !important; flex-direction: row !important; gap: 10px !important; width: 100% !important; background: transparent !important; justify-content: center !important; }
154
+ .gr-radio-group .wrap { display: flex !important; flex-direction: row !important; gap: 10px !important; width: 100% !important; background: transparent !important; }
155
+ .gr-radio-group label { background: rgba(30, 0, 0, 0.8) !important; border: 1px solid #550000 !important; color: #ff6666 !important; padding: 10px 15px !important; border-radius: 4px !important; cursor: pointer !important; flex: 1 !important; text-align: center !important; transition: all 0.3s !important; box-shadow: none !important; }
156
+ .gr-radio-group label.selected { background: rgba(255, 0, 60, 0.2) !important; border-color: #ff003c !important; color: #ffffff !important; box-shadow: 0 0 15px #ff003c !important; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  .gr-radio-group input[type="radio"] { display: none !important; }
158
+ input[type="checkbox"] { accent-color: #ff003c !important; background-color: #000 !important; border: 1px solid #ff003c !important; }
159
+ button.primary, .gr-button-primary { background: linear-gradient(90deg, #550000, #ff003c, #550000) !important; background-size: 200% auto !important; border: 1px solid #ff003c !important; color: #ffffff !important; box-shadow: 0 0 15px rgba(255, 0, 60, 0.5) !important; font-weight: bold !important; text-transform: uppercase !important; letter-spacing: 2px !important; transition: 0.5s !important; }
160
+ button.primary:hover, .gr-button-primary:hover { background-position: right center !important; box-shadow: 0 0 30px #ff003c !important; }
161
+ textarea, input[type="text"], input[type="number"] { background: rgba(0, 0, 0, 0.9) !important; border: 1px solid #800000 !important; color: #ff003c !important; font-family: monospace !important; box-shadow: inset 0 0 10px rgba(255,0,0,0.2) !important; }
162
+ textarea:focus, input:focus { border-color: #ff003c !important; box-shadow: 0 0 15px #ff003c !important; }
163
+ .file-preview { border: 1px dashed #ff003c !important; background: rgba(10, 0, 0, 0.8) !important; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  footer { display: none !important; }
165
  """
166
 
167
  # ==========================================
168
  # 6. Gradio UI Construction
169
  # ==========================================
170
+ with gr.Blocks(theme=gr.themes.Base(), css=custom_css, title="Aparna's High-Speed ImageGen") as demo:
171
 
172
  with gr.Column(elem_classes="glass-panel"):
173
+ gr.Markdown("# ⬡ APARNA'S HIGH-SPEED IMAGEGEN ⬡\n*SYSTEM STATUS: ONLINE // AWAITING INPUT*")
174
+ mode_selector = gr.Radio(choices=["🖼️ SINGLE IMAGE", "📦 BATCH GENERATE"], value="🖼️ SINGLE IMAGE", label="SELECT OPERATION MODE", interactive=True, elem_classes="gr-radio-group")
 
 
 
 
 
 
 
 
 
 
 
 
175
 
176
+ # --- SINGLE MODE ---
177
  with gr.Column(visible=True, elem_classes="glass-panel") as single_view:
178
  with gr.Row():
179
  with gr.Column(scale=1):
 
182
  single_randomize = gr.Checkbox(label="RANDOMIZE SEED", value=True)
183
  single_seed = gr.Number(label="MANUAL SEED", value=42, precision=0)
184
  single_btn = gr.Button("⚡ INITIALIZE GENERATION", variant="primary")
 
185
  with gr.Column(scale=1):
186
  single_output_img = gr.Image(label="VISUAL OUTPUT", interactive=False)
187
  single_status = gr.Textbox(label="SYSTEM LOG", interactive=False)
188
+ single_btn.click(fn=generate_one_ui, inputs=[single_prompt, single_randomize, single_seed], outputs=[single_output_img, single_status])
189
 
190
+ # --- BATCH MODE ---
 
 
 
 
 
 
191
  with gr.Column(visible=False, elem_classes="glass-panel") as batch_view:
192
  with gr.Row():
193
  with gr.Column(scale=1):
194
+ gr.Markdown("### 📁 DATA INGESTION\nFormat: `*prompt 1* *prompt 2*`\n⚠️ **Limit: 10 images per batch** to prevent timeouts.")
 
 
 
 
 
 
 
 
 
195
  txt_input = gr.File(label="UPLOAD TXT FILE", file_types=[".txt"])
196
  randomize_cb = gr.Checkbox(label="RANDOMIZE SEED", value=True)
197
+ with gr.Row():
198
+ run_btn = gr.Button("⚡ START BATCH", variant="primary")
199
+ continue_btn = gr.Button("▶️ CONTINUE NEXT 10", variant="primary", visible=False)
200
  with gr.Column(scale=1):
201
  status_text = gr.Textbox(label="SYSTEM LOG", interactive=False, lines=3)
202
+ with gr.Row():
203
+ zip_chunk = gr.File(label="BATCH ZIP", interactive=False)
204
+ zip_full = gr.File(label="FULL ARCHIVE ZIP", interactive=False, visible=False)
205
+
206
+ gallery_output = gr.Gallery(label="LIVE PREVIEW", columns=4, visible=True)
207
 
208
+ # Hidden State Variables
209
+ state_remaining = gr.State([])
210
+ state_all_files = gr.State([])
211
+ state_session_dir = gr.State("")
212
+ state_batch_num = gr.State(1)
213
+
214
+ # Event Handlers
215
+ outputs_list = [gallery_output, zip_chunk, zip_full, status_text, continue_btn, state_remaining, state_all_files, state_batch_num, state_session_dir]
216
+
217
+ run_btn.click(fn=start_batch_wrapper, inputs=[txt_input, randomize_cb], outputs=outputs_list)
218
+ continue_btn.click(fn=continue_batch_wrapper, inputs=[state_remaining, state_all_files, state_session_dir, randomize_cb, state_batch_num], outputs=outputs_list)
219
 
220
  # --- THE SWITCH LOGIC ---
221
  def toggle_view(mode):
 
224
  else:
225
  return gr.update(visible=False), gr.update(visible=True)
226
 
227
+ mode_selector.change(fn=toggle_view, inputs=[mode_selector], outputs=[single_view, batch_view])
 
 
 
 
228
 
229
  if __name__ == "__main__":
230
  demo.launch(footer_links=[])