mlapi face detection

Discussion topics related to mobile applications and ZoneMinder Event Server (including machine learning)
Post Reply
VicThor
Posts: 39
Joined: Tue Oct 13, 2020 8:47 pm

mlapi face detection

Post by VicThor »

Hi all,

Looking for some guidance in getting face detection working. I believe I have set up the ml_sequence correctly but it never gets to the face detection part:

Oct 03 2021 10:47:23.246741 [DBG 1] Skipping face as it was overridden in ml_overrides
Not sure what that means, i can;t find that variable anywhere.

Here is my sequence:

Code: Select all

[ml]
# if enabled, will not grab exclusive locks before running inferencing
# locking seems to cause issues on some unique file systems
disable_locks = no


use_sequence = yes

stream_sequence = {
		'frame_strategy': 'most_unique',
		'frame_set': 'snapshot,alarm',
		'contig_frames_before_error': 5,
		'max_attempts': 3,
		'sleep_between_attempts': 0,
		'delay_between_frames':0,
		'convert_snapshot_to_fid':'yes',
		'resize': 'no',
	}

ml_sequence= {
		'general': {
			'model_sequence': 'object,face',
                        'disable_locks': '{{disable_locks}}',
			'match_past_detections': 'yes',
			'past_det_max_diff_area': '15%',
			'car_past_det_max_diff_area': '15%',
		},
		'object': {
			'general':{
				'pattern':'{{object_detection_pattern}}',
				'same_model_sequence_strategy': 'first' # also 'most', 'most_unique's
			},
			'sequence': [{
				#First run on TPU with higher confidence
				'name': 'TPU object detection',
				'enabled': 'yes',
				'object_weights':'{{object_weights}}',
				'object_labels': '{{object_labels}}',
				'object_min_confidence': {{tpu_min_confidence}},
				'object_framework':'{{tpu_object_framework}}',
				'tpu_max_processes': {{tpu_max_processes}},
				'tpu_max_lock_wait': {{tpu_max_lock_wait}},
                                'max_detection_size':'{{max_detection_size}}',
				'show_models':'{{show_models}}'

				
			},
			{
				# YoloV4 on GPU if TPU fails (because sequence strategy is 'first')
				'name': 'YoloV4 GPU/CPU',
				'enabled': 'yes', # don't really need to say this explictly
				'object_config':'{{yolo4_object_config}}',
				'object_weights':'{{yolo4_object_weights}}',
				'object_labels': '{{yolo4_object_labels}}',
				'object_min_confidence': {{object_min_confidence}},
				'object_framework':'{{yolo4_object_framework}}',
				'object_processor': '{{yolo4_object_processor}}',
				'gpu_max_processes': {{gpu_max_processes}},
				'gpu_max_lock_wait': {{gpu_max_lock_wait}},
				'cpu_max_processes': {{cpu_max_processes}},
				'cpu_max_lock_wait': {{cpu_max_lock_wait}},
                                'max_detection_size':'{{max_detection_size}}',
				'show_models':'{{show_models}}'

			}]
		},
		'face': {
			'general':{
				'pattern': '{{face_detection_pattern}}',		
				'pre_existing_labels': ['person'], # when put in general section, it will check if a previous detection type (like object) found this label
				'same_model_sequence_strategy': 'union' # combines all outputs of this sequence
			},
			'sequence': [
			{
				'name': 'TPU face detection',
				'enabled': 'yes',
				'face_detection_framework': 'tpu',
				'face_weights':'/var/lib/zmeventnotification/models/coral_edgetpu/ssd_mobilenet_v2_face_quant_postprocess_edgetpu.tflite',
				'face_min_confidence': 0.3,
			
			},
			{
				'name': 'DLIB based face recognition',
				'enabled': 'yes',
				'pre_existing_labels': ['face'], # If you use TPU detection first, we can run this ONLY if TPU detects a face first
				'save_unknown_faces':'{{save_unknown_faces}}',
				'save_unknown_faces_leeway_pixels':{{save_unknown_faces_leeway_pixels}},
				'face_detection_framework': '{{face_detection_framework}}',
				'known_images_path': '{{known_images_path}}',
				'unknown_images_path': '{{unknown_images_path}}',
				'face_model': '{{face_model}}',
				'face_train_model': '{{face_train_model}}',
				'face_recog_dist_threshold': '{{face_recog_dist_threshold}}',
				'face_num_jitters': '{{face_num_jitters}}',
				'face_upsample_times':'{{face_upsample_times}}',
				'gpu_max_processes': {{gpu_max_processes}},
				'gpu_max_lock_wait': {{gpu_max_lock_wait}},
				'cpu_max_processes': {{cpu_max_processes}},
				'cpu_max_lock_wait': {{cpu_max_lock_wait}},
				'max_size':800
			}]
		}
	}
Appreciate any help
tsp84
Posts: 227
Joined: Thu Dec 24, 2020 4:04 am

Re: mlapi face detection

Post by tsp84 »

Ml_overrides is sent from the ZMES host. I'm assuming you are using mlapi?

I'll hop on my rig and take a look, I had this issue before but I ended up changing core code alot so thing smight be different.
VicThor
Posts: 39
Joined: Tue Oct 13, 2020 8:47 pm

Re: mlapi face detection

Post by VicThor »

Thank you sir, that led me to the issue. I have to modify the monitor in objectconfig.ini not mlapiconfig.
Cheers
tsp84
Posts: 227
Joined: Thu Dec 24, 2020 4:04 am

Re: mlapi face detection

Post by tsp84 »

Awesome!
Post Reply