av-savchenko/face-emotion-recognition

AttributeError: 'EfficientNet' object has no attribute 'act1'

JimReno opened this issue · 2 comments

Thank you chenko for the great work! I tried to use effifientNet model to predict facial emotions. I used code from test_hsemotion_package.ipynb. I downloaded the xx.pt file from the models folder and load it from a local directory. The model loaded well. But an error occurs when executing fer.predict_emotions(frame,logits=True)
Here is my code.

import os
import numpy as np
import matplotlib.pyplot as plt
import cv2
from PIL import Image
import torch
from hsemotion.facial_emotions import HSEmotionRecognizer

import torch

use_cuda = torch.cuda.is_available()
device = 'cuda' if use_cuda else 'cpu'

model_path='../models/affectnet_emotions/enet_b2_8_best.pt'

fer=HSEmotionRecognizer(model_name=model_path,device=device)
# model = torch.load(model_path, map_location=torch.device('cpu'))

fpath='../test_images/0_alamy_adoration_emotion_2_22.jpg'
frame_bgr = cv2.imread(fpath)
plt.figure(figsize=(5, 5))
frame = cv2.cvtColor(frame_bgr, cv2.COLOR_BGR2RGB)
plt.axis('off')
plt.imshow(frame)

emotion, scores=fer.predict_emotions(frame,logits=True)
plt.figure(figsize=(3, 3))
plt.axis('off')
plt.imshow(frame)
plt.title(emotion)

The error is:

raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'EfficientNet' object has no attribute 'act1'

My timm version is 0.4.5. Any idea on how to solve this issue?

#15
The issue above may help you.

Regards,
Sungguk Cha

#15 The issue above may help you.

Regards, Sungguk Cha

Thank you gukcha for the lighting speed reply. I have installed timm==0.6.7. Sine this issue has been solved. I will close this issue.