huzey commited on
Commit
e9af887
1 Parent(s): b583aba

add models

Browse files
Files changed (2) hide show
  1. app.py +6 -3
  2. requirements.txt +1 -1
app.py CHANGED
@@ -204,6 +204,8 @@ def ncut_run(
204
  video_output=False,
205
  ):
206
  logging_str = ""
 
 
207
  if perplexity >= num_sample_tsne or n_neighbors >= num_sample_tsne:
208
  # raise gr.Error("Perplexity must be less than the number of samples for t-SNE.")
209
  gr.Warning("Perplexity/n_neighbors must be less than the number of samples.\n" f"Setting Perplexity to {num_sample_tsne-1}.")
@@ -585,9 +587,10 @@ def make_output_images_section():
585
 
586
  def make_parameters_section():
587
  gr.Markdown("### Parameters <a style='color: #0044CC;' href='https://ncut-pytorch.readthedocs.io/en/latest/how_to_get_better_segmentation/' target='_blank'>Help</a>")
588
- from ncut_pytorch.backbone import get_demo_model_names
589
- model_names = get_demo_model_names()
590
- model_dropdown = gr.Dropdown(model_names, label="Backbone", value="DiNO(dino_vitb8)", elem_id="model_name")
 
591
  layer_slider = gr.Slider(1, 12, step=1, label="Backbone: Layer index", value=10, elem_id="layer")
592
  node_type_dropdown = gr.Dropdown(["attn: attention output", "mlp: mlp output", "block: sum of residual"], label="Backbone: Layer type", value="block: sum of residual", elem_id="node_type", info="which feature to take from each layer?")
593
  num_eig_slider = gr.Slider(1, 1000, step=1, label="NCUT: Number of eigenvectors", value=100, elem_id="num_eig", info='increase for more clusters')
 
204
  video_output=False,
205
  ):
206
  logging_str = ""
207
+ resolution = RES_DICT[model_name]
208
+ logging_str += f"Resolution: {resolution}\n"
209
  if perplexity >= num_sample_tsne or n_neighbors >= num_sample_tsne:
210
  # raise gr.Error("Perplexity must be less than the number of samples for t-SNE.")
211
  gr.Warning("Perplexity/n_neighbors must be less than the number of samples.\n" f"Setting Perplexity to {num_sample_tsne-1}.")
 
587
 
588
  def make_parameters_section():
589
  gr.Markdown("### Parameters <a style='color: #0044CC;' href='https://ncut-pytorch.readthedocs.io/en/latest/how_to_get_better_segmentation/' target='_blank'>Help</a>")
590
+ from ncut_pytorch.backbone import list_models, get_demo_model_names
591
+ model_names = list_models()
592
+ model_names = sorted(model_names)
593
+ model_dropdown = gr.Dropdown(model_names, label="Backbone", value="DiNO(dino_vitb8_448)", elem_id="model_name")
594
  layer_slider = gr.Slider(1, 12, step=1, label="Backbone: Layer index", value=10, elem_id="layer")
595
  node_type_dropdown = gr.Dropdown(["attn: attention output", "mlp: mlp output", "block: sum of residual"], label="Backbone: Layer type", value="block: sum of residual", elem_id="node_type", info="which feature to take from each layer?")
596
  num_eig_slider = gr.Slider(1, 1000, step=1, label="NCUT: Number of eigenvectors", value=100, elem_id="num_eig", info='increase for more clusters')
requirements.txt CHANGED
@@ -1,6 +1,6 @@
1
  torch
2
  torchvision
3
- ncut-pytorch>=1.2.0
4
  opencv-python
5
  decord
6
  transformers
 
1
  torch
2
  torchvision
3
+ ncut-pytorch>=1.2.6
4
  opencv-python
5
  decord
6
  transformers