繁体   English   中英

预测 Vgg16 的输出,混淆

[英]Predicting out put of a Vgg16, confuse

我试图了解我们如何处理来自 model.predict 的结果。

yhat = model.predict(image),我正在研究什么样的回报,但它是一个结构......但后来我在网上发现了这个让我真的很困惑......

有人可以帮我理解 model.predict([x])[0][0]

我试图获得一个价值,以便我可以看到它是一回事。 它是一个二级分类。

谢谢。

def get_predicition(image):
    height, width = image.shape[:2]
    try: # If in case face is not detected at any frame
        face = face_detector(image, 1)[0]  # Face detection
        x, y, size = get_boundingbox(face=face, width=width, height=height) # Calling to get bound box around the face
    except IndexError:
        pass
    cropped_face = image[y:y+size, x:x+size] # cropping the face 
    output,label = evaluate(cropped_face) # Sending the cropped face to get classifier result 
    font_face = cv2.FONT_HERSHEY_SIMPLEX # font settings
    thickness = 2
    font_scale = 1
    if label=='Real':
        color = (0,255, 0)
    else:
        color = (0, 0, 255)
    x = face.left()    # Setting the bounding box on uncropped image
    y = face.top()
    w = face.right() - x
    h = face.bottom() - y
    cv2.putText(image, label+'_'+str('%.2f'%output)+'%', (x, y+h+30), 
            font_face, font_scale,
            color, thickness, 2) # Putting the label and confidence values

    return cv2.rectangle(image, (x, y), (x + w, y + h), color, 2)# draw box over face

def evaluate(cropped_face):
    # Read the image and resize it
    img = cv2.resize(cropped_face, (224, 224))

    # Reshape
    x = img.reshape((1,) + img.shape)
    x /= 255.

    result = model_Xc.predict([x])[0][0] # result = model_Xc.predict([x])[0][0]

    if result > 0.5:
        animal = "cat"
    else:
        animal = "dog"
        result = 1 - result

    return result, animal
res = model_Xc.predict(img)[0][0]

res = 0.026140803

它为您提供结果数组中的最小值

res = model_Xc.predict(img)[0][1]

它为您提供结果数组中的最大值

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM