def test_detector(): detector = Detector(n_jobs=1) assert detector['n_jobs'] == 1 assert type(detector) == Detector # Test detect image inputFname = os.path.join(get_test_data_path(), "input.jpg") out = detector.detect_image(inputFname=inputFname) assert type(out) == Fex assert len(out) == 1 assert out.happiness.values[0] > 0 outputFname = os.path.join(get_test_data_path(), "output.csv") out = detector.detect_image(inputFname=inputFname, outputFname=outputFname) assert out assert os.path.exists(outputFname) out = pd.read_csv(outputFname) assert out.happiness.values[0] > 0 # Test detect video inputFname = os.path.join(get_test_data_path(), "input.mp4") out = detector.detect_video(inputFname=inputFname) assert len(out) == 72 outputFname = os.path.join(get_test_data_path(), "output.csv") out = detector.detect_video(inputFname=inputFname, outputFname=outputFname) assert out assert os.path.exists(outputFname) out = pd.read_csv(outputFname) assert out.happiness.values.max() > 0
def test_detect_image(): # Test detect image detector = Detector(n_jobs=1) inputFname = os.path.join(get_test_data_path(), "input.jpg") out = detector.detect_image(inputFname=inputFname) assert type(out) == Fex assert len(out) == 1 assert out.happiness.values[0] > 0 outputFname = os.path.join(get_test_data_path(), "output.csv") out = detector.detect_image(inputFname=inputFname, outputFname=outputFname) assert out assert os.path.exists(outputFname) out = pd.read_csv(outputFname) assert out.happiness.values[0] > 0
def test_resmasknet(): inputFname = os.path.join(get_test_data_path(), "sampler0000.jpg") detector1 = Detector(emotion_model="resmasknet") out = detector1.detect_image(inputFname) assert out.emotions()["neutral"].values > 0.5
def test_nofile(): with pytest.raises(FileNotFoundError): inputFname = os.path.join(get_test_data_path(), "nosuchfile.jpg") detector1 = Detector(emotion_model="svm") out = detector1.detect_image(inputFname)
def test_emotionrf(): # Emotion RF models is not good inputFname = os.path.join(get_test_data_path(), "input.jpg") detector1 = Detector(emotion_model="rf") out = detector1.detect_image(inputFname) assert out.emotions()["happiness"].values > 0.0
def test_emotionsvm(): inputFname = os.path.join(get_test_data_path(), "input.jpg") detector1 = Detector(emotion_model="svm") out = detector1.detect_image(inputFname) assert out.emotions()["happiness"].values > 0.5