YannisK commited on
Commit
0cb19e3
1 Parent(s): 9fec9a2
Files changed (1) hide show
  1. app.py +8 -17
app.py CHANGED
@@ -91,12 +91,12 @@ def match(query_feat, pos_feat, LoweRatioTh=0.9):
91
 
92
  col = plt.get_cmap('tab10')
93
 
94
- def generate_matching_superfeatures(im1, im2, model_fn, scale_id=6, threshold=50, random_mode=False, sf_ids='', only_matching=True):
95
  print('im1:', im1.size)
96
  print('im2:', im2.size)
97
 
98
  net = net_sfm
99
- if model_fn == "ImageNet":
100
  net = net_imagenet
101
 
102
  # dataset_ = ImgDataset(images=[im1, im2], imsize=1024)
@@ -246,14 +246,6 @@ title = "Visualizing Super-features"
246
  description = "This is a visualization demo for the ICLR 2022 paper <b><a href='https://github.com/naver/fire' target='_blank'>Learning Super-Features for Image Retrieval</a></p></b>"
247
  article = "<p style='text-align: center'><a href='https://github.com/naver/fire' target='_blank'>Original Github Repo</a></p>"
248
 
249
-
250
- # css = ".output-image, .input-image {height: 40rem !important; width: 100% !important;}"
251
- # css = "@media screen and (max-width: 600px) { .output_image, .input_image {height:20rem !important; width: 100% !important;} }"
252
- # css = ".output_image, .input_image {hieght: 1000px !important}"
253
- css = ".input_image, .input_image {height: 600px !important; width: 600px !important;} "
254
- # css = ".output-image, .input-image {height: 40rem !important; width: 100% !important;}"
255
-
256
-
257
  iface = gr.Interface(
258
  fn=generate_matching_superfeatures,
259
  inputs=[
@@ -261,11 +253,11 @@ iface = gr.Interface(
261
  # gr.inputs.Image(shape=(1024, 1024), type="pil", label="Second Image"),
262
  gr.inputs.Image(type="pil", label="First Image"),
263
  gr.inputs.Image(type="pil", label="Second Image"),
264
- gr.inputs.Radio(["ImageNet", "SfM-120k (landmarks)"], label="Model", optional=False),
265
  gr.inputs.Slider(minimum=0, maximum=6, step=1, default=2, label="Scale"),
266
  gr.inputs.Slider(minimum=0, maximum=255, step=25, default=150, label="Binarization Threshold"),
267
- gr.inputs.Checkbox(default=False, label="Show random matching SFs"),
268
- gr.inputs.Textbox(lines=1, default="", label="SF IDs to show (comma separated numbers from 0-255; typing 'rX' will return X random SFs", optional=True),
269
  gr.inputs.Checkbox(default=True, label="Show only matching SFs"),
270
  ],
271
  outputs=[
@@ -278,11 +270,10 @@ iface = gr.Interface(
278
  layout="horizontal",
279
  description=description,
280
  article=article,
281
- css=css,
282
  examples=[
283
- ["chateau_1.png", "chateau_2.png", 3, 150, 'r8', True],
284
- ["anafi1.jpeg", "anafi2.jpeg", 4, 150, 'r8', True],
285
- ["areopoli1.jpeg", "areopoli2.jpeg", 4, 150, 'r8', True],
286
  ]
287
  )
288
  iface.launch(enable_queue=True)
 
91
 
92
  col = plt.get_cmap('tab10')
93
 
94
+ def generate_matching_superfeatures(im1, im2, Imagenet_model=False, scale_id=6, threshold=50, random_mode=False, sf_ids='', only_matching=True):
95
  print('im1:', im1.size)
96
  print('im2:', im2.size)
97
 
98
  net = net_sfm
99
+ if Imagenet_model:
100
  net = net_imagenet
101
 
102
  # dataset_ = ImgDataset(images=[im1, im2], imsize=1024)
 
246
  description = "This is a visualization demo for the ICLR 2022 paper <b><a href='https://github.com/naver/fire' target='_blank'>Learning Super-Features for Image Retrieval</a></p></b>"
247
  article = "<p style='text-align: center'><a href='https://github.com/naver/fire' target='_blank'>Original Github Repo</a></p>"
248
 
 
 
 
 
 
 
 
 
249
  iface = gr.Interface(
250
  fn=generate_matching_superfeatures,
251
  inputs=[
 
253
  # gr.inputs.Image(shape=(1024, 1024), type="pil", label="Second Image"),
254
  gr.inputs.Image(type="pil", label="First Image"),
255
  gr.inputs.Image(type="pil", label="Second Image"),
256
+ gr.inputs.Checkbox(default=False, label="Model trained on ImageNet (Default: SfM-120k)"),
257
  gr.inputs.Slider(minimum=0, maximum=6, step=1, default=2, label="Scale"),
258
  gr.inputs.Slider(minimum=0, maximum=255, step=25, default=150, label="Binarization Threshold"),
259
+ gr.inputs.Checkbox(default=False, label="Show random (matching) SFs"),
260
+ gr.inputs.Textbox(lines=1, default="", label="...or show specific SF IDs:", optional=True),
261
  gr.inputs.Checkbox(default=True, label="Show only matching SFs"),
262
  ],
263
  outputs=[
 
270
  layout="horizontal",
271
  description=description,
272
  article=article,
 
273
  examples=[
274
+ ["chateau_1.png", "chateau_2.png", False, 3, 150, True, '', True],
275
+ ["anafi1.jpeg", "anafi2.jpeg", False, 4, 150, True, '', True],
276
+ ["areopoli1.jpeg", "areopoli2.jpeg", False, 4, 150, True, '', True],
277
  ]
278
  )
279
  iface.launch(enable_queue=True)