Dominik commited on
Commit
aedb861
β€’
1 Parent(s): 25a58c7

Added error message if no images are given

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -364,6 +364,15 @@ def on_submit_btn_click(model_name, true_name, prompts, images):
364
  </div>
365
  """
366
 
 
 
 
 
 
 
 
 
 
367
  # calculate the image embeddings
368
  img_embeddings = calculate_image_embeddings(model_name, images)
369
 
@@ -538,7 +547,7 @@ with block as demo:
538
  <br><br>
539
  <b>How does it work?</b> We are giving CLIP your images and let it choose from 1000 possible names.
540
  As CLIP is predicting the names that match the given images, we can probe whether the model has seen your images
541
- during training.
542
  </p>
543
  </div>
544
  """
 
364
  </div>
365
  """
366
 
367
+ if images is None or len(images) < 1:
368
+ return None, None, f"""<br>
369
+ <div class="error-message" style="background-color: #fce4e4; border: 1px solid #fcc2c3; padding: 20px 30px; border-radius: var(--radius-lg);">
370
+ <span class="error-text" style="color: #cc0033; font-weight: bold;">
371
+ No images are given. Images are needed to determin whether {true_name} was in the dataset. Please upload at least a single image of {true_name}.
372
+ </span>
373
+ </div>
374
+ """
375
+
376
  # calculate the image embeddings
377
  img_embeddings = calculate_image_embeddings(model_name, images)
378
 
 
547
  <br><br>
548
  <b>How does it work?</b> We are giving CLIP your images and let it choose from 1000 possible names.
549
  As CLIP is predicting the names that match the given images, we can probe whether the model has seen your images
550
+ during training. The more images you upload the more confident you can be in the result!
551
  </p>
552
  </div>
553
  """