Skip to content

Commit f6d0be6

Browse files
No public description
PiperOrigin-RevId: 898054992
1 parent 4a39a5c commit f6d0be6

1 file changed

Lines changed: 19 additions & 14 deletions

File tree

official/projects/waste_identification_ml/model_inference/cn_model_run.ipynb

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
},
112112
"cell_type": "code",
113113
"source": [
114-
"!wget https://storage.googleapis.com/tf_model_garden/vision/waste_identification_ml/CN-ModelCheckpoints/checkpoint_best_total_432x432.pth"
114+
"!wget https://storage.googleapis.com/tf_model_garden/vision/waste_identification_ml/CN-ModelCheckpoints/ModelRegistry_432x432_March26/checkpoint_best_total.pth"
115115
],
116116
"outputs": [],
117117
"execution_count": null
@@ -122,7 +122,7 @@
122122
},
123123
"cell_type": "code",
124124
"source": [
125-
"seg_medium_model = RFDETRSegMedium(pretrain_weights=\"./checkpoint_best_total_432x432.pth\")\n",
125+
"seg_medium_model = RFDETRSegMedium(pretrain_weights=\"./checkpoint_best_total.pth\")\n",
126126
"class_id_to_class_name_mapper = seg_medium_model.class_names"
127127
],
128128
"outputs": [],
@@ -302,9 +302,9 @@
302302
},
303303
"cell_type": "code",
304304
"source": [
305-
"img_path = \"./sample_image.jpg\"\n",
305+
"input_image_path = \"./sample_image.jpg\"\n",
306306
"onnx_model_path = \"./inference_model.onnx\"\n",
307-
"output_image_dimensions = (1024, 1024)"
307+
"output_image_dimension = (1920, 1080)"
308308
],
309309
"outputs": [],
310310
"execution_count": null
@@ -345,8 +345,8 @@
345345
},
346346
"cell_type": "code",
347347
"source": [
348-
"image_array = model_utils._get_input_batch_for_inference(image_path=img_path)\n",
349-
"outputs = onnx_model_session.run(None, {\"input\": image_array})"
348+
"image_array = model_utils._get_input_batch_for_inference(image_path=input_image_path)\n",
349+
"outputs = onnx_model.run(None, {\"input\": image_array})"
350350
],
351351
"outputs": [],
352352
"execution_count": null
@@ -362,17 +362,20 @@
362362
},
363363
{
364364
"metadata": {
365-
"id": "POQajqV7IeGZ"
365+
"id": "6eucX1xOsyrr"
366366
},
367-
"cell_type": "markdown",
367+
"cell_type": "code",
368368
"source": [
369369
"results = model_utils._reformat_triton_output_to_dict(\n",
370370
" outputs, confidence_threshold=0.5, max_boxes=100\n",
371371
")\n",
372372
"\n",
373-
"results = model_utils._scale_bbox_and_masks(results, target_dims=(1920, 1080))\n",
373+
"# output_image_dimension makes sure the output image dimession along with the bounding boxes and masks are resized.\n",
374+
"results = model_utils._scale_bbox_and_masks(results, target_dims=output_image_dimension)\n",
374375
"results[\"class_names\"] = model_utils.get_class_names(results)"
375-
]
376+
],
377+
"outputs": [],
378+
"execution_count": null
376379
},
377380
{
378381
"metadata": {
@@ -385,13 +388,15 @@
385388
},
386389
{
387390
"metadata": {
388-
"id": "dwHzAAwjIjbu"
391+
"id": "4tIuPGpls0h4"
389392
},
390-
"cell_type": "markdown",
393+
"cell_type": "code",
391394
"source": [
392-
"draw_detections_and_save_image(img=Image.open(img_path), results=results, save_path= \"./output.jpg\")\n",
395+
"draw_detections_and_save_image(img=Image.open(input_image_path), results=results, save_path= \"./output.jpg\")\n",
393396
"Image.open(\"./output.jpg\")"
394-
]
397+
],
398+
"outputs": [],
399+
"execution_count": null
395400
},
396401
{
397402
"metadata": {

0 commit comments

Comments
 (0)