YOLOV5 Models on Android

Hello everyone,
I used two yolov5 models.
My first model detects the tray. In my second model, it finds food types.

The size of the first model was 416, then I cropped it. I sent it to
the second model. The size of my second model is 224.

my question: There is a shift in the second model in the example_output.jpg
image. Second model failed to draw bounding boxes properly.I would love any advice.

Thank you very much.

Hi @Laura1 ,

First adjust the horizontal and vertical scaling factors and then offset the X , Y coordinates based on the center coordinates of the original image. Here is the sample code to adjust the coordinates. Please change according to your data structure.

        # Apply scaling factors
        if not normalized:
            left *= scaling_factors[0]
            top *= scaling_factors[1]
            right *= scaling_factors[0]
            bottom *= scaling_factors[1]

        # Offset both X, Y coordinates by tray center
        left += tray_center[0]
        top += tray_center[1]
        right += tray_center[0]
        bottom += tray_center[1]

Thank You

Hello @LK_Kadali ,

Thank you very much for reply. I will try.