keras-team / keras

Deep Learning for humans
http://keras.io/
Apache License 2.0
61.92k stars 19.45k forks source link

yolov8 with yolo_v8_xl_backbone_coco not able to detect objects with pretrained weights #18703

Closed muhammetp closed 10 months ago

muhammetp commented 11 months ago

HEADER_STARTING_LAYER_NAME = 'yolo_v8_head_1_class_1_pad'
BBOX_FORMAT = "xywh"
INFERENCE_RESIZING = keras_cv.layers.JitteredResize(
    target_size=(640, 640),
    scale_factor=(0.75, 1.3),
    bounding_box_format=BBOX_FORMAT,
)

def load_model():
    model =  keras_cv.models.YOLOV8Detector(
        num_classes=len(LABEL_MAP),
        bounding_box_format=BBOX_FORMAT,
        backbone=keras_cv.models.YOLOV8Backbone.from_preset(
            "yolo_v8_xl_backbone_coco", load_weights=True
        ),
        fpn_depth=3
    )
    prediction_decoder = keras_cv.layers.MultiClassNonMaxSuppression(
    bounding_box_format=BBOX_FORMAT,
    from_logits=True,
    iou_threshold=0.8,
    confidence_threshold=0.62,
    )
    model.prediction_decoder = prediction_decoder
    #model = freeze_weights_up_to_header(model)

    return model
model = load_model()
if len(images.shape):
    images = np.expand_dims(images, axis=0)
norm_img = INFERENCE_RESIZING(images)
y_pred = model.predict(norm_img)

i m getting so weird predictions out of this lines of code above even if i used pretrained weights. the corresponding output is shown as follows:

frame1

As you can see the outputs all of their predictions confidence score 0.63 i also verified from debuggin which is 0.62... maybe that helps you to understand the root of the problem

image

please suggest me correct codebase which make predictions well and accurately.

sachinprasadhs commented 11 months ago

Hi, Could you please provide reproducible code in colab. Thanks!

github-actions[bot] commented 11 months ago

This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.

github-actions[bot] commented 10 months ago

This issue was closed because it has been inactive for 28 days. Please reopen if you'd like to work on this further.