JustinShenk / fer

Facial Expression Recognition with a deep neural network as a PyPI package
MIT License
351 stars 80 forks source link

Model prediction is at 15 FPS, anyway to increase throughput? #20

Open pangshengwei opened 3 years ago

JustinShenk commented 3 years ago

Yes, we could batch images through the model. Are you using cpu only or also GPU acceleration?

Neel7317 commented 3 years ago

how can we change FPS for Model prediction?

JustinShenk commented 3 years ago

Consider setting the save_fps parameter to a number 2-25. This will only compute on the nth frame.

Neel7317 commented 3 years ago

thanks for answering but after changing save_fps parameter, i have to retrain the model ? and if i give save_fps=3 or 4 then will model get decrease its accuracy?

JustinShenk commented 3 years ago

save_fps just changes how many frames are skipped when running inference on the video. It doesn't change the model, only how it is applied to the video.

On Thu, Jun 17, 2021 at 11:59 AM Neelkanth @.***> wrote:

thanks for answering but after changing save_fps parameter, i have to retrain the model ? and if i give save_fps=3 or 4 then will model get decrease its accuracy?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/justinshenk/fer/issues/20#issuecomment-863104481, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACOLMZGQ6GMEXWXKLL4Z2BDTTHBONANCNFSM4355BPHQ .

Neel7317 commented 3 years ago

Thank you so much. I just found where to put that and it's working fine. and another doubt in my mind about whether we can have any solution to make this entire process fast? I have a GPU too but still it takes too much time for complete execution for just 1 minute video file.

On Thu, Jun 17, 2021 at 4:29 PM Neelkanth Bhavnagarwala < @.***> wrote:

means if i am using this below code then where do i make changes for save_fps can you tell me please ?

def foremotion():

fn contains the video file name (Ensure that you only upload one file)

videofile = "D://RR/integration/in.mp4"

Face detection

detector = FER(mtcnn=True)

Video predictions

video = Video(videofile)

Output list of dictionaries

raw_data = video.analyze(detector, display=False)

Convert to pandas for analysis

df = video.to_pandas(raw_data) df = video.get_first_face(df) df = video.get_emotions(df)

Plot emotions

fig = df.plot(figsize=(20, 10), fontsize=14).get_figure()

Filename for plot

fig.savefig('static/my_figure.png')

return render_template('try.html',img="static/my_figure.png")

On Thu, Jun 17, 2021 at 3:57 PM Justin Shenk @.***> wrote:

save_fps just changes how many frames are skipped when running inference on the video. It doesn't change the model, only how it is applied to the video.

On Thu, Jun 17, 2021 at 11:59 AM Neelkanth @.***> wrote:

thanks for answering but after changing save_fps parameter, i have to retrain the model ? and if i give save_fps=3 or 4 then will model get decrease its accuracy?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/justinshenk/fer/issues/20#issuecomment-863104481, or unsubscribe < https://github.com/notifications/unsubscribe-auth/ACOLMZGQ6GMEXWXKLL4Z2BDTTHBONANCNFSM4355BPHQ

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/justinshenk/fer/issues/20#issuecomment-863123478, or unsubscribe https://github.com/notifications/unsubscribe-auth/APU3EWCJ6K7JBELVNRU4DYDTTHEX5ANCNFSM4355BPHQ .

JustinShenk commented 3 years ago

It could be extended for this, maybe someone else will be kind enough to contribute this feature.

On Thu 17. Jun 2021 at 13:19 Neelkanth @.***> wrote:

Thank you so much. I just found where to put that and it's working fine. and another doubt in my mind about whether we can have any solution to make this entire process fast? I have a GPU too but still it takes too much time for complete execution for just 1 minute video file.

On Thu, Jun 17, 2021 at 4:29 PM Neelkanth Bhavnagarwala < @.***> wrote:

means if i am using this below code then where do i make changes for save_fps can you tell me please ?

def foremotion():

fn contains the video file name (Ensure that you only upload one file)

videofile = "D://RR/integration/in.mp4"

Face detection

detector = FER(mtcnn=True)

Video predictions

video = Video(videofile)

Output list of dictionaries

raw_data = video.analyze(detector, display=False)

Convert to pandas for analysis

df = video.to_pandas(raw_data) df = video.get_first_face(df) df = video.get_emotions(df)

Plot emotions

fig = df.plot(figsize=(20, 10), fontsize=14).get_figure()

Filename for plot

fig.savefig('static/my_figure.png')

return render_template('try.html',img="static/my_figure.png")

On Thu, Jun 17, 2021 at 3:57 PM Justin Shenk @.***> wrote:

save_fps just changes how many frames are skipped when running inference on the video. It doesn't change the model, only how it is applied to the video.

On Thu, Jun 17, 2021 at 11:59 AM Neelkanth @.***> wrote:

thanks for answering but after changing save_fps parameter, i have to retrain the model ? and if i give save_fps=3 or 4 then will model get decrease its accuracy?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <https://github.com/justinshenk/fer/issues/20#issuecomment-863104481 , or unsubscribe <

https://github.com/notifications/unsubscribe-auth/ACOLMZGQ6GMEXWXKLL4Z2BDTTHBONANCNFSM4355BPHQ

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/justinshenk/fer/issues/20#issuecomment-863123478, or unsubscribe < https://github.com/notifications/unsubscribe-auth/APU3EWCJ6K7JBELVNRU4DYDTTHEX5ANCNFSM4355BPHQ

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/justinshenk/fer/issues/20#issuecomment-863154964, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACOLMZDAKOEATIGQSX4RDV3TTHK5DANCNFSM4355BPHQ .