matrice 1.0.98850__py3-none-any.whl → 1.0.98852__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.
@@ -1,8 +1,9 @@
1
1
  """Module providing task_utils functionality."""
2
2
 
3
3
  import os
4
- import shlex
5
- import subprocess
4
+ import shutil
5
+ import urllib.request
6
+ import zipfile
6
7
  from matrice.utils import log_errors
7
8
 
8
9
 
@@ -30,24 +31,46 @@ def setup_workspace_and_run_task(
30
31
  if os.path.exists(workspace_dir):
31
32
  return
32
33
  os.makedirs(workspace_dir, exist_ok=True)
33
- download_codebase_cmd = (
34
- f"curl -L -o {shlex.quote(codebase_zip_path)} {shlex.quote(model_codebase_url)}"
35
- )
36
- subprocess.run(
37
- download_codebase_cmd,
38
- shell=True,
39
- check=True,
40
- )
41
- unzip_codebase_cmd = (
42
- f"unzip -o {shlex.quote(codebase_zip_path)} -d {shlex.quote(workspace_dir)}"
43
- )
44
- subprocess.run(unzip_codebase_cmd, shell=True, check=True)
45
- move_files_cmd = f"rsync -av {shlex.quote(workspace_dir)}/*/ {shlex.quote(workspace_dir)}/ "
46
- subprocess.run(move_files_cmd, shell=True, check=True)
34
+
35
+ # Download codebase ZIP file
36
+ urllib.request.urlretrieve(model_codebase_url, codebase_zip_path)
37
+
38
+ # Extract ZIP file with overwrite
39
+ with zipfile.ZipFile(codebase_zip_path, 'r') as zip_ref:
40
+ zip_ref.extractall(workspace_dir)
41
+
42
+ # Move files from subdirectories to workspace root (equivalent to rsync -av)
43
+ for root, dirs, files in os.walk(workspace_dir):
44
+ # Skip the workspace_dir itself to avoid moving files to themselves
45
+ if root == workspace_dir:
46
+ continue
47
+
48
+ for file in files:
49
+ src_file = os.path.join(root, file)
50
+ dst_file = os.path.join(workspace_dir, file)
51
+
52
+ # If destination file exists, overwrite it (equivalent to rsync -av behavior)
53
+ if os.path.exists(dst_file):
54
+ os.remove(dst_file)
55
+
56
+ shutil.move(src_file, dst_file)
57
+
58
+ # Remove empty directories after moving files
59
+ for dir_name in dirs:
60
+ dir_path = os.path.join(root, dir_name)
61
+ if os.path.exists(dir_path) and not os.listdir(dir_path):
62
+ os.rmdir(dir_path)
63
+
64
+ # Clean up any remaining empty subdirectories
65
+ for root, dirs, files in os.walk(workspace_dir, topdown=False):
66
+ if root == workspace_dir:
67
+ continue
68
+ if not files and not dirs:
69
+ try:
70
+ os.rmdir(root)
71
+ except OSError:
72
+ pass # Directory might not be empty or might not exist
73
+
74
+ # Download requirements.txt if URL is provided
47
75
  if model_codebase_requirements_url:
48
- download_requirements_cmd = f"curl -L -o {shlex.quote(requirements_txt_path)} {shlex.quote(model_codebase_requirements_url)}"
49
- subprocess.run(
50
- download_requirements_cmd,
51
- shell=True,
52
- check=True,
53
- )
76
+ urllib.request.urlretrieve(model_codebase_requirements_url, requirements_txt_path)
@@ -566,6 +566,8 @@ class VehicleMonitoringUseCase(BaseProcessor):
566
566
  total_vehicles = counting_summary.get("total_count", 0)
567
567
  total_vehicle_counts = counting_summary.get("total_vehicle_counts", {})
568
568
  cumulative_total = sum(total_vehicle_counts.values()) if total_vehicle_counts else 0
569
+ per_category_count = counting_summary.get("per_category_count", {})
570
+
569
571
 
570
572
  track_ids_info = self._get_track_ids_info(counting_summary.get("detections", []))
571
573
 
@@ -577,7 +579,14 @@ class VehicleMonitoringUseCase(BaseProcessor):
577
579
  # CURRENT FRAME section
578
580
  human_text_lines.append(f"CURRENT FRAME @ {current_timestamp}:")
579
581
  if total_vehicles > 0:
580
- human_text_lines.append(f"\t- Vehicles Detected: {total_vehicles}")
582
+ category_counts = [f"{count} {cat}" for cat, count in per_category_count.items()]
583
+ if len(category_counts) == 1:
584
+ vehicles_text = category_counts[0] + " detected"
585
+ elif len(category_counts) == 2:
586
+ vehicles_text = f"{category_counts[0]} and {category_counts[1]} detected"
587
+ else:
588
+ vehicles_text = f"{', '.join(category_counts[:-1])}, and {category_counts[-1]} detected"
589
+ human_text_lines.append(f"\t- {vehicles_text}")
581
590
  else:
582
591
  human_text_lines.append(f"\t- No vehicles detected")
583
592
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: matrice
3
- Version: 1.0.98850
3
+ Version: 1.0.98852
4
4
  Summary: SDK for connecting to matrice.ai services
5
5
  Home-page: https://github.com/matrice-ai/python-sdk
6
6
  Author: Matrice.ai
@@ -31,7 +31,7 @@ matrice/compute_manager/prechecks.py,sha256=sarrX0DIUWRfWvCowTANiMvSi2VPZ-5tCEdZ
31
31
  matrice/compute_manager/resources_tracker.py,sha256=84yzWYyLZmd2wENnKMk-mBUMAhE3CZ7oyZ3-5hnAwdI,16178
32
32
  matrice/compute_manager/scaling.py,sha256=95gt9KxYLtcOskSpdbC0ddbduSgZuDD6bGsJX-SVlwc,22976
33
33
  matrice/compute_manager/shutdown_manager.py,sha256=3m0DjItl1uSyTO7fvQb-IV8lapNX31Zul8FG0yCge0M,5245
34
- matrice/compute_manager/task_utils.py,sha256=gBmlD4Fw73mm6Z3keXMSk33joF_Kkf_6CucR1iyciME,1761
34
+ matrice/compute_manager/task_utils.py,sha256=hwT3_RyCu7RTH7T83NYNHBJ8XXkS8V3sUSb3oO0QNrU,2626
35
35
  matrice/data_processing/__init__.py,sha256=JqYtcyzrQGSXN2EmQBjS4rqwj0CKe0tg9x1Nd3UAAgQ,120
36
36
  matrice/data_processing/client.py,sha256=AtimRASg8nH3mxwwih1EHvvHNeXl9NvJhIJHjLjSxHY,55309
37
37
  matrice/data_processing/client_utils.py,sha256=q0bJg6bmlUTzy83RSuViCcpazHWgRgKgx77fqDqT2kQ,50121
@@ -123,7 +123,7 @@ matrice/deploy/utils/post_processing/usecases/flare_analysis.py,sha256=_pPKa16ax
123
123
  matrice/deploy/utils/post_processing/usecases/license_plate_detection.py,sha256=f38mdyAdW2Lopqy2XcT97HzI31_FcxTux-_tIdCm37g,26855
124
124
  matrice/deploy/utils/post_processing/usecases/people_counting.py,sha256=QSvq2zwFotp0o_T15EqFePAkukIyACleBZCf4fy7dHM,77973
125
125
  matrice/deploy/utils/post_processing/usecases/ppe_compliance.py,sha256=UhFFy7awb3vmBd4eOdFeO43um497J0Xt90Nl9v6reoQ,27599
126
- matrice/deploy/utils/post_processing/usecases/vehicle_monitoring.py,sha256=EkbZc1yYrb3rtloQQqZLNOTJsFPGPD8dyTG8J1M4ZNQ,39277
126
+ matrice/deploy/utils/post_processing/usecases/vehicle_monitoring.py,sha256=BD-7iz1TGS7Br1wmtBZoiL9YCW_qYGRn8xoh175RHJ4,39792
127
127
  matrice/deploy/utils/post_processing/utils/__init__.py,sha256=A49ksdXL7gRwBbIUwnU2ueFDGA67qVnEW_9lItOibtk,3626
128
128
  matrice/deploy/utils/post_processing/utils/advanced_counting_utils.py,sha256=D6jlZNRCfPtfG8COv3AMCbCfZf4_DK9rFhwzVJEYjpg,19152
129
129
  matrice/deploy/utils/post_processing/utils/advanced_helper_utils.py,sha256=W8mDqJTpg98YJgWYBod0rZUNbR4bmvYMeWAGASs14_s,11624
@@ -137,8 +137,8 @@ matrice/deploy/utils/post_processing/utils/format_utils.py,sha256=ce2VpQicTYKfxu
137
137
  matrice/deploy/utils/post_processing/utils/geometry_utils.py,sha256=BWfdM6RsdJTTLR1GqkWfdwpjMEjTCJyuBxA4zVGKdfk,9623
138
138
  matrice/deploy/utils/post_processing/utils/smoothing_utils.py,sha256=gQPykV1HGh-IMMz_3fumgtrhpyCRgXMS1hOEDcLRMO0,12542
139
139
  matrice/deploy/utils/post_processing/utils/tracking_utils.py,sha256=rWxuotnJ3VLMHIBOud2KLcu4yZfDp7hVPWUtNAq_2xw,8288
140
- matrice-1.0.98850.dist-info/licenses/LICENSE.txt,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
141
- matrice-1.0.98850.dist-info/METADATA,sha256=0DEEGtD_S91fmHYOV3wONYu3S94DMa7XHrBOpA4rwTk,14624
142
- matrice-1.0.98850.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
143
- matrice-1.0.98850.dist-info/top_level.txt,sha256=P97js8ur6o5ClRqMH3Cjoab_NqbJ6sOQ3rJmVzKBvMc,8
144
- matrice-1.0.98850.dist-info/RECORD,,
140
+ matrice-1.0.98852.dist-info/licenses/LICENSE.txt,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
141
+ matrice-1.0.98852.dist-info/METADATA,sha256=6LpPKRORYoxIvokieEh3qlx_v_1BaFKjXM7WuTZmD0Q,14624
142
+ matrice-1.0.98852.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
143
+ matrice-1.0.98852.dist-info/top_level.txt,sha256=P97js8ur6o5ClRqMH3Cjoab_NqbJ6sOQ3rJmVzKBvMc,8
144
+ matrice-1.0.98852.dist-info/RECORD,,