Skip to content

Commit

Permalink
No public description
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 734305540
  • Loading branch information
tensorflower-gardener committed Mar 6, 2025
1 parent d6397c8 commit aa2c509
Showing 1 changed file with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1152,18 +1152,18 @@
},
"outputs": [],
"source": [
"if agg_features:\n",
"if not agg_features.empty:\n",
" for group_name, df in tqdm.tqdm(agg_features.groupby(\"detection_classes_names\")):\n",
" os.makedirs(f'{output_dir}/{group_name}', exist_ok=True)\n",
"\n",
" for row in df.itertuples(index=False):\n",
" image = cv2.imread(os.path.join(images_dir,row.image_name))\n",
" image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)\n",
" new_h, new_w = image.shape[0], image.shape[1]\n",
" y1, x1, y2, x2 = row.bbox_0, row.bbox_1, row.bbox_2, row.bbox_3\n",
" new_bbox = resize_bbox(y1, x1, y2, x2, HEIGHT_TRACKING, WIDTH_TRACKING, new_h, new_w)\n",
" name = f'{os.path.splitext(row.image_name)[0]}_{row.particle}.png'\n",
" cv2.imwrite(f'{output_dir}/{row.detection_classes_names}/{name}', image[new_bbox[0]:new_bbox[2], new_bbox[1]:new_bbox[3]])"
" os.makedirs(f'{output_dir}/{group_name}', exist_ok=True)\n",
"\n",
" for row in df.itertuples(index=False):\n",
" image = cv2.imread(os.path.join(images_dir,row.image_name))\n",
" image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)\n",
" new_h, new_w = image.shape[0], image.shape[1]\n",
" y1, x1, y2, x2 = row.bbox_0, row.bbox_1, row.bbox_2, row.bbox_3\n",
" new_bbox = resize_bbox(y1, x1, y2, x2, HEIGHT_TRACKING, WIDTH_TRACKING, new_h, new_w)\n",
" name = f'{os.path.splitext(row.image_name)[0]}_{row.particle}.png'\n",
" cv2.imwrite(f'{output_dir}/{row.detection_classes_names}/{name}', image[new_bbox[0]:new_bbox[2], new_bbox[1]:new_bbox[3]])"
]
},
{
Expand Down

0 comments on commit aa2c509

Please sign in to comment.