Skip to content

Commit 4d305f5

Browse files
No public description
PiperOrigin-RevId: 734305540
1 parent 60f87b7 commit 4d305f5

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Diff for: official/projects/waste_identification_ml/model_inference/Inference_Tensorflow_Pipeline_with_Tracking.ipynb

+11-11
Original file line numberDiff line numberDiff line change
@@ -1152,18 +1152,18 @@
11521152
},
11531153
"outputs": [],
11541154
"source": [
1155-
"if agg_features:\n",
1155+
"if not agg_features.empty:\n",
11561156
" for group_name, df in tqdm.tqdm(agg_features.groupby(\"detection_classes_names\")):\n",
1157-
" os.makedirs(f'{output_dir}/{group_name}', exist_ok=True)\n",
1158-
"\n",
1159-
" for row in df.itertuples(index=False):\n",
1160-
" image = cv2.imread(os.path.join(images_dir,row.image_name))\n",
1161-
" image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)\n",
1162-
" new_h, new_w = image.shape[0], image.shape[1]\n",
1163-
" y1, x1, y2, x2 = row.bbox_0, row.bbox_1, row.bbox_2, row.bbox_3\n",
1164-
" new_bbox = resize_bbox(y1, x1, y2, x2, HEIGHT_TRACKING, WIDTH_TRACKING, new_h, new_w)\n",
1165-
" name = f'{os.path.splitext(row.image_name)[0]}_{row.particle}.png'\n",
1166-
" cv2.imwrite(f'{output_dir}/{row.detection_classes_names}/{name}', image[new_bbox[0]:new_bbox[2], new_bbox[1]:new_bbox[3]])"
1157+
" os.makedirs(f'{output_dir}/{group_name}', exist_ok=True)\n",
1158+
"\n",
1159+
" for row in df.itertuples(index=False):\n",
1160+
" image = cv2.imread(os.path.join(images_dir,row.image_name))\n",
1161+
" image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)\n",
1162+
" new_h, new_w = image.shape[0], image.shape[1]\n",
1163+
" y1, x1, y2, x2 = row.bbox_0, row.bbox_1, row.bbox_2, row.bbox_3\n",
1164+
" new_bbox = resize_bbox(y1, x1, y2, x2, HEIGHT_TRACKING, WIDTH_TRACKING, new_h, new_w)\n",
1165+
" name = f'{os.path.splitext(row.image_name)[0]}_{row.particle}.png'\n",
1166+
" cv2.imwrite(f'{output_dir}/{row.detection_classes_names}/{name}', image[new_bbox[0]:new_bbox[2], new_bbox[1]:new_bbox[3]])"
11671167
]
11681168
},
11691169
{

0 commit comments

Comments
 (0)