We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I've ran facenet-pytorch on this video, and the video with face tracking has a lot of false positives, especially in the second half of the video.
script:
from facenet_pytorch import MTCNN import torch import numpy as np import mmcv, cv2 from PIL import Image, ImageDraw from IPython import display import sys, os ## file names video_file = sys.argv[1] print(f'video={video_file}') video_file_output = f'{video_file}.tracked.mp4' ## which device? device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu') print('Running on device: {}'.format(device)) ## create the NN mtcnn = MTCNN(keep_all=True, device=device) ## read the video print('reading the video ...') video = mmcv.VideoReader(video_file) frames = [Image.fromarray(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)) for frame in video] ## detect faces print('tracking faces ...') frames_tracked = [] for i, frame in enumerate(frames): print('\rTracking frame: {} of {}'.format(i + 1, len(frames)), end='') # Detect faces boxes, _ = mtcnn.detect(frame) # Draw faces try: frame_draw = frame.copy() draw = ImageDraw.Draw(frame_draw) for box in boxes: draw.rectangle(box.tolist(), outline=(255, 0, 0), width=6) except: print(f'exception caught in the frame {i+1}') # Add to frame list #frames_tracked.append(frame_draw.resize((640, 360), Image.BILINEAR)) frames_tracked.append(frame_draw) print('\nDone') ## write the tracked video print('write the tracked videoi ...') dim = frames_tracked[0].size fourcc = cv2.VideoWriter_fourcc(*'mp4v') video_tracked = cv2.VideoWriter(video_file_output, fourcc, 25.0, dim) for frame in frames_tracked: video_tracked.write(cv2.cvtColor(np.array(frame), cv2.COLOR_RGB2BGR)) video_tracked.release() print(f'done: wrote the tracked output file: {video_file_output}')
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I've ran facenet-pytorch on this video, and the video with face tracking has a lot of false positives, especially in the second half of the video.
script:
The text was updated successfully, but these errors were encountered: