|
9 | 9 | from models import get_model_instance_segmentation |
10 | 10 | from misc_utils import get_dataloaders, sample_images |
11 | 11 | import torch |
| 12 | +from draw_image import instance_segmentation_api |
12 | 13 | # from PIL import Image |
13 | 14 | import argparse |
14 | 15 |
|
|
19 | 20 | opt = parser.parse_args() |
20 | 21 |
|
21 | 22 | opt.model_name='maskrcnn_250.pth' |
22 | | -opt.path2model= 'C:/MyPrograms/t-HPC-results/mask_rcnn-Mar-30-at-3-18/' |
| 23 | +#opt.path2model= 'C:/MyPrograms/t-HPC-results/mask_rcnn-Mar-30-at-3-18/' |
| 24 | +# opt.path2model ='C:/MyPrograms/t-HPC-results/mrcn_no_bkgrnd/' |
| 25 | +opt.path2model ='C:/MyPrograms/t-HPC-results/mrcnn_prsn_detect/' |
23 | 26 | opt.HPC_run = 0 |
24 | | -opt.remove_background = 1 |
25 | | -opt.person_detection = 0 |
| 27 | +opt.remove_background = False |
| 28 | +opt.person_detection = True |
26 | 29 | opt.train_percentage = 0.5 |
27 | 30 | opt.batch_size = 1 |
28 | | -opt.train_shuffle = 0 |
| 31 | +opt.train_shuffle = False |
29 | 32 | opt.n_cpu=0 |
30 | 33 | opt.cuda = False # this will definetly work on the cpu if it is false |
31 | 34 |
|
| 35 | +folder_name = '/my' |
| 36 | +image_name = 'myimage' |
| 37 | + |
| 38 | +image_path = folder_name+image_name |
| 39 | + |
| 40 | + |
32 | 41 | device = torch.device('cuda' if opt.cuda else 'cpu') |
33 | | -model = get_model_instance_segmentation( number_of_classes(opt.dataset_name) ) |
| 42 | + |
| 43 | +model = get_model_instance_segmentation( number_of_classes(opt) ) |
34 | 44 | print("loading model", opt.model_name ) |
35 | 45 | model.load_state_dict(torch.load(opt.path2model+opt.model_name, map_location=device )) |
36 | 46 | model.eval() |
37 | | -data_loader, data_loader_test = get_dataloaders(opt) |
| 47 | +instance_segmentation_api(model, folder_name+image_name) |
| 48 | + |
38 | 49 |
|
39 | | -for i in range(3): # range( len(data_loader_test)): # let's just check a couple of images |
40 | | - images, targets = next(iter(data_loader_test)) # get image(s) |
41 | | - sample_images(images, targets, model, device) |
42 | 50 |
|
43 | 51 |
|
44 | 52 |
|
|
0 commit comments