neuro-sam 0.1.5__tar.gz → 0.1.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. {neuro_sam-0.1.5/src/neuro_sam.egg-info → neuro_sam-0.1.7}/PKG-INFO +2 -1
  2. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/pyproject.toml +4 -2
  3. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/napari_utils/punet_widget.py +5 -11
  4. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/napari_utils/segmentation_model.py +16 -7
  5. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/napari_utils/segmentation_module.py +1 -4
  6. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/plugin.py +5 -3
  7. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/punet/punet_inference.py +1 -1
  8. neuro_sam-0.1.7/src/neuro_sam/utils.py +90 -0
  9. {neuro_sam-0.1.5 → neuro_sam-0.1.7/src/neuro_sam.egg-info}/PKG-INFO +2 -1
  10. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam.egg-info/SOURCES.txt +1 -0
  11. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam.egg-info/entry_points.txt +1 -0
  12. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam.egg-info/requires.txt +1 -0
  13. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/LICENSE +0 -0
  14. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/README.md +0 -0
  15. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/setup.cfg +0 -0
  16. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/__init__.py +0 -0
  17. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/brightest_path_lib/__init__.py +0 -0
  18. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/brightest_path_lib/algorithm/__init__.py +0 -0
  19. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/brightest_path_lib/algorithm/astar.py +0 -0
  20. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/brightest_path_lib/algorithm/waypointastar.py +0 -0
  21. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/brightest_path_lib/algorithm/waypointastar_speedup.py +0 -0
  22. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/brightest_path_lib/connected_componen.py +0 -0
  23. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/brightest_path_lib/cost/__init__.py +0 -0
  24. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/brightest_path_lib/cost/cost.py +0 -0
  25. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/brightest_path_lib/cost/reciprocal.py +0 -0
  26. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/brightest_path_lib/cost/reciprocal_transonic.py +0 -0
  27. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/brightest_path_lib/heuristic/__init__.py +0 -0
  28. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/brightest_path_lib/heuristic/euclidean.py +0 -0
  29. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/brightest_path_lib/heuristic/heuristic.py +0 -0
  30. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/brightest_path_lib/image/__init__.py +0 -0
  31. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/brightest_path_lib/image/stats.py +0 -0
  32. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/brightest_path_lib/input/__init__.py +0 -0
  33. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/brightest_path_lib/input/inputs.py +0 -0
  34. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/brightest_path_lib/node/__init__.py +0 -0
  35. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/brightest_path_lib/node/bidirectional_node.py +0 -0
  36. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/brightest_path_lib/node/node.py +0 -0
  37. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/brightest_path_lib/visualization/__init__.py +0 -0
  38. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/brightest_path_lib/visualization/flythrough.py +0 -0
  39. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/brightest_path_lib/visualization/flythrough_all.py +0 -0
  40. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/brightest_path_lib/visualization/tube_data.py +0 -0
  41. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/brightest_path_lib/visualization/tube_flythrough.py +0 -0
  42. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/napari_utils/anisotropic_scaling.py +0 -0
  43. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/napari_utils/color_utils.py +0 -0
  44. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/napari_utils/contrasting_color_system.py +0 -0
  45. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/napari_utils/main_widget.py +0 -0
  46. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/napari_utils/path_tracing_module.py +0 -0
  47. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/napari_utils/visualization_module.py +0 -0
  48. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/punet/__init__.py +0 -0
  49. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/punet/deepd3_model.py +0 -0
  50. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/punet/prob_unet_deepd3.py +0 -0
  51. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/punet/prob_unet_with_tversky.py +0 -0
  52. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/punet/run_inference.py +0 -0
  53. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/punet/unet_blocks.py +0 -0
  54. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam/punet/utils.py +0 -0
  55. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam.egg-info/dependency_links.txt +0 -0
  56. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/neuro_sam.egg-info/top_level.txt +0 -0
  57. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/__init__.py +0 -0
  58. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/automatic_mask_generator.py +0 -0
  59. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/benchmark.py +0 -0
  60. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/build_sam.py +0 -0
  61. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/configs/sam2/sam2_hiera_b+.yaml +0 -0
  62. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/configs/sam2/sam2_hiera_l.yaml +0 -0
  63. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/configs/sam2/sam2_hiera_s.yaml +0 -0
  64. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/configs/sam2/sam2_hiera_t.yaml +0 -0
  65. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/configs/sam2.1/sam2.1_hiera_b+.yaml +0 -0
  66. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/configs/sam2.1/sam2.1_hiera_l.yaml +0 -0
  67. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/configs/sam2.1/sam2.1_hiera_s.yaml +0 -0
  68. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/configs/sam2.1/sam2.1_hiera_t.yaml +0 -0
  69. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/configs/sam2.1_training/sam2.1_hiera_b+_MOSE_finetune.yaml +0 -0
  70. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/configs/train.yaml +0 -0
  71. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/modeling/__init__.py +0 -0
  72. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/modeling/backbones/__init__.py +0 -0
  73. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/modeling/backbones/hieradet.py +0 -0
  74. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/modeling/backbones/image_encoder.py +0 -0
  75. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/modeling/backbones/utils.py +0 -0
  76. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/modeling/memory_attention.py +0 -0
  77. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/modeling/memory_encoder.py +0 -0
  78. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/modeling/position_encoding.py +0 -0
  79. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/modeling/sam/__init__.py +0 -0
  80. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/modeling/sam/mask_decoder.py +0 -0
  81. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/modeling/sam/prompt_encoder.py +0 -0
  82. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/modeling/sam/transformer.py +0 -0
  83. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/modeling/sam2_base.py +0 -0
  84. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/modeling/sam2_utils.py +0 -0
  85. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/sam2.1_hiera_b+.yaml +0 -0
  86. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/sam2.1_hiera_l.yaml +0 -0
  87. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/sam2.1_hiera_s.yaml +0 -0
  88. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/sam2.1_hiera_t.yaml +0 -0
  89. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/sam2_hiera_b+.yaml +0 -0
  90. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/sam2_hiera_l.yaml +0 -0
  91. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/sam2_hiera_s.yaml +0 -0
  92. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/sam2_hiera_t.yaml +0 -0
  93. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/sam2_image_predictor.py +0 -0
  94. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/sam2_video_predictor.py +0 -0
  95. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/sam2_video_predictor_legacy.py +0 -0
  96. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/utils/__init__.py +0 -0
  97. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/utils/amg.py +0 -0
  98. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/utils/misc.py +0 -0
  99. {neuro_sam-0.1.5 → neuro_sam-0.1.7}/src/sam2/utils/transforms.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: neuro-sam
3
- Version: 0.1.5
3
+ Version: 0.1.7
4
4
  Summary: Neuro-SAM: Foundation Models for Dendrite and Dendritic Spine Segmentation
5
5
  Author-email: Nipun Arora <nipunarora8@yahoo.com>
6
6
  License: MIT License
@@ -54,6 +54,7 @@ Requires-Dist: numba
54
54
  Requires-Dist: PyQt5
55
55
  Requires-Dist: opencv-python-headless
56
56
  Requires-Dist: matplotlib
57
+ Requires-Dist: requests
57
58
  Dynamic: license-file
58
59
 
59
60
  <div align="center">
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "neuro-sam"
7
- version = "0.1.5"
7
+ version = "0.1.7"
8
8
  description = "Neuro-SAM: Foundation Models for Dendrite and Dendritic Spine Segmentation"
9
9
  readme = "README.md"
10
10
  authors = [
@@ -37,7 +37,8 @@ dependencies = [
37
37
  "numba",
38
38
  "PyQt5",
39
39
  "opencv-python-headless",
40
- "matplotlib"
40
+ "matplotlib",
41
+ "requests"
41
42
  ]
42
43
  requires-python = ">=3.10"
43
44
 
@@ -55,6 +56,7 @@ include = ["neuro_sam*", "sam2*"]
55
56
 
56
57
  [project.scripts]
57
58
  neuro-sam = "neuro_sam.plugin:main"
59
+ neuro-sam-download = "neuro_sam.utils:download_all_models"
58
60
 
59
61
  [project.entry-points."napari.manifest"]
60
62
  neuro-sam = "neuro_sam:napari.yaml"
@@ -15,14 +15,8 @@ import napari
15
15
  from napari.qt.threading import thread_worker
16
16
 
17
17
  # Import the model class
18
- # Assuming running from root, so punet is a package
19
- try:
20
- from neuro_sam.punet.punet_inference import run_inference_volume
21
- except ImportError:
22
- # Fallback if running from a different context, try to append path
23
- import sys
24
- sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'punet'))
25
- from neuro_sam.punet.punet_inference import run_inference_volume
18
+ # Assumes installed package structure
19
+ from neuro_sam.punet.punet_inference import run_inference_volume
26
20
 
27
21
 
28
22
 
@@ -197,13 +191,13 @@ class PunetSpineSegmentationWidget(QWidget):
197
191
  def _segmentation_worker(self, vol, params):
198
192
  import traceback
199
193
  try:
194
+ # Import the refactored inference function from the package
200
195
  # Import the refactored inference function from the package
201
196
  try:
202
197
  from neuro_sam.punet.punet_inference import run_inference_volume
203
198
  except ImportError:
204
- import sys
205
- sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'punet'))
206
- from neuro_sam.punet_inference import run_inference_volume
199
+ # Fallback should not be needed with proper package execution
200
+ raise ImportError("Could not import run_inference_volume from neuro_sam.punet.punet_inference")
207
201
 
208
202
  yield "Starting inference..."
209
203
 
@@ -8,22 +8,33 @@ from scipy.ndimage import label
8
8
  from matplotlib.path import Path
9
9
 
10
10
 
11
+ from neuro_sam.utils import get_weights_path
12
+
11
13
  class DendriteSegmenter:
12
14
  """Class for segmenting dendrites from 3D image volumes using SAM2 with overlapping patches"""
13
15
 
14
- def __init__(self, model_path="./Train-SAMv2/checkpoints/sam2.1_hiera_small.pt", config_path="sam2.1_hiera_s.yaml", weights_path="./Train-SAMv2/results/samv2_dendrite/dendrite_model.torch", device="cuda"):
16
+ def __init__(self, model_path=None, config_path="sam2.1_hiera_s.yaml", weights_path=None, device="cuda"):
15
17
  """
16
18
  Initialize the dendrite segmenter with overlapping patches.
17
19
 
18
20
  Args:
19
- model_path: Path to SAM2 model checkpoint
21
+ model_path: Path to SAM2 model checkpoint (auto-downloaded if None)
20
22
  config_path: Path to model configuration
21
- weights_path: Path to trained weights
23
+ weights_path: Path to trained weights (auto-downloaded if None)
22
24
  device: Device to run the model on (cpu or cuda)
23
25
  """
24
- self.model_path = model_path
26
+ if model_path is None:
27
+ self.model_path = get_weights_path("sam2.1_hiera_small.pt")
28
+ else:
29
+ self.model_path = model_path
30
+
25
31
  self.config_path = config_path
26
- self.weights_path = weights_path
32
+
33
+ if weights_path is None:
34
+ self.weights_path = get_weights_path("dendrite_model.torch")
35
+ else:
36
+ self.weights_path = weights_path
37
+
27
38
  self.device = device
28
39
  self.predictor = None
29
40
 
@@ -35,8 +46,6 @@ class DendriteSegmenter:
35
46
 
36
47
  # Try importing first to catch import errors
37
48
  try:
38
- import sys
39
- sys.path.append('./Train-SAMv2')
40
49
  from sam2.build_sam import build_sam2
41
50
  from sam2.sam2_image_predictor import SAM2ImagePredictor
42
51
  print("Successfully imported SAM2 modules")
@@ -349,11 +349,8 @@ class SegmentationWidget(QWidget):
349
349
  # Initialize segmenter if not already done
350
350
  if self.segmenter is None:
351
351
  self.segmenter = DendriteSegmenter(
352
- model_path="./Train-SAMv2/checkpoints/sam2.1_hiera_small.pt",
353
- config_path="sam2.1_hiera_s.yaml",
354
- weights_path="./Train-SAMv2/results/samv2_dendrite/dendrite_model.torch",
355
352
  device=device
356
- )
353
+ ) # Paths are now handled automatically by default args
357
354
 
358
355
  # Load the model
359
356
  success = self.segmenter.load_model()
@@ -247,11 +247,13 @@ def main():
247
247
  else:
248
248
  # Try to load a default benchmark image
249
249
  try:
250
- default_path = './DeepD3_Benchmark.tif'
251
- print(f"No image path provided, trying to load default: {default_path}")
250
+ from neuro_sam.utils import get_weights_path
251
+ default_path = get_weights_path('DeepD3_Benchmark.tif')
252
+ print(f"No image path provided, loading default: {default_path}")
252
253
  spacing_xyz = (args.x_spacing, args.y_spacing, args.z_spacing)
253
254
  viewer = run_neuro_sam(image_path=default_path, spacing_xyz=spacing_xyz)
254
- except FileNotFoundError:
255
+ except Exception as e:
256
+ print(f"Failed to load default image: {e}")
255
257
  sys.exit(1)
256
258
 
257
259
  print("\nStarted NeuroSAM with anisotropic scaling support!")
@@ -7,7 +7,7 @@ import torch
7
7
  import tifffile as tiff
8
8
  from tqdm import tqdm
9
9
 
10
- from prob_unet_with_tversky import ProbabilisticUnetDualLatent
10
+ from .prob_unet_with_tversky import ProbabilisticUnetDualLatent
11
11
 
12
12
 
13
13
  def pad_to_multiple(img: np.ndarray, multiple: int = 32):
@@ -0,0 +1,90 @@
1
+ import os
2
+ import sys
3
+ import requests
4
+ from pathlib import Path
5
+ from tqdm import tqdm
6
+
7
+ # Constants for Model URLs
8
+ WEIGHTS_URLS = {
9
+ "DeepD3_Benchmark.tif": "https://github.com/nipunarora8/Neuro-SAM/releases/download/weights/DeepD3_Benchmark.tif",
10
+ "dendrite_model.torch": "https://github.com/nipunarora8/Neuro-SAM/releases/download/weights/dendrite_model.torch",
11
+ "sam2.1_hiera_small.pt": "https://github.com/nipunarora8/Neuro-SAM/releases/download/weights/sam2.1_hiera_small.pt",
12
+ "punet_best.pth": "https://github.com/nipunarora8/Neuro-SAM/releases/download/weights/punet_best.pth"
13
+ }
14
+
15
+ def get_weights_dir():
16
+ """Get the directory where weights are stored (~/.neuro_sam/checkpoints)."""
17
+ weights_dir = Path.home() / ".neuro_sam" / "checkpoints"
18
+ weights_dir.mkdir(parents=True, exist_ok=True)
19
+ return weights_dir
20
+
21
+ def download_file(url, dest_path):
22
+ """Download a file from a URL to a destination path with a progress bar."""
23
+ print(f"Downloading {url} to {dest_path}...")
24
+ try:
25
+ response = requests.get(url, stream=True)
26
+ response.raise_for_status()
27
+ total_size = int(response.headers.get('content-length', 0))
28
+
29
+ block_size = 1024 # 1 Kibibyte
30
+ t = tqdm(total=total_size, unit='iB', unit_scale=True)
31
+
32
+ with open(dest_path, 'wb') as file:
33
+ for data in response.iter_content(block_size):
34
+ t.update(len(data))
35
+ file.write(data)
36
+ t.close()
37
+
38
+ if total_size != 0 and t.n != total_size:
39
+ print("ERROR, something went wrong with the download")
40
+ return False
41
+
42
+ print(f"Download complete: {dest_path}")
43
+ return True
44
+ except Exception as e:
45
+ print(f"Error downloading file: {e}")
46
+ if os.path.exists(dest_path):
47
+ os.remove(dest_path)
48
+ return False
49
+
50
+ def get_weights_path(filename, url=None):
51
+ """
52
+ Get the path to a weights file.
53
+ Checks local 'checkpoints' folder first, then ~/.neuro_sam/checkpoints.
54
+ If not found, downloads it.
55
+ """
56
+ # 1. Check local checkpoints folder (development mode)
57
+ local_path = Path("checkpoints") / filename
58
+ if local_path.exists():
59
+ return str(local_path.absolute())
60
+
61
+ # 2. Check global cache directory
62
+ weights_dir = get_weights_dir()
63
+ cache_path = weights_dir / filename
64
+
65
+ if cache_path.exists():
66
+ return str(cache_path.absolute())
67
+
68
+ # 3. Download if not found
69
+ if url is None:
70
+ url = WEIGHTS_URLS.get(filename)
71
+
72
+ if url:
73
+ print(f"Weights file {filename} not found locally. Downloading...")
74
+ success = download_file(url, cache_path)
75
+ if success:
76
+ return str(cache_path.absolute())
77
+ else:
78
+ raise RuntimeError(f"Failed to download {filename}")
79
+ else:
80
+ raise FileNotFoundError(f"Weights file {filename} not found and no URL provided.")
81
+
82
+ def download_all_models():
83
+ """Download all known models to the cache directory."""
84
+ print("Downloading all Neuro-SAM models...")
85
+ for filename, url in WEIGHTS_URLS.items():
86
+ try:
87
+ get_weights_path(filename, url)
88
+ except Exception as e:
89
+ print(f"Failed to process {filename}: {e}")
90
+ print("All downloads processed.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: neuro-sam
3
- Version: 0.1.5
3
+ Version: 0.1.7
4
4
  Summary: Neuro-SAM: Foundation Models for Dendrite and Dendritic Spine Segmentation
5
5
  Author-email: Nipun Arora <nipunarora8@yahoo.com>
6
6
  License: MIT License
@@ -54,6 +54,7 @@ Requires-Dist: numba
54
54
  Requires-Dist: PyQt5
55
55
  Requires-Dist: opencv-python-headless
56
56
  Requires-Dist: matplotlib
57
+ Requires-Dist: requests
57
58
  Dynamic: license-file
58
59
 
59
60
  <div align="center">
@@ -3,6 +3,7 @@ README.md
3
3
  pyproject.toml
4
4
  src/neuro_sam/__init__.py
5
5
  src/neuro_sam/plugin.py
6
+ src/neuro_sam/utils.py
6
7
  src/neuro_sam.egg-info/PKG-INFO
7
8
  src/neuro_sam.egg-info/SOURCES.txt
8
9
  src/neuro_sam.egg-info/dependency_links.txt
@@ -1,5 +1,6 @@
1
1
  [console_scripts]
2
2
  neuro-sam = neuro_sam.plugin:main
3
+ neuro-sam-download = neuro_sam.utils:download_all_models
3
4
 
4
5
  [napari.manifest]
5
6
  neuro-sam = neuro_sam:napari.yaml
@@ -18,3 +18,4 @@ numba
18
18
  PyQt5
19
19
  opencv-python-headless
20
20
  matplotlib
21
+ requests
File without changes
File without changes
File without changes