SqueezeNetの
学習済caffeモデルをchainerに読み込もうと、以下の記事を参考にしました。
Chainerでcaffemodelを読み込んで画像を分類するこちらのソースコードで、新たに以下のクラスを作成しました。
class SqueezeNet(NNModel):
def __init__(self):
NNModel.__init__(self)
def _image_shape(self):
return (227, 227)
def _mean_image(self):
mean_image = np.ndarray((3, 227, 227), dtype=np.float32)
mean_image[0] = 103.939
mean_image[1] = 116.779
mean_image[2] = 123.68
return mean_image
def _predict_class(self, x):
y, = self.func(inputs={'data': x}, outputs=['pool10'], train=False)
return F.softmax(y)
添付の画像で実行してみたところ、GoogleNetでは「36.70% tabby, tabby cat」という結果が出たのですが、SqueezeNetでは以下のワーニングが出て、「nan% tench, Tinca tinca」という結果になりました。
Warning (from warnings module):
File "C:\Python27\lib\site-packages\numpy\core\_methods.py", line 59
warnings.warn("Mean of empty slice.", RuntimeWarning)
RuntimeWarning: Mean of empty slice.
Warning (from warnings module):
File "C:\Python27\lib\site-packages\numpy\core\_methods.py", line 68
ret, rcount, out=ret, casting='unsafe', subok=False)
RuntimeWarning: invalid value encountered in true_divide
正しく動作していないようですが、SqueezeNetのcaffeモデルはchainerに読み込むことが出来ないのでしょうか。
アドバイス頂けましたら幸いです。
以上、よろしくお願い致します。