|
370 | 370 | " total_time_dict = {}\n",
|
371 | 371 | " roi_size = (96, 96, 96)\n",
|
372 | 372 | " sw_batch_size = 4\n",
|
373 |
| - " \n", |
| 373 | + "\n", |
374 | 374 | " for idx, sample in enumerate(data_list[:10]):\n",
|
375 | 375 | " start = timer()\n",
|
376 | 376 | " data = infer_transforms({\"image\": sample})\n",
|
|
474 | 474 | " all_df = pd.merge(all_df, df, on=\"file_name\", how=\"left\")\n",
|
475 | 475 | "\n",
|
476 | 476 | "# for each file, add it's size\n",
|
477 |
| - "all_df[\"file_size\"] = all_df[\"file_name\"].apply(lambda x: os.path.getsize(os.path.join(root_dir, \"Task03_Liver\", \"imagesTs_nii\", x)))\n", |
| 477 | + "all_df[\"file_size\"] = all_df[\"file_name\"].apply(\n", |
| 478 | + " lambda x: os.path.getsize(os.path.join(root_dir, \"Task03_Liver\", \"imagesTs_nii\", x))\n", |
| 479 | + ")\n", |
478 | 480 | "# sort by file size\n",
|
479 | 481 | "all_df = all_df.sort_values(by=\"file_size\", ascending=True)\n",
|
480 | 482 | "# convert file size to MB\n",
|
|
538 | 540 | ],
|
539 | 541 | "source": [
|
540 | 542 | "print(\"TensorRT Improvement: \", (total_time[\"original_time\"] - total_time[\"trt_time\"]) / total_time[\"original_time\"])\n",
|
541 |
| - "print(\"TensorRT + GPU Transforms Improvement: \", (total_time[\"original_time\"] - total_time[\"trt_gpu_transforms_time\"]) / total_time[\"original_time\"])\n", |
542 |
| - "print(\"TensorRT + GDS + GPU Transforms Improvement: \", (total_time[\"original_time\"] - total_time[\"trt_gds_gpu_transforms_time\"]) / total_time[\"original_time\"])" |
| 543 | + "print(\n", |
| 544 | + " \"TensorRT + GPU Transforms Improvement: \",\n", |
| 545 | + " (total_time[\"original_time\"] - total_time[\"trt_gpu_transforms_time\"]) / total_time[\"original_time\"],\n", |
| 546 | + ")\n", |
| 547 | + "print(\n", |
| 548 | + " \"TensorRT + GDS + GPU Transforms Improvement: \",\n", |
| 549 | + " (total_time[\"original_time\"] - total_time[\"trt_gds_gpu_transforms_time\"]) / total_time[\"original_time\"],\n", |
| 550 | + ")" |
543 | 551 | ]
|
544 | 552 | },
|
545 | 553 | {
|
|
562 | 570 | "total_time.index = [\"pytorch_model\", \"TensorRT\", \"TensorRT_GPU_Transform\", \"TensorRT_GPU_Transform_GDS\"]\n",
|
563 | 571 | "\n",
|
564 | 572 | "plt.figure(figsize=(10, 6))\n",
|
565 |
| - "total_time.plot(kind='bar', color=['skyblue', 'orange', 'green', 'red'])\n", |
566 |
| - "plt.title('Total Inference Time for Each Benchmark Type')\n", |
567 |
| - "plt.xlabel('Benchmark Type')\n", |
568 |
| - "plt.ylabel('Total Time (seconds)')\n", |
| 573 | + "total_time.plot(kind=\"bar\", color=[\"skyblue\", \"orange\", \"green\", \"red\"])\n", |
| 574 | + "plt.title(\"Total Inference Time for Each Benchmark Type\")\n", |
| 575 | + "plt.xlabel(\"Benchmark Type\")\n", |
| 576 | + "plt.ylabel(\"Total Time (seconds)\")\n", |
569 | 577 | "plt.xticks(rotation=45)\n",
|
570 | 578 | "plt.tight_layout()\n",
|
571 | 579 | "plt.show()"
|
|
0 commit comments