This project is useful only for pre-trained yolov8 weights. It requires a weights file ("xxx.pt") and images to crop.
"crop_focus_object_driver.py" file is an example for using the crop function. You need to declare the paths of images and weight.pt file.
"choose_one_bbox.py" has a function which decides the bounding box which is most likely to be the focus object bbox in case of multiple detections.
Requirements that have to be installed:
ultralytics
cv2
os
imageio
pytorch
time
Here are some input-output examples of the crop function. (each edge has %1 margin added to original detection in the examples.)
(Images are resized to display and output images are not in their original cropped sizes.)
Example 1 input:
Example 1 output:
Example 2 input:
Example 2 output:
Example 3 input:
Example 3 output:
Example 4 input:
Example 4 output:
Example 5 input:
Example 5 output:
Example 6 input:
Example 6 output:
Example 7 input:
Example 7 output:
Example 8 input:
Example 8 output:
Example 9 input:
Example 9 output:
Example 10 input:
Example 10 output:
Example 11 input:
Example 11 output:
Example 12 input:
Example 12 output:
Example 13 input:
Example 13 output:
Example 14 input:
Example 14 output: