-
Notifications
You must be signed in to change notification settings - Fork 36
ITEP-90240: Reid vector length is configurable #1301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ | |
| import time | ||
| from unittest import result | ||
|
|
||
| from controller.vdms_adapter import VDMSDatabase | ||
| from controller.vdms_adapter import VDMSDatabase, DIMENSIONS | ||
| from scene_common import log | ||
| from scene_common.timestamp import get_epoch_time | ||
|
|
||
|
|
@@ -35,15 +35,17 @@ def __init__(self, database=DEFAULT_DATABASE, reid_config_data=None): | |
| self.features_for_database_timestamps = {} # Track when features were added | ||
| self.quality_features = {} | ||
| self.unique_id_count = 0 | ||
| self.reid_database = available_databases[database]() | ||
| # Extract vector dimensions from reid config, pass to database | ||
| if reid_config_data is None: | ||
| reid_config_data = {} | ||
| vector_dimensions = reid_config_data.get('vector_dimensions', DIMENSIONS) | ||
| self.reid_database = available_databases[database](dimensions=vector_dimensions) | ||
| self.pool = concurrent.futures.ThreadPoolExecutor() | ||
|
Comment on lines
+38
to
43
|
||
| self.similarity_query_times = collections.deque( | ||
| maxlen=DEFAULT_MAX_SIMILARITY_QUERIES_TRACKED) | ||
| self.similarity_query_times_lock = threading.Lock() | ||
| self.reid_enabled = True | ||
| # Extract stale feature timeout from reid config, use default if not provided | ||
| if reid_config_data is None: | ||
| reid_config_data = {} | ||
| self.stale_feature_timeout_secs = reid_config_data.get('stale_feature_timeout_secs', DEFAULT_STALE_FEATURE_TIMEOUT_SECS) | ||
| self.stale_feature_check_interval_secs = reid_config_data.get('stale_feature_check_interval_secs', DEFAULT_STALE_FEATURE_CHECK_INTERVAL_SECS) | ||
| self.stale_feature_timer = None | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -145,10 +145,10 @@ def addEntry(self, uuid, rvid, object_type, reid_vectors, set_name=SCHEMA_NAME, | |
| add_query = [] | ||
| for reid_vector in reid_vectors: | ||
| # Ensure vector is properly formatted as 1D array of float32 | ||
| # reid_vector might be shape (1, 256) from moving_object, need to flatten to (256,) | ||
| # reid_vector might be shape (N,) from moving_object, need to flatten to (N,) | ||
| vec_array = np.asarray(reid_vector, dtype="float32").flatten() | ||
| if vec_array.shape[0] != 256: | ||
| log.warning(f"addEntry: Expected vector shape (256,) but got {vec_array.shape}, skipping this vector") | ||
| if vec_array.shape[0] != self.dimensions: | ||
| log.warning(f"addEntry: Expected vector shape ({self.dimensions},) but got {vec_array.shape}, skipping this vector") | ||
| continue | ||
|
Comment on lines
146
to
152
|
||
| descriptor_blobs.append(vec_array.tobytes()) | ||
| # Create query dict for each vector | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,7 +37,18 @@ def reidPolicy(pobj, item, fw, fh): | |
| name = tensor.get('name','') | ||
| if name and ('reid' in name or 'embedding' in name): | ||
| reid_vector = tensor.get('data', []) | ||
| v = struct.pack("256f",*reid_vector) | ||
| # Handle variable-length re-id vectors from different models | ||
| if not reid_vector: | ||
| continue | ||
| vector_len = len(reid_vector) | ||
| # Pack vector with its actual dimensions | ||
| format_string = f"{vector_len}f" | ||
| try: | ||
| v = struct.pack(format_string, *reid_vector) | ||
|
Comment on lines
+40
to
+47
|
||
| except struct.error as e: | ||
| import sys | ||
| print(f"Failed to pack reid vector of length {vector_len}: {e}", file=sys.stderr) | ||
| continue | ||
| # Move reid under metadata key | ||
| if 'metadata' not in pobj: | ||
| pobj['metadata'] = {} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A new
vector_dimensionsoption is added toreid-config.json, but the controller documentation that describes this config file (e.g.docs/user-guide/microservices/controller/Extended-ReID.md) does not mention this setting yet. Please document what this value controls (VDMS schema dimensions + expected embedding length) and any compatibility constraints with the embedding producer/decoder.