|
3 | 3 |
|
4 | 4 | from deepvac import AttrDict, new
|
5 | 5 |
|
6 |
| -from data.dataloader import DBTrainDataset, DBTestDataset |
| 6 | +from data.dataloader import DBTrainDataset, DBTrainCocoDataset, DBTestDataset |
7 | 7 | from modules.model_db import Resnet18DB, Mobilenetv3LargeDB
|
8 | 8 | from modules.loss import DBLoss
|
9 | 9 |
|
|
27 | 27 | #config.core.DBNetTrain.tensorboard_ip = None
|
28 | 28 |
|
29 | 29 | ## -------------------- script and quantize ------------------
|
30 |
| -config.cast.TraceCast = AttrDict() |
31 |
| -config.cast.TraceCast.model_dir = "./script.pt" |
32 |
| -# config.cast.TraceCast.static_quantize_dir = "./script.sq" # unsupported op nn.ConvTranspose2d for now |
33 |
| -config.cast.TraceCast.dynamic_quantize_dir = "./quantize.sq" |
| 30 | +config.cast.ScriptCast = AttrDict() |
| 31 | +config.cast.ScriptCast.model_dir = "./script.pt" |
| 32 | +# config.cast.ScriptCast.static_quantize_dir = "./script.sq" # unsupported op nn.ConvTranspose2d for now |
| 33 | +# config.cast.ScriptCast.dynamic_quantize_dir = "./quantize.sq" |
34 | 34 |
|
35 | 35 | ## -------------------- net and criterion ------------------
|
36 | 36 | config.arch = "resnet18"
|
|
49 | 49 | config.core.DBNetTrain.scheduler = optim.lr_scheduler.LambdaLR(config.core.DBNetTrain.optimizer, lr_lambda=lambda_lr)
|
50 | 50 |
|
51 | 51 | ## -------------------- loader ------------------
|
52 |
| -config.sample_path = 'your train image dir' |
53 |
| -config.label_path = 'your train labels dir' |
54 |
| -config.is_transform = True |
| 52 | +config.sample_path = 'your train images dir' |
| 53 | +config.label_path = 'your train coco json path' |
55 | 54 | config.img_size = 640
|
56 |
| -config.datasets.DBTrainDataset = AttrDict() |
57 |
| -config.datasets.DBTrainDataset.shrink_ratio = 0.4 |
58 |
| -config.datasets.DBTrainDataset.thresh_min = 0.3 |
59 |
| -config.datasets.DBTrainDataset.thresh_max = 0.7 |
| 55 | +config.datasets.DBTrainCocoDataset = AttrDict() |
| 56 | +config.datasets.DBTrainCocoDataset.shrink_ratio = 0.4 |
| 57 | +config.datasets.DBTrainCocoDataset.thresh_min = 0.3 |
| 58 | +config.datasets.DBTrainCocoDataset.thresh_max = 0.7 |
60 | 59 | config.core.DBNetTrain.batch_size = 8
|
61 | 60 | config.core.DBNetTrain.num_workers = 4
|
62 |
| -config.core.DBNetTrain.train_dataset = DBTrainDataset(config, config.sample_path, config.label_path, config.is_transform, config.img_size) |
| 61 | +config.core.DBNetTrain.train_dataset = DBTrainCocoDataset(config, config.sample_path, config.label_path, config.img_size) |
63 | 62 | config.core.DBNetTrain.train_loader = torch.utils.data.DataLoader(
|
64 | 63 | dataset = config.core.DBNetTrain.train_dataset,
|
65 | 64 | batch_size = config.core.DBNetTrain.batch_size,
|
|
70 | 69 | )
|
71 | 70 |
|
72 | 71 | ## -------------------- val ------------------
|
73 |
| -config.sample_path = 'your val image dir' |
74 |
| -config.label_path = 'your val labels dir' |
75 |
| -config.is_transform = True |
| 72 | +config.sample_path = 'your val images dir' |
| 73 | +config.label_path = 'your val coco json path' |
76 | 74 | config.img_size = 640
|
77 |
| -config.core.DBNetTrain.val_dataset = DBTrainDataset(config, config.sample_path, config.label_path, config.is_transform, config.img_size) |
| 75 | +config.core.DBNetTrain.val_dataset = DBTrainCocoDataset(config, config.sample_path, config.label_path, config.img_size) |
78 | 76 | config.core.DBNetTrain.val_loader = torch.utils.data.DataLoader(
|
79 | 77 | dataset = config.core.DBNetTrain.val_dataset,
|
80 | 78 | batch_size = 1,
|
|
85 | 83 |
|
86 | 84 | ## -------------------- test ------------------
|
87 | 85 | config.core.DBNetTest = config.core.DBNetTrain.clone()
|
88 |
| -config.core.DBNetTest.model_path = 'your test model dir / pretrained weights' |
| 86 | +config.core.DBNetTest.model_path = 'output/disable_git/model__2021-06-30-04-55__acc_0__epoch_34__step_182__lr_0.00042280517.pth' |
89 | 87 | # config.core.DBNetTest.jit_model_path = 'your torchscript model path'
|
90 | 88 | config.core.DBNetTest.is_output_polygon = True
|
91 |
| -config.sample_path = 'your test image dir' |
| 89 | +config.sample_path = 'your test images path' |
92 | 90 | config.core.DBNetTest.test_dataset = DBTestDataset(config, config.sample_path, long_size = 1280)
|
93 | 91 | config.core.DBNetTest.test_loader = torch.utils.data.DataLoader(
|
94 | 92 | dataset = config.core.DBNetTest.test_dataset,
|
|
0 commit comments