前提・実現したいこと
googleコラボラトリーの方で、エラーが発生したため、解決方法をお伺いしたいです。
発生している問題・エラーメッセージ
AttributeError Traceback (most recent call last) <ipython-input-22-c166c9cbba1e> in <module>() 1 import emotion 2 ----> 3 results = emotion.predict(pathlib.Path("/content/images")) 4 np.savez("/content/results/emotions.npz", **results) 5 frames /content/gan-playground/analyze_attributes/emotion.py in predict(target_dir) 41 def predict(target_dir: pathlib.Path) -> Dict[str, np.ndarray]: 42 results = {} ---> 43 detect = EmotionDetector() 44 for i, img_file in enumerate(map(str, target_dir.glob("*.png"))): 45 image = load_image(img_file) /content/gan-playground/analyze_attributes/emotion.py in __init__(self) 16 self.detector = dlib.get_frontal_face_detector() 17 self.crop = pr.CropBoxes2D() ---> 18 self.classify = MiniXceptionFER() 19 20 def call(self, image: np.ndarray) -> List[np.ndarray]: /usr/local/lib/python3.7/dist-packages/paz/pipelines/classification.py in __init__(self) 35 def __init__(self): 36 super(MiniXceptionFER, self).__init__() ---> 37 self.classifier = MiniXception((48, 48, 1), 7, weights='FER') 38 self.class_names = get_class_names('FER') 39 /usr/local/lib/python3.7/dist-packages/paz/models/classification/xception.py in MiniXception(input_shape, num_classes, weights) 104 filename = 'fer2013_mini_XCEPTION.119-0.65.hdf5' 105 path = get_file(filename, URL + filename, cache_subdir='paz/models') --> 106 model = load_model(path) 107 else: 108 stem_kernels = [32, 64] /tensorflow-1.15.2/python3.7/tensorflow_core/python/keras/saving/save.py in load_model(filepath, custom_objects, compile) 141 if (h5py is not None and ( 142 isinstance(filepath, h5py.File) or h5py.is_hdf5(filepath))): --> 143 return hdf5_format.load_model_from_hdf5(filepath, custom_objects, compile) 144 145 if isinstance(filepath, six.string_types): /tensorflow-1.15.2/python3.7/tensorflow_core/python/keras/saving/hdf5_format.py in load_model_from_hdf5(filepath, custom_objects, compile) 158 if model_config is None: 159 raise ValueError('No model found in config file.') --> 160 model_config = json.loads(model_config.decode('utf-8')) 161 model = model_config_lib.model_from_config(model_config, 162 custom_objects=custom_objects) AttributeError: 'str' object has no attribute 'decode'
該当のソースコード
import emotion results = emotion.predict(pathlib.Path("/content/images")) np.savez("/content/results/emotions.npz", **results)
あなたの回答
tips
プレビュー