|
111 | 111 | }, |
112 | 112 | "cell_type": "code", |
113 | 113 | "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" |
115 | 115 | ], |
116 | 116 | "outputs": [], |
117 | 117 | "execution_count": null |
|
122 | 122 | }, |
123 | 123 | "cell_type": "code", |
124 | 124 | "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", |
126 | 126 | "class_id_to_class_name_mapper = seg_medium_model.class_names" |
127 | 127 | ], |
128 | 128 | "outputs": [], |
|
302 | 302 | }, |
303 | 303 | "cell_type": "code", |
304 | 304 | "source": [ |
305 | | - "img_path = \"./sample_image.jpg\"\n", |
| 305 | + "input_image_path = \"./sample_image.jpg\"\n", |
306 | 306 | "onnx_model_path = \"./inference_model.onnx\"\n", |
307 | | - "output_image_dimensions = (1024, 1024)" |
| 307 | + "output_image_dimension = (1920, 1080)" |
308 | 308 | ], |
309 | 309 | "outputs": [], |
310 | 310 | "execution_count": null |
|
345 | 345 | }, |
346 | 346 | "cell_type": "code", |
347 | 347 | "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})" |
350 | 350 | ], |
351 | 351 | "outputs": [], |
352 | 352 | "execution_count": null |
|
362 | 362 | }, |
363 | 363 | { |
364 | 364 | "metadata": { |
365 | | - "id": "POQajqV7IeGZ" |
| 365 | + "id": "6eucX1xOsyrr" |
366 | 366 | }, |
367 | | - "cell_type": "markdown", |
| 367 | + "cell_type": "code", |
368 | 368 | "source": [ |
369 | 369 | "results = model_utils._reformat_triton_output_to_dict(\n", |
370 | 370 | " outputs, confidence_threshold=0.5, max_boxes=100\n", |
371 | 371 | ")\n", |
372 | 372 | "\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", |
374 | 375 | "results[\"class_names\"] = model_utils.get_class_names(results)" |
375 | | - ] |
| 376 | + ], |
| 377 | + "outputs": [], |
| 378 | + "execution_count": null |
376 | 379 | }, |
377 | 380 | { |
378 | 381 | "metadata": { |
|
385 | 388 | }, |
386 | 389 | { |
387 | 390 | "metadata": { |
388 | | - "id": "dwHzAAwjIjbu" |
| 391 | + "id": "4tIuPGpls0h4" |
389 | 392 | }, |
390 | | - "cell_type": "markdown", |
| 393 | + "cell_type": "code", |
391 | 394 | "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", |
393 | 396 | "Image.open(\"./output.jpg\")" |
394 | | - ] |
| 397 | + ], |
| 398 | + "outputs": [], |
| 399 | + "execution_count": null |
395 | 400 | }, |
396 | 401 | { |
397 | 402 | "metadata": { |
|
0 commit comments