matrice-analytics 0.1.40__py3-none-any.whl → 0.1.41__py3-none-any.whl

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.

Potentially problematic release.


This version of matrice-analytics might be problematic. Click here for more details.

@@ -56,28 +56,77 @@ def try_install_clip_dependencies():
56
56
  Only called when ClipProcessor is actually instantiated (lazy installation).
57
57
  Returns True if successful, False otherwise.
58
58
  """
59
- global ort, Image, CLIPProcessor, ir_files, ir_as_file
60
-
61
59
  print("→ Color detection is being used but dependencies are missing")
62
60
  print("→ Attempting auto-installation of missing packages...")
63
61
 
62
+ import platform
63
+ import subprocess
64
+
65
+ # Detect platform
66
+ machine = platform.machine().lower()
67
+ is_jetson = machine in ['aarch64', 'arm64'] or os.path.exists('/etc/nv_tegra_release')
68
+
69
+ if is_jetson:
70
+ print(f"→ Detected Jetson/ARM platform ({machine})")
71
+ else:
72
+ print(f"→ Detected x86_64 platform ({machine})")
73
+
64
74
  packages_to_install = []
65
75
 
76
+ # Helper function to check if package is installed
77
+ def is_package_installed(package_name):
78
+ try:
79
+ result = subprocess.run(
80
+ [sys.executable, "-m", "pip", "show", package_name],
81
+ capture_output=True,
82
+ text=True,
83
+ timeout=10
84
+ )
85
+ return result.returncode == 0
86
+ except Exception:
87
+ return False
88
+
66
89
  # Check which packages are missing
67
90
  try:
68
91
  import onnxruntime
69
- except ImportError:
70
- packages_to_install.append("onnxruntime-gpu")
92
+ print("→ onnxruntime imported successfully")
93
+ except ImportError as e:
94
+ # Check if onnxruntime is installed but import is failing
95
+ if is_package_installed("onnxruntime"):
96
+ print(f"→ onnxruntime is installed but import failed: {e}")
97
+ print("→ This may be due to NumPy version mismatch or CUDA library issues")
98
+ print("→ Skipping installation, will check other dependencies")
99
+ elif is_jetson and is_package_installed("onnxruntime-gpu"):
100
+ print("→ onnxruntime-gpu found on Jetson (this may not work on ARM)")
101
+ print("→ Attempting import with installed version")
102
+ else:
103
+ # Choose appropriate onnxruntime package based on platform
104
+ if is_jetson:
105
+ print("→ onnxruntime not installed on Jetson platform")
106
+ print("→ Note: Jetson usually has onnxruntime pre-installed via JetPack")
107
+ print("→ If you see this, check your JetPack installation")
108
+ # Try installing anyway
109
+ packages_to_install.append("onnxruntime")
110
+ else:
111
+ packages_to_install.append("onnxruntime-gpu")
71
112
 
72
113
  try:
73
114
  from PIL import Image as PILImage
115
+ print("→ PIL/Pillow imported successfully")
74
116
  except ImportError:
75
- packages_to_install.append("pillow")
117
+ if not is_package_installed("pillow") and not is_package_installed("PIL"):
118
+ packages_to_install.append("pillow")
119
+ else:
120
+ print("→ pillow is installed but import failed")
76
121
 
77
122
  try:
78
123
  from transformers import CLIPProcessor as CLIP
124
+ print("→ transformers imported successfully")
79
125
  except ImportError:
80
- packages_to_install.append("transformers")
126
+ if not is_package_installed("transformers"):
127
+ packages_to_install.append("transformers")
128
+ else:
129
+ print("→ transformers is installed but import failed (may be incompatible with torch version)")
81
130
 
82
131
  if not packages_to_install:
83
132
  print("→ All packages are available, retrying import...")
@@ -103,30 +152,62 @@ def try_install_clip_dependencies():
103
152
  print(f"✗ Installation failed: {install_error}")
104
153
  return False
105
154
 
106
- # Retry imports after installation
155
+ # Retry imports after installation (or if packages were already installed)
156
+ print("→ Attempting to import dependencies...")
157
+
158
+ ort_module = None
159
+ PILImage = None
160
+ CLIPProc = None
161
+ ir_files_module = None
162
+ ir_as_file_module = None
163
+
164
+ import_errors = []
165
+
166
+ # Try importing each package individually
107
167
  try:
108
- print("→ Retrying imports after installation...")
109
168
  import onnxruntime as ort_module
169
+ print(" ✓ onnxruntime imported")
170
+ except Exception as e:
171
+ import_errors.append(f"onnxruntime: {e}")
172
+ print(f" ✗ onnxruntime import failed: {e}")
173
+
174
+ try:
110
175
  from PIL import Image as PILImage
111
- from transformers import CLIPProcessor as CLIPProc
112
- from importlib.resources import files as ir_files_module, as_file as ir_as_file_module
176
+ print(" ✓ PIL imported")
177
+ except Exception as e:
178
+ import_errors.append(f"PIL: {e}")
179
+ print(f" ✗ PIL import failed: {e}")
113
180
 
114
- # Update global variables
115
- ort = ort_module
116
- Image = PILImage
117
- CLIPProcessor = CLIPProc
118
- ir_files = ir_files_module
119
- ir_as_file = ir_as_file_module
181
+ try:
182
+ from transformers import CLIPProcessor as CLIPProc
183
+ print(" ✓ transformers imported")
184
+ except Exception as e:
185
+ import_errors.append(f"transformers: {e}")
186
+ print(f" ✗ transformers import failed: {e}")
120
187
 
121
- print("✓ CLIP dependencies imported successfully after installation!")
122
- return True
123
- except ImportError as e:
124
- print(f"✗ Import still failed after installation: {e}")
125
- return False
188
+ try:
189
+ from importlib.resources import files as ir_files_module, as_file as ir_as_file_module
190
+ print(" ✓ importlib.resources imported")
126
191
  except Exception as e:
127
- print(f"✗ Unexpected error: {e}")
192
+ import_errors.append(f"importlib.resources: {e}")
193
+ print(f" ✗ importlib.resources import failed: {e}")
194
+
195
+ # Check if we have at least the critical dependencies
196
+ if ort_module is None or PILImage is None or CLIPProc is None:
197
+ print(f"✗ Critical dependencies missing after installation attempt")
198
+ print(f" Errors: {'; '.join(import_errors)}")
128
199
  return False
129
200
 
201
+ # Update global variables with successfully imported modules
202
+ globals()['ort'] = ort_module
203
+ globals()['Image'] = PILImage
204
+ globals()['CLIPProcessor'] = CLIPProc
205
+ globals()['ir_files'] = ir_files_module
206
+ globals()['ir_as_file'] = ir_as_file_module
207
+
208
+ print("✓ CLIP dependencies imported successfully!")
209
+ return True
210
+
130
211
  def load_model_from_checkpoint(checkpoint_url: str, providers: Optional[List] = None):
131
212
  """
132
213
  Load an ONNX model from a URL directly into memory without writing locally.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: matrice_analytics
3
- Version: 0.1.40
3
+ Version: 0.1.41
4
4
  Summary: Common server utilities for Matrice.ai services
5
5
  Author-email: "Matrice.ai" <dipendra@matrice.ai>
6
6
  License-Expression: MIT
@@ -166,7 +166,7 @@ matrice_analytics/post_processing/usecases/weld_defect_detection.py,sha256=b0dAJ
166
166
  matrice_analytics/post_processing/usecases/wildlife_monitoring.py,sha256=TMVHJ5GLezmqG7DywmqbLggqNXgpsb63MD7IR6kvDkk,43446
167
167
  matrice_analytics/post_processing/usecases/windmill_maintenance.py,sha256=G1eqo3Z-HYmGJ6oeZYrpZwhpvqQ9Lc_T-6S7BLBXHeA,40498
168
168
  matrice_analytics/post_processing/usecases/wound_segmentation.py,sha256=ehNX6VuWMB3xAnCySO3ra3Tf_5FUNg5LCSdq_91h374,38342
169
- matrice_analytics/post_processing/usecases/color/clip.py,sha256=12ir0RkJCb4FJErn_e_9UbjtbBki5PMH2hWJLzyV75Q,21471
169
+ matrice_analytics/post_processing/usecases/color/clip.py,sha256=qtG1YUngpt-5Emx4vdX1Hv_X9U6Sa4BMCNRDYpuM_4g,24828
170
170
  matrice_analytics/post_processing/usecases/color/color_map_utils.py,sha256=SP-AEVcjLmL8rxblu-ixqUJC2fqlcr7ab4hWo4Fcr_k,2677
171
171
  matrice_analytics/post_processing/usecases/color/color_mapper.py,sha256=nKPc28mJLlrl2HPua5EUUMweRRSI6WrrUBkeitTm7ms,17459
172
172
  matrice_analytics/post_processing/usecases/color/clip_processor/merges.txt,sha256=n9aR98gDkhDg_O0VhlRmxlgg0JtjmIsBdL_iXeKZBRo,524619
@@ -188,8 +188,8 @@ matrice_analytics/post_processing/utils/format_utils.py,sha256=UTF7A5h9j0_S12xH9
188
188
  matrice_analytics/post_processing/utils/geometry_utils.py,sha256=BWfdM6RsdJTTLR1GqkWfdwpjMEjTCJyuBxA4zVGKdfk,9623
189
189
  matrice_analytics/post_processing/utils/smoothing_utils.py,sha256=78U-yucAcjUiZ0NIAc9NOUSIT0PWP1cqyIPA_Fdrjp0,14699
190
190
  matrice_analytics/post_processing/utils/tracking_utils.py,sha256=rWxuotnJ3VLMHIBOud2KLcu4yZfDp7hVPWUtNAq_2xw,8288
191
- matrice_analytics-0.1.40.dist-info/licenses/LICENSE.txt,sha256=_uQUZpgO0mRYL5-fPoEvLSbNnLPv6OmbeEDCHXhK6Qc,1066
192
- matrice_analytics-0.1.40.dist-info/METADATA,sha256=tROotN2KHqbTIpf18BknZQ8Z4zO8VHNMcf7f1q4svas,14378
193
- matrice_analytics-0.1.40.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
194
- matrice_analytics-0.1.40.dist-info/top_level.txt,sha256=STAPEU-e-rWTerXaspdi76T_eVRSrEfFpURSP7_Dt8E,18
195
- matrice_analytics-0.1.40.dist-info/RECORD,,
191
+ matrice_analytics-0.1.41.dist-info/licenses/LICENSE.txt,sha256=_uQUZpgO0mRYL5-fPoEvLSbNnLPv6OmbeEDCHXhK6Qc,1066
192
+ matrice_analytics-0.1.41.dist-info/METADATA,sha256=aGpFsA4ZZ5rNPFR2iqDy8JlA-gAhpAtjniELau5yH1I,14378
193
+ matrice_analytics-0.1.41.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
194
+ matrice_analytics-0.1.41.dist-info/top_level.txt,sha256=STAPEU-e-rWTerXaspdi76T_eVRSrEfFpURSP7_Dt8E,18
195
+ matrice_analytics-0.1.41.dist-info/RECORD,,