How to use the fer.Video function in fer

To help you get started, we’ve selected a few fer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github justinshenk / fer / tests / test_fer.py View on Github external
def test_video(self):
        detector = FER()
        video = Video("tests/woman2.mp4")

        raw_data = video.analyze(detector, display=False)
        assert isinstance(raw_data, list)

        # Convert to pandas for analysis
        df = video.to_pandas(raw_data)
        assert sum(df.neutral[:5] > 0.5) == 5, f"Expected neutral > 0.5, got {df.neutral[:5]}"
        assert isinstance(df, pd.DataFrame)
        assert "angry" in df
        df = video.get_first_face(df)
        assert isinstance(df, pd.DataFrame)
        df = video.get_emotions(df)
        assert isinstance(df, pd.DataFrame)
github justinshenk / fer / video-example.py View on Github external
import matplotlib
if os.name == 'posix' and "DISPLAY" not in os.environ:
    matplotlib.use("Agg")

import matplotlib.pyplot as plt

from fer import FER
from fer import Video

if __name__ == "__main__":
    try:
        videofile = sys.argv[1]
    except:
        videofile = "test.mp4"
    detector = FER(mtcnn=True)
    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
    df.plot()
    plt.show()

fer

Facial expression recognition from images

MIT
Latest version published 1 year ago

Package Health Score

44 / 100
Full package analysis