zhiqiulin commited on
Commit
474c1ae
1 Parent(s): 5b8a47b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -55,7 +55,7 @@ def rank_images(model_name, images, text):
55
  results = model_pipe(images=images, texts=[text]).cpu()[:, 0].tolist() # Perform the model inference on all images
56
  print("Initial results: should be imgs x texts", results)
57
  ranked_results = sorted(zip(images, results), key=lambda x: x[1], reverse=True) # Rank results
58
- ranked_images = [img for img, score in ranked_results]
59
  print("Ranked Results:", ranked_results)
60
  except RuntimeError as e:
61
  print(f"RuntimeError during model inference: {e}")
@@ -86,7 +86,8 @@ demo_vqascore_ranking = gr.Interface(
86
  ], # define the types of inputs
87
  outputs=gr.Gallery(label="Ranked Images"), # define the type of output
88
  title="VQAScore Ranking", # title of the app
89
- description="This model ranks a gallery of images based on their similarity to a text prompt."
 
90
  )
91
 
92
  # Combine the demos into a tabbed interface
 
55
  results = model_pipe(images=images, texts=[text]).cpu()[:, 0].tolist() # Perform the model inference on all images
56
  print("Initial results: should be imgs x texts", results)
57
  ranked_results = sorted(zip(images, results), key=lambda x: x[1], reverse=True) # Rank results
58
+ ranked_images = [(img, f"Rank: {rank + 1} - Score: {score:.2f}") for rank, (img, score) in enumerate(ranked_results)] # Pair images with their scores and rank
59
  print("Ranked Results:", ranked_results)
60
  except RuntimeError as e:
61
  print(f"RuntimeError during model inference: {e}")
 
86
  ], # define the types of inputs
87
  outputs=gr.Gallery(label="Ranked Images"), # define the type of output
88
  title="VQAScore Ranking", # title of the app
89
+ description="This model ranks a gallery of images based on their similarity to a text prompt.",
90
+ allow_flagging='never'
91
  )
92
 
93
  # Combine the demos into a tabbed interface