首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >预测Vgg16的输出,混淆

预测Vgg16的输出,混淆
EN

Stack Overflow用户
提问于 2020-01-19 01:58:17
回答 1查看 31关注 0票数 0

我正在尝试理解如何处理来自model.predict的结果。

yhat =model.predict(图像),我正在寻找什么样的回报,但它是一种结构……但后来我在网上发现了这个,这让我很困惑。

有人能帮我理解一下model.predict(x)吗?

我正在尝试获取一个值,这样我就可以看到它是一件或另一件事。这是一个两级分类。

谢谢。

代码语言:javascript
运行
复制
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
EN

Stack Overflow用户

发布于 2020-01-19 05:33:29

代码语言:javascript
运行
复制
res = model_Xc.predict(img)[0][0]

res = 0.026140803

它给出了结果数组中的最小值

代码语言:javascript
运行
复制
res = model_Xc.predict(img)[0][1]

它给出了结果数组的最大值

票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59803355

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档