taesiri commited on
Commit
0457a29
·
1 Parent(s): 20e3844
Files changed (1) hide show
  1. app.py +17 -4
app.py CHANGED
@@ -305,18 +305,31 @@ with gr.Blocks() as demo:
305
  zip(response_data[::3], response_data[1::3], response_data[2::3])
306
  )
307
 
308
- # Filter out empty responses (only checking image and model name, notes are optional)
 
 
 
 
 
 
 
 
 
 
 
 
 
309
  valid_responses = [
310
  (img, txt, notes)
311
  for img, txt, notes in response_triplets
312
- if img is not None and txt
313
  ]
314
 
315
  if not valid_responses:
316
- gr.Warning("Please provide at least one response (image + text)!")
317
  return
318
 
319
- # Modify generate_json_files call to handle notes
320
  generate_json_files(source_img, valid_responses, post_id)
321
  gr.Info("Responses saved successfully! 🎉")
322
 
 
305
  zip(response_data[::3], response_data[1::3], response_data[2::3])
306
  )
307
 
308
+ # Check for responses with images but no model names
309
+ incomplete_responses = [
310
+ i + 1
311
+ for i, (img, txt, _) in enumerate(response_triplets)
312
+ if img is not None and not txt.strip()
313
+ ]
314
+
315
+ if incomplete_responses:
316
+ gr.Warning(
317
+ f"Please provide model names for responses: {', '.join(map(str, incomplete_responses))}!"
318
+ )
319
+ return
320
+
321
+ # Filter out empty responses (where both image and model name are empty)
322
  valid_responses = [
323
  (img, txt, notes)
324
  for img, txt, notes in response_triplets
325
+ if img is not None and txt.strip()
326
  ]
327
 
328
  if not valid_responses:
329
+ gr.Warning("Please provide at least one response (image + model name)!")
330
  return
331
 
332
+ # Generate JSON files with the valid responses
333
  generate_json_files(source_img, valid_responses, post_id)
334
  gr.Info("Responses saved successfully! 🎉")
335