taesiri commited on
Commit
6c8426b
·
1 Parent(s): 3b0010c
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -20,7 +20,7 @@ concat = lambda x: np.concatenate(x, axis=0)
20
  # Embeddings
21
  gdown.cached_download(
22
  url="https://drive.google.com/uc?id=116CiA_cXciGSl72tbAUDoN-f1B9Frp89",
23
- path="./embeddings.pkl",
24
  quiet=False,
25
  md5="002b2a7f5c80d910b9cc740c2265f058",
26
  )
@@ -84,15 +84,10 @@ def search(query_image, searcher=searcher):
84
  gallery_images = [training_folder.imgs[int(X)][0] for X in top_indices[:5]]
85
  predicted_labels = {id_to_bird_name[X[0]]: X[1] / 20.0 for X in result_ctr}
86
 
87
- print("gallery_images:", gallery_images)
88
-
89
  # CHM Prediction
90
  kNN_results = (top1_label, result_ctr[0][1], gallery_images)
91
  support_files = [training_folder.imgs[int(X)][0] for X in indices[0]]
92
-
93
- print(support_files)
94
  support_labels = [training_folder.imgs[int(X)][1] for X in indices[0]]
95
- print(support_labels)
96
 
97
  support = [support_files, support_labels]
98
 
@@ -102,14 +97,22 @@ def search(query_image, searcher=searcher):
102
 
103
  viz_plot = plot_from_reranker_output(chm_output, draw_arcs=False)
104
 
105
- return predicted_labels, gallery_images, viz_plot
106
 
107
 
108
  demo = gr.Interface(
109
  search,
110
  gr.Image(type="filepath"),
111
- ["label", "gallery", "plot"],
112
- examples=[["./examples/bird.jpg"]],
 
 
 
 
 
 
 
 
113
  description="WIP - kNN on CUB dataset",
114
  title="Work in Progress - CHM-Corr",
115
  )
 
20
  # Embeddings
21
  gdown.cached_download(
22
  url="https://drive.google.com/uc?id=116CiA_cXciGSl72tbAUDoN-f1B9Frp89",
23
+ path="./embeddings.pickle",
24
  quiet=False,
25
  md5="002b2a7f5c80d910b9cc740c2265f058",
26
  )
 
84
  gallery_images = [training_folder.imgs[int(X)][0] for X in top_indices[:5]]
85
  predicted_labels = {id_to_bird_name[X[0]]: X[1] / 20.0 for X in result_ctr}
86
 
 
 
87
  # CHM Prediction
88
  kNN_results = (top1_label, result_ctr[0][1], gallery_images)
89
  support_files = [training_folder.imgs[int(X)][0] for X in indices[0]]
 
 
90
  support_labels = [training_folder.imgs[int(X)][1] for X in indices[0]]
 
91
 
92
  support = [support_files, support_labels]
93
 
 
97
 
98
  viz_plot = plot_from_reranker_output(chm_output, draw_arcs=False)
99
 
100
+ return viz_plot, predicted_labels, gallery_images
101
 
102
 
103
  demo = gr.Interface(
104
  search,
105
  gr.Image(type="filepath"),
106
+ ["plot", "label", "gallery"],
107
+ examples=[
108
+ ["./examples/bird.jpg"],
109
+ ["./examples/Red_Winged_Blackbird_0012_6015.jpg"],
110
+ ["./examples/Red_Winged_Blackbird_0025_5342.jpg"],
111
+ ["./examples/sample1.jpeg"],
112
+ ["./examples/sample2.jpeg"],
113
+ ["./examples/Yellow_Headed_Blackbird_0020_8549.jpg"],
114
+ ["./examples/Yellow_Headed_Blackbird_0026_8545.jpg"],
115
+ ],
116
  description="WIP - kNN on CUB dataset",
117
  title="Work in Progress - CHM-Corr",
118
  )