mpc001 / Lipreading_using_Temporal_Convolutional_Networks

ICASSP'22 Training Strategies for Improved Lip-Reading; ICASSP'21 Towards Practical Lipreading with Distilled and Efficient Models; ICASSP'20 Lipreading using Temporal Convolutional Networks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to create .pkl file for my own video

Rathi4research opened this issue · comments

Hi,
I'm trying to create .pkl file(landmarks file) for my own video but I'm facing an error. Please help me with the procedure to create .pkl file in the same way as how it is created for the LRW dataset. PFB the details on how i tried to create.

First, I tried to create using the below code. And when it tried to use it for my own video, it is throwing the error "TypeError: unsupported operand type(s) for /: 'dict' and 'int'"

Code used to create .pkl(Using Google colab)

import cv2
import face_recognition
import pickle

cap = cv2.VideoCapture("myvideo.mp4")
landmarks_data = [] 
while cap.isOpened():
    ret, frame = cap.read()
    if not ret:
        break

    # Convert BGR image to RGB (required for face_recognition)
    rgb_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)

    # Find all face landmarks in the frame
    face_landmarks_list = face_recognition.face_landmarks(rgb_frame)

    # Append the detected landmarks to the list
    landmarks_data.append(face_landmarks_list)

cap.release()

# Serialize and save the landmarks data to a .pkl file
with open("myvideo.pkl", "wb") as file:
    pickle.dump(landmarks_data, file)