venkyyuvy commited on
Commit
6f00f31
·
1 Parent(s): b1f02cd

label prob output

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -11,8 +11,8 @@ def inference(input_img, captions):
11
  # this is the image-text similarity score
12
  logits_per_image = outputs.logits_per_image
13
  probs = logits_per_image.softmax(dim=1)
14
- probabilities_percentages = ', '.join(['{:.2f}%'.format(prob.item() * 100) for prob in probs[0]])
15
- return probabilities_percentages
16
 
17
  title = "CLIP Inference: Application using a pretrained CLIP model"
18
  description = "An application using Gradio interface that accepts an image and some captions, and displays a probability score with which each caption describes the image "
@@ -31,6 +31,7 @@ demo = gr.Interface(
31
  gr.Image(shape=(416, 416), label="Input Image"),
32
  gr.Textbox(placeholder="List of captions")],
33
  outputs = [gr.Textbox(label="Probability score on captions likely describing the image")],
 
34
  title = title,
35
  description = description,
36
  examples = examples,
 
11
  # this is the image-text similarity score
12
  logits_per_image = outputs.logits_per_image
13
  probs = logits_per_image.softmax(dim=1)
14
+ confidences = {i: probs[i] for i in range(len(probs))}
15
+ return confidences
16
 
17
  title = "CLIP Inference: Application using a pretrained CLIP model"
18
  description = "An application using Gradio interface that accepts an image and some captions, and displays a probability score with which each caption describes the image "
 
31
  gr.Image(shape=(416, 416), label="Input Image"),
32
  gr.Textbox(placeholder="List of captions")],
33
  outputs = [gr.Textbox(label="Probability score on captions likely describing the image")],
34
+ outputs = gr.Label(),
35
  title = title,
36
  description = description,
37
  examples = examples,