Leyo commited on
Commit
6890dab
β€’
1 Parent(s): a897014

fix edge case saving with no images

Browse files
Files changed (1) hide show
  1. app_dialogue.py +12 -2
app_dialogue.py CHANGED
@@ -258,7 +258,12 @@ def flag_dope(
258
  images.append(ex[0]["file"])
259
  prev_ex_is_image = True
260
 
261
- image_flag = images[0]
 
 
 
 
 
262
  dope_dataset_writer.flag(
263
  flag_data=[
264
  model_selector,
@@ -287,7 +292,12 @@ def flag_problematic(
287
  if isinstance(ex[0], dict):
288
  images.append(ex[0]["file"])
289
 
290
- image_flag = images[0]
 
 
 
 
 
291
  problematic_dataset_writer.flag(
292
  flag_data=[
293
  model_selector,
 
258
  images.append(ex[0]["file"])
259
  prev_ex_is_image = True
260
 
261
+ if len(images)== 0:
262
+ black_image = Image.new('RGB', (20, 20), (0, 0, 0))
263
+ black_image.save("/tmp/gradio/fake_image.png")
264
+ image_flag = {'path': "/tmp/gradio/fake_image.png", 'size': None, 'orig_name': None, 'mime_type': 'image/png', 'is_stream': False, 'meta': {'_type': 'gradio.FileData'}}
265
+ else:
266
+ image_flag = images[0]
267
  dope_dataset_writer.flag(
268
  flag_data=[
269
  model_selector,
 
292
  if isinstance(ex[0], dict):
293
  images.append(ex[0]["file"])
294
 
295
+ if len(images)== 0:
296
+ black_image = Image.new('RGB', (20, 20), (0, 0, 0))
297
+ black_image.save("/tmp/gradio/fake_image.png")
298
+ image_flag = {'path': "/tmp/gradio/fake_image.png", 'size': None, 'orig_name': None, 'mime_type': 'image/png', 'is_stream': False, 'meta': {'_type': 'gradio.FileData'}}
299
+ else:
300
+ image_flag = images[0]
301
  problematic_dataset_writer.flag(
302
  flag_data=[
303
  model_selector,