Предсказание пут Vgg16, путай - PullRequest
0 голосов
/ 18 января 2020

Я пытаюсь понять, что нам делать с результатом model.predict.

yhat = model.predict (изображение), какой вид возврата я рассматриваю, но это структура ... но потом я обнаружил это в сети, что очень смутило меня ...

Может кто-нибудь помочь мне понять 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

1 Ответ

0 голосов
/ 19 января 2020
res = model_Xc.predict(img)[0][0]

res = 0.026140803

выдает минимальное значение из массива результатов

и

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

выдает максимальное значение из массива результатов

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...