fix: model calling method
All checks were successful
Build Worker Base and Application Images / check-base-changes (push) Successful in 8s
Build Worker Base and Application Images / build-base (push) Has been skipped
Build Worker Base and Application Images / build-docker (push) Successful in 2m44s
Build Worker Base and Application Images / deploy-stack (push) Successful in 9s
All checks were successful
Build Worker Base and Application Images / check-base-changes (push) Successful in 8s
Build Worker Base and Application Images / build-base (push) Has been skipped
Build Worker Base and Application Images / build-docker (push) Successful in 2m44s
Build Worker Base and Application Images / deploy-stack (push) Successful in 9s
This commit is contained in:
parent
5bb68b6e10
commit
2e5316ca01
3 changed files with 82 additions and 33 deletions
|
@ -438,11 +438,22 @@ class BranchProcessor:
|
|||
f"({input_frame.shape[1]}x{input_frame.shape[0]}) with confidence={min_confidence}")
|
||||
|
||||
|
||||
# Use .predict() method for both detection and classification models
|
||||
# Determine model type and use appropriate calling method (like ML engineer's approach)
|
||||
inference_start = time.time()
|
||||
detection_results = model.model.predict(input_frame, conf=min_confidence, verbose=False)
|
||||
|
||||
# Check if this is a classification model based on filename or model structure
|
||||
is_classification = 'cls' in branch_id.lower() or 'classify' in branch_id.lower()
|
||||
|
||||
if is_classification:
|
||||
# Use .predict() method for classification models (like ML engineer's classification_test.py)
|
||||
detection_results = model.model.predict(source=input_frame, verbose=False)
|
||||
logger.info(f"[INFERENCE DONE] {branch_id}: Classification completed in {time.time() - inference_start:.3f}s using .predict()")
|
||||
else:
|
||||
# Use direct model call for detection models (like ML engineer's detection_test.py)
|
||||
detection_results = model.model(input_frame, conf=min_confidence, verbose=False)
|
||||
logger.info(f"[INFERENCE DONE] {branch_id}: Detection completed in {time.time() - inference_start:.3f}s using direct call")
|
||||
|
||||
inference_time = time.time() - inference_start
|
||||
logger.info(f"[INFERENCE DONE] {branch_id}: Predict completed in {inference_time:.3f}s using .predict() method")
|
||||
|
||||
# Initialize branch_detections outside the conditional
|
||||
branch_detections = []
|
||||
|
@ -648,17 +659,11 @@ class BranchProcessor:
|
|||
# Format key with context
|
||||
key = action.params['key'].format(**context)
|
||||
|
||||
# Convert image to bytes
|
||||
# Get image format parameters
|
||||
import cv2
|
||||
image_format = action.params.get('format', 'jpeg')
|
||||
quality = action.params.get('quality', 90)
|
||||
|
||||
if image_format.lower() == 'jpeg':
|
||||
encode_param = [cv2.IMWRITE_JPEG_QUALITY, quality]
|
||||
_, image_bytes = cv2.imencode('.jpg', image_to_save, encode_param)
|
||||
else:
|
||||
_, image_bytes = cv2.imencode('.png', image_to_save)
|
||||
|
||||
# Save to Redis synchronously using a sync Redis client
|
||||
try:
|
||||
import redis
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue