-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
我写了预测代码,为什么预测出来是一个都是同一个类别呀 #15
Comments
目前这个问题解决了吗?我也是这个问题。 |
我也是兄弟,有解决办法么 |
应该是BatchNormalization的锅 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
我训练的时候看到准确率是90%以上,但是拿训练图片去预测,却都是一个类别
from keras.models import Model
from keras.layers import Input, Conv2D, GlobalAveragePooling2D, Dropout
from keras.layers import Activation, BatchNormalization, add, Reshape,DepthwiseConv2D,ReLU
from keras.applications.mobilenet import relu6, DepthwiseConv2D
from keras.utils.vis_utils import plot_model
from keras import backend as K
import cv2
import numpy as np
import time
import os
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
def _conv_block(inputs, filters, kernel, strides):
"""Convolution Block
This function defines a 2D convolution operation with BN and relu6.
def _bottleneck(inputs, filters, kernel, t, s, r=False):
"""Bottleneck
This function defines a basic bottleneck structure.
def _inverted_residual_block(inputs, filters, kernel, t, strides, n):
"""Inverted Residual Block
This function defines a sequence of 1 or more identical layers.
def MobileNetv2( k=3):
"""MobileNetv2
This function defines a MobileNetv2 architectures.
if name=="main":
model=MobileNetv2()
files=os.listdir("testimage3/")
for file in files:
print file
time1=time.time()
image = cv2.imread("testimage3/"+file)
image = cv2.resize(image, (224, 224))
image = image.transpose(1, 0, 2)
result = model.predict(np.array([image]),verbose=1)
print result
print "耗时:",time.time()-time1
The text was updated successfully, but these errors were encountered: