写这个博客的关键Bug: Value passed to parameter ‘input’ has DataType uint8 not in list of allowed values: float16, bfloat16, float32, float64。本博客将围绕 加载图片 和 保存图片到本地 来详细解释和解决上述的Bug及其引出来的一系列Bug。
加载图片
首先,造成上述Bug的代码如下所示
image_path = "data/test.jpg" # 本地的测试图片
imag
最近使用pytorch时,需要用到一个预训练好的人脸识别模型提取人脸ID特征,想到很多人都在用用vgg-face,但是vgg-face没有pytorch的模型,于是写个vgg-face.mat转到pytorch模型的代码
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Thu May 10 10:41:40 2018
author: hy
"""
import torch
import math
import torc
VGG-19 Pre-trained Model for Keras.
VGG-19 Keras的预训练模型。
imagenet_class_index.json
vgg19_weights_tf_dim_ordering_tf_kernels_notop.h5
vgg19_weights_tf_dim_ordering_tf_kernels.h5
VGG-16 Pre-trained Model for Keras.
VGG-16 Keras的预训练模型。
imagenet_class_index.json
vgg16_weights_tf_dim_ordering_tf_kernels_notop.h5
vgg16_weights_tf_dim_ordering_tf_kernels.h5
我就废话不多说了,大家还是直接看代码吧!
import keras
import numpy as np
from keras.applications import vgg16, inception_v3, resnet50, mobilenet
#Load the VGG model
vgg_model = vgg16.VGG16(weights='imagenet')
#Load the Inception_V3 model
inception_model = inception_v3