Skip to content

Commit 8635edc

Browse files
Merge branch 'add-infer-accelerate-tutorial' of github.com:yiheng-wang-nv/tutorials into add-infer-accelerate-tutorial
2 parents f4840a7 + dc1c24f commit 8635edc

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

acceleration/fast_inference_tutorial/fast_inference_tutorial.ipynb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@
243243
},
244244
{
245245
"cell_type": "code",
246-
"execution_count": 2,
246+
"execution_count": 3,
247247
"metadata": {},
248248
"outputs": [],
249249
"source": [
@@ -270,7 +270,7 @@
270270
},
271271
{
272272
"cell_type": "code",
273-
"execution_count": 3,
273+
"execution_count": 4,
274274
"metadata": {},
275275
"outputs": [
276276
{
@@ -307,7 +307,7 @@
307307
},
308308
{
309309
"cell_type": "code",
310-
"execution_count": 4,
310+
"execution_count": 5,
311311
"metadata": {},
312312
"outputs": [],
313313
"source": [
@@ -362,7 +362,7 @@
362362
},
363363
{
364364
"cell_type": "code",
365-
"execution_count": 5,
365+
"execution_count": 6,
366366
"metadata": {},
367367
"outputs": [],
368368
"source": [
@@ -424,7 +424,7 @@
424424
},
425425
{
426426
"cell_type": "code",
427-
"execution_count": null,
427+
"execution_count": 7,
428428
"metadata": {},
429429
"outputs": [],
430430
"source": [
@@ -442,10 +442,10 @@
442442
"infer_transforms = get_transforms(device, gpu_loading_flag, gpu_transforms_flag)\n",
443443
"model = get_model(device, weights_path, trt_model_path, trt_flag)\n",
444444
"\n",
445-
"total_time_dict = run_inference(train_files, infer_transforms, model, device, benchmark_type)\n",
445+
"# total_time_dict = run_inference(train_files, infer_transforms, model, device, benchmark_type)\n",
446446
"\n",
447-
"df = pd.DataFrame(list(total_time_dict.items()), columns=[\"file_name\", \"time\"])\n",
448-
"df.to_csv(os.path.join(root_dir, f\"time_{benchmark_type}.csv\"), index=False)"
447+
"# df = pd.DataFrame(list(total_time_dict.items()), columns=[\"file_name\", \"time\"])\n",
448+
"# df.to_csv(os.path.join(root_dir, f\"time_{benchmark_type}.csv\"), index=False)"
449449
]
450450
},
451451
{
@@ -460,7 +460,7 @@
460460
},
461461
{
462462
"cell_type": "code",
463-
"execution_count": 12,
463+
"execution_count": 8,
464464
"metadata": {},
465465
"outputs": [],
466466
"source": [
@@ -502,7 +502,7 @@
502502
},
503503
{
504504
"cell_type": "code",
505-
"execution_count": 13,
505+
"execution_count": 9,
506506
"metadata": {},
507507
"outputs": [
508508
{
@@ -523,7 +523,7 @@
523523
},
524524
{
525525
"cell_type": "code",
526-
"execution_count": 15,
526+
"execution_count": 10,
527527
"metadata": {},
528528
"outputs": [
529529
{
@@ -544,7 +544,7 @@
544544
},
545545
{
546546
"cell_type": "code",
547-
"execution_count": 24,
547+
"execution_count": 11,
548548
"metadata": {},
549549
"outputs": [
550550
{
@@ -584,7 +584,7 @@
584584
},
585585
{
586586
"cell_type": "code",
587-
"execution_count": 25,
587+
"execution_count": 12,
588588
"metadata": {},
589589
"outputs": [
590590
{

acceleration/fast_inference_tutorial/run_benchmark.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,21 @@
2020
import torch_tensorrt
2121
from monai.inferers import sliding_window_inference
2222
from monai.networks.nets import SegResNet
23-
from monai.transforms import (Activationsd, AsDiscreted, Compose,
24-
EnsureChannelFirstd, EnsureTyped, Invertd,
25-
LoadImaged, NormalizeIntensityd, Orientationd,
26-
ScaleIntensityd, Spacingd)
27-
28-
from utils import (prepare_model_weights, prepare_tensorrt_model,
29-
prepare_test_datalist)
23+
from monai.transforms import (
24+
Activationsd,
25+
AsDiscreted,
26+
Compose,
27+
EnsureChannelFirstd,
28+
EnsureTyped,
29+
Invertd,
30+
LoadImaged,
31+
NormalizeIntensityd,
32+
Orientationd,
33+
ScaleIntensityd,
34+
Spacingd,
35+
)
36+
37+
from utils import prepare_model_weights, prepare_tensorrt_model, prepare_test_datalist
3038

3139

3240
def get_transforms(device, gpu_loading_flag=False, gpu_transforms_flag=False):

0 commit comments

Comments
 (0)