前提・実現したいこと
Google Colaboratoryでpklファイルを読み込もうとした際にエラーが発生してしまいます。
またpklファイルはjoblibで読み込みをおこないたいです。
発生している問題・エラーメッセージ
ModuleNotFoundError Traceback (most recent call last) /usr/local/lib/python3.6/dist-packages/menpo/feature/optional/vlfeat.py in <module>() 7 try: ----> 8 from cyvlfeat.sift.dsift import dsift as cyvlfeat_dsift 9 except ImportError as e: 9 frames /content/drive/My Drive/熱画像から顔面皮膚温の部位抽出プログラム/src/cyvlfeat/__init__.py in <module>() ----> 1 import cyvlfeat.fisher 2 import cyvlfeat.generic 3 import cyvlfeat.gmm /content/drive/My Drive/熱画像から顔面皮膚温の部位抽出プログラム/src/cyvlfeat/fisher/__init__.py in <module>() ----> 1 from .fisher import fisher /content/drive/My Drive/熱画像から顔面皮膚温の部位抽出プログラム/src/cyvlfeat/fisher/fisher.py in <module>() 1 import numpy as np ----> 2 from .cyfisher import cy_fisher 3 ModuleNotFoundError: No module named 'cyvlfeat.fisher.cyfisher' During handling of the above exception, another exception occurred: MenpoMissingDependencyError Traceback (most recent call last) <ipython-input-83-d2537e95320f> in <module>() 119 #%cd cyvlfeat/fisher 120 #fit = pickle.load(open('AAM_model_2020_1027.pkl', 'rb')) --> 121 fit = joblib.load('AAM_model_2020_1027.pkl') 122 #fit = pickle.load('thermo_landmark.pkl') 123 #%cd ../../ /usr/local/lib/python3.6/dist-packages/joblib/numpy_pickle.py in load(filename, mmap_mode) 583 return load_compatibility(fobj) 584 --> 585 obj = _unpickle(fobj, filename, mmap_mode) 586 return obj /usr/local/lib/python3.6/dist-packages/joblib/numpy_pickle.py in _unpickle(fobj, filename, mmap_mode) 502 obj = None 503 try: --> 504 obj = unpickler.load() 505 if unpickler.compat_mode: 506 warnings.warn("The file '%s' has been generated with a " /usr/lib/python3.6/pickle.py in load(self) 1048 raise EOFError 1049 assert isinstance(key, bytes_types) -> 1050 dispatch[key[0]](self) 1051 except _Stop as stopinst: 1052 return stopinst.value /usr/lib/python3.6/pickle.py in load_global(self) 1336 module = self.readline()[:-1].decode("utf-8") 1337 name = self.readline()[:-1].decode("utf-8") -> 1338 klass = self.find_class(module, name) 1339 self.append(klass) 1340 dispatch[GLOBAL[0]] = load_global /usr/lib/python3.6/pickle.py in find_class(self, module, name) 1386 elif module in _compat_pickle.IMPORT_MAPPING: 1387 module = _compat_pickle.IMPORT_MAPPING[module] -> 1388 __import__(module, level=0) 1389 if self.proto >= 4: 1390 return _getattribute(sys.modules[module], name)[0] /usr/local/lib/python3.6/dist-packages/menpo/feature/optional/vlfeat.py in <module>() 8 from cyvlfeat.sift.dsift import dsift as cyvlfeat_dsift 9 except ImportError as e: ---> 10 raise MenpoMissingDependencyError(e) 11 12 MenpoMissingDependencyError: You need to install the 'No module named 'cyvlfeat.fisher.cyfisher'' package in order to use this functionality. We recommend that you use conda to achieve this - try the command 'conda install -c menpo No module named 'cyvlfeat.fisher.cyfisher'' in your terminal.
該当のソースコード
python
1# coding: utf-8 2import copy 3import glob 4import keras 5from keras.applications.imagenet_utils import preprocess_input 6#from keras.backend.tensorflow_backend import set_session 7#from tensorflow.compat.v1.keras.backend import set_session 8from keras import backend as K 9from keras.models import Model 10from keras.preprocessing import image 11import matplotlib.pyplot as plt 12import pickle 13from random import shuffle 14import scipy 15from scipy.misc import imread 16from scipy.misc import imresize 17import seaborn as sns 18import tensorflow as tf 19import requests 20# from tqdm.notebook import tqdm 21from tqdm import tqdm 22from menpo.shape import bounding_box 23from menpo.transform import UniformScale 24from menpo.visualize import print_progress 25from scipy import io 26from PIL import Image 27import h5py 28import glob2 29import menpo.io as mio 30import pandas as pd 31import os ,sys ,cv2 32import matplotlib 33import matplotlib.image as mpimg 34import matplotlib.pyplot as plt 35from pathlib import Path 36import dlib 37import joblib 38import numpy as np 39import pickle 40from pyclustering.cluster import cluster_visualizer 41from pyclustering.cluster.xmeans import xmeans 42from pyclustering.cluster.center_initializer import kmeans_plusplus_initializer 43#from __future__ import division 44from functools import partial 45from pathlib import Path 46from menpo.base import MenpoMissingDependencyError 47import h5py 48import numpy as np 49from PIL import Image 50try: 51 import dlib 52except ImportError: 53 raise MenpoMissingDependencyError('dlib') 54from menpodetect.compatibility import STRING_TYPES 55from menpowidgets.tools import LogoWidget 56''' 57from menpowidgets.options import (RendererOptionsWidget, TextPrintWidget, 58 SaveFigureOptionsWidget, AnimationOptionsWidget, 59 LandmarkOptionsWidget, ChannelOptionsWidget, 60 FeatureOptionsWidget, PlotOptionsWidget, 61 PatchOptionsWidget, LinearModelParametersWidget, 62 CameraSnapshotWidget) 63 64from menpowidgets import (visualize_pointclouds, visualize_landmarkgroups, 65 visualize_landmarks, visualize_images, visualize_patches, 66 plot_graph, save_matplotlib_figure, features_selection) 67''' 68#get_ipython().magic('matplotlib inline') 69 70 71# グラフのレイアウトの設定 72plt.rcParams['font.family'] ='sans-serif'# 使用するフォント 73# plt.rcParams['font.family'] = 'IPAexGothic' # 使用するフォント 74# plt.rcParams['font.family'] = 'Times New Roman' # 使用するフォント 75 76# x軸の目盛線が内向き('in')か外向き('out')か双方向か('inout') 77plt.rcParams['xtick.direction'] = 'in' 78# y軸の目盛線が内向き('in')か外向き('out')か双方向か('inout') 79plt.rcParams['ytick.direction'] = 'in' 80plt.rcParams['xtick.major.width'] = 1.0 # x軸主目盛り線の線幅 81plt.rcParams['ytick.major.width'] = 1.0 # y軸主目盛り線の線幅 82plt.rcParams['font.size'] = 8 # フォントの大きさ 83plt.rcParams['axes.linewidth'] = 1.0 # 軸の線幅edge linewidth。囲みの太さ 84 85 86# importの探索ディレクトリの追加 87#MENPO_PATH = '.../src/' 88#sys.path.append(MENPO_PATH) 89from ssd import SSD300 90from ssd_training import MultiboxLoss 91from ssd_utils import BBoxUtility 92 93# logの設定 94from logging import StreamHandler, DEBUG, Formatter, FileHandler, getLogger 95 96logger = getLogger(__name__) 97DIR = 'log/' 98 99log_fmt = Formatter('%(asctime)s %(name)s %(lineno)d [%(levelname)s][%(funcName)s] %(message)s ') 100handler = StreamHandler() 101handler.setLevel('INFO') 102handler.setFormatter(log_fmt) 103logger.addHandler(handler) 104 105# ログファイルの保存先 106try: 107 os.mkdir('./{}'.format(DIR)) 108except FileExistsError: 109 pass 110 111handler = FileHandler(DIR + 'train.py.log', 'a') 112handler.setLevel(DEBUG) 113handler.setFormatter(log_fmt) 114logger.setLevel(DEBUG) 115logger.addHandler(handler) 116 117logger.info('start') 118 119fit = joblib.load('AAM_model_2020_1027.pkl')
試したこと
以下のリンクの対処をしました。
https://qiita.com/knok/items/598052d17d0f1b26f77a
あなたの回答
tips
プレビュー