Skip to content

Commit 0c21ec6

Browse files
committed
add coco dataloader
1 parent 00f10e6 commit 0c21ec6

File tree

2 files changed

+391
-357
lines changed

2 files changed

+391
-357
lines changed

config.py

+17-19
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from deepvac import AttrDict, new
55

6-
from data.dataloader import DBTrainDataset, DBTestDataset
6+
from data.dataloader import DBTrainDataset, DBTrainCocoDataset, DBTestDataset
77
from modules.model_db import Resnet18DB, Mobilenetv3LargeDB
88
from modules.loss import DBLoss
99

@@ -27,10 +27,10 @@
2727
#config.core.DBNetTrain.tensorboard_ip = None
2828

2929
## -------------------- 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"
3434

3535
## -------------------- net and criterion ------------------
3636
config.arch = "resnet18"
@@ -49,17 +49,16 @@
4949
config.core.DBNetTrain.scheduler = optim.lr_scheduler.LambdaLR(config.core.DBNetTrain.optimizer, lr_lambda=lambda_lr)
5050

5151
## -------------------- 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'
5554
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
6059
config.core.DBNetTrain.batch_size = 8
6160
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)
6362
config.core.DBNetTrain.train_loader = torch.utils.data.DataLoader(
6463
dataset = config.core.DBNetTrain.train_dataset,
6564
batch_size = config.core.DBNetTrain.batch_size,
@@ -70,11 +69,10 @@
7069
)
7170

7271
## -------------------- 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'
7674
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)
7876
config.core.DBNetTrain.val_loader = torch.utils.data.DataLoader(
7977
dataset = config.core.DBNetTrain.val_dataset,
8078
batch_size = 1,
@@ -85,10 +83,10 @@
8583

8684
## -------------------- test ------------------
8785
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'
8987
# config.core.DBNetTest.jit_model_path = 'your torchscript model path'
9088
config.core.DBNetTest.is_output_polygon = True
91-
config.sample_path = 'your test image dir'
89+
config.sample_path = 'your test images path'
9290
config.core.DBNetTest.test_dataset = DBTestDataset(config, config.sample_path, long_size = 1280)
9391
config.core.DBNetTest.test_loader = torch.utils.data.DataLoader(
9492
dataset = config.core.DBNetTest.test_dataset,

0 commit comments

Comments
 (0)