######## scaled data ############# def normalize_bbox(bboxes,img): # removing the fist and last coordinates bboxes= bboxes[1:-1] # Define the new image size new_width = 100 new_height = 100 original_width,original_height = img.size # Calculate the scaling factors x_scale = new_width / original_width y_scale = new_height / original_height #parsing the bboxes new_bboxes = [] for bbox in bboxes: x1,y1,x2,y2 = bbox # Normalize the bounding box coordinates new_x1 = int(x1 * x_scale) new_y1 = int(y1 * y_scale) new_x2 = int(x2 * x_scale) new_y2 = int(y2 * y_scale) new_bbox = new_x1,new_y1,new_x2,new_y2 new_bboxes.append(new_bbox) return new_bboxes
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter