huzey commited on
Commit
55dc840
1 Parent(s): 43c4f02

update parameters

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -464,9 +464,10 @@ def image_clip_feature(
464
  return outputs
465
 
466
 
467
-
468
  def extract_features(images, model_name="sam", node_type="block", layer=-1):
469
  if model_name == "SAM(sam_vit_b)":
 
 
470
  return image_sam_feature(images, node_type=node_type, layer=layer)
471
  elif model_name == 'MobileSAM':
472
  return image_mobilesam_feature(images, node_type=node_type, layer=layer)
@@ -583,15 +584,15 @@ demo = gr.Interface(
583
  gr.Dropdown(["attn", "mlp", "block"], label="Node type", value="block", elem_id="node_type", info="attn: attention output, mlp: mlp output, block: sum of residual stream"),
584
  gr.Slider(0, 11, step=1, label="Layer", value=11, elem_id="layer", info="which layer of the image backbone features"),
585
  gr.Slider(1, 1000, step=1, label="Number of eigenvectors", value=100, elem_id="num_eig", info='increase for more object parts, decrease for whole object'),
586
- gr.Slider(0.01, 1, step=0.01, label="Affinity focal gamma", value=0.3, elem_id="affinity_focal_gamma", info="decrease for more aggressive cleaning on the affinity matrix"),
587
  ],
588
  gr.Gallery(value=default_outputs, label="NCUT Embedding", show_label=False, elem_id="ncut", columns=[3], rows=[1], object_fit="contain", height="auto"),
589
  additional_inputs=[
590
- gr.Slider(100, 30000, step=100, label="num_sample (NCUT)", value=10000, elem_id="num_sample_ncut", info="for Nyström approximation"),
591
  gr.Slider(1, 100, step=1, label="KNN (NCUT)", value=10, elem_id="knn_ncut", info="for Nyström approximation"),
592
- gr.Slider(100, 10000, step=100, label="num_sample (t-SNE)", value=1000, elem_id="num_sample_tsne", info="for Nyström approximation. Adding will slow down t-SNE quite a lot"),
593
  gr.Slider(1, 100, step=1, label="KNN (t-SNE)", value=10, elem_id="knn_tsne", info="for Nyström approximation"),
594
- gr.Slider(10, 1000, step=10, label="Perplexity (t-SNE)", value=500, elem_id="perplexity", info="for t-SNE"),
595
 
596
  ]
597
  )
 
464
  return outputs
465
 
466
 
 
467
  def extract_features(images, model_name="sam", node_type="block", layer=-1):
468
  if model_name == "SAM(sam_vit_b)":
469
+ if not use_cuda:
470
+ gr.warning("GPU not detected. Running SAM on CPU, ~30s/image.")
471
  return image_sam_feature(images, node_type=node_type, layer=layer)
472
  elif model_name == 'MobileSAM':
473
  return image_mobilesam_feature(images, node_type=node_type, layer=layer)
 
584
  gr.Dropdown(["attn", "mlp", "block"], label="Node type", value="block", elem_id="node_type", info="attn: attention output, mlp: mlp output, block: sum of residual stream"),
585
  gr.Slider(0, 11, step=1, label="Layer", value=11, elem_id="layer", info="which layer of the image backbone features"),
586
  gr.Slider(1, 1000, step=1, label="Number of eigenvectors", value=100, elem_id="num_eig", info='increase for more object parts, decrease for whole object'),
587
+ gr.Slider(0.01, 1, step=0.01, label="Affinity focal gamma", value=0.5, elem_id="affinity_focal_gamma", info="decrease for more aggressive cleaning on the affinity matrix"),
588
  ],
589
  gr.Gallery(value=default_outputs, label="NCUT Embedding", show_label=False, elem_id="ncut", columns=[3], rows=[1], object_fit="contain", height="auto"),
590
  additional_inputs=[
591
+ gr.Slider(100, 10000, step=100, label="num_sample (NCUT)", value=5000, elem_id="num_sample_ncut", info="for Nyström approximation"),
592
  gr.Slider(1, 100, step=1, label="KNN (NCUT)", value=10, elem_id="knn_ncut", info="for Nyström approximation"),
593
+ gr.Slider(100, 1000, step=100, label="num_sample (t-SNE)", value=500, elem_id="num_sample_tsne", info="for Nyström approximation. Adding will slow down t-SNE quite a lot"),
594
  gr.Slider(1, 100, step=1, label="KNN (t-SNE)", value=10, elem_id="knn_tsne", info="for Nyström approximation"),
595
+ gr.Slider(10, 500, step=10, label="Perplexity (t-SNE)", value=250, elem_id="perplexity", info="for t-SNE"),
596
 
597
  ]
598
  )