Skip to content
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

Improve Processing time per frame in video while testing #37

Open
xanthan011 opened this issue Nov 16, 2021 · 1 comment
Open

Improve Processing time per frame in video while testing #37

xanthan011 opened this issue Nov 16, 2021 · 1 comment

Comments

@xanthan011
Copy link

Firstly, amazing work by the contributors.

I have installed the fer library on google colab (through pip).
I wanted to know if there was a way to improve the processing time per frame, my aim is to reduce the processing time while testing, let's say 4 videos at once.

I have already tired multithreading and multiprocessing, both of the methods don't seem to reduce the time for processing. I understand that your model sees each and every frame of the video that is sent, but is there a way to make it parallelly run on more than 1 video so as to reduce the overall execution time?

@xanthan011
Copy link
Author

A sample code of threading that I tried to implement is given below:

import threading

from fer import Video
from fer import FER
import matplotlib.pyplot as plt
import os
import sys



def funk(video_name):
  try:
    videofile = video_name 
    # Face detection
    detector = FER(mtcnn=True)
    # Video predictions
    video = Video(videofile)
    # Output list of dictionaries
    raw_data = video.analyze(detector, display=False) 
  except Exception as e:
    print(f"In video {video_name} there was an error: \n {e}")

videos = ["a","b","c","d"]
for each in videos:
  t2 = threading.Thread(target = funk, args = [each])    
  t2.start()

for x in threads:
     x.join()

If anything can be improved in this code in order to reduce the execution time then please let me know. Other methods are also welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant