Closed zhenghan408 closed 3 years ago
Hi @zhenghan408 , thanks for attention!
Seems that you are training on a dataset for building. I think you need to prepare your dataset following the COCO format, and then register it, afterwards specifying the dataset in your training config .yaml
file.
Hi @zhenghan408 , thanks for attention! Seems that you are training on a dataset for building. I think you need to prepare your dataset following the COCO format, and then register it, afterwards specifying the dataset in your training config
.yaml
file.
hi,thanks very much!however ,i face another question: ERROR [07/10 16:13:04 d2.engine.train_loop]: Exception during training: Traceback (most recent call last): File "/media/dxy/EE36CE0236CDCBB1/zh/detectron2/detectron2/engine/train_loop.py", line 132, in train self.run_step() File "/media/dxy/EE36CE0236CDCBB1/zh/detectron2/detectron2/engine/train_loop.py", line 214, in run_step loss_dict = self.model(data) File "/home/dxy/anaconda3/envs/dance/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(*input, *kwargs) File "/media/dxy/EE36CE0236CDCBB1/zh/dance-master/core/modeling/edge_snake/dance.py", line 140, in forward features, proposals, (gt_sem_seg, [gt_instances, images.image_sizes]) File "/home/dxy/anaconda3/envs/dance/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(input, kwargs) File "/media/dxy/EE36CE0236CDCBB1/zh/dance-master/core/modeling/edge_snake/edge_det.py", line 273, in forward edge_loss = self.loss(pred_edge_full, edge_target) self.loss_weight File "/home/dxy/anaconda3/envs/dance/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(input, kwargs) File "/media/dxy/EE36CE0236CDCBB1/zh/dance-master/core/layers/losses.py", line 121, in forward if len(target.size()) == 3: AttributeError: 'NoneType' object has no attribute 'size' [07/10 16:13:04 d2.engine.hooks]: Total training time: 0:00:02 (0:00:00 on hooks)
can you give some suggestions?beg you~
Seems that you did not have the edge map for edge supervision. Can please try to use the scripts to generate the object contour map based on the mask annotation first? The example code is here: https://github.com/lkevinzc/dance/blob/master/datasets/prepare_edge_map_cityscapes.py
Seems that you did not have the edge map for edge supervision. Can please try to use the scripts to generate the object contour map based on the mask annotation first? The example code is here: https://github.com/lkevinzc/dance/blob/master/datasets/prepare_edge_map_cityscapes.py
i did this ,however,then ,Do I need to modify anything?because ,i have the contour map but the error no change
i use the command:python train_net.py --num-gpus 1 --config-file configs/Dance_R_50_3x.yaml
You may need to modify the config file to add your dataset like this:
_BASE_: "Base-DANCE.yaml"
MODEL:
WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl"
RESNETS:
DEPTH: 50
EDGE_HEAD:
NAME: "EdgeSnakeFPNHead"
CONVS_DIM: 256
STRONG_FEAT: True
IN_FEATURES: ['p2', 'p3', 'p4', 'p5']
SNAKE_HEAD:
NUM_SAMPLING: 196
DETACH: True
INITIAL: 'box'
NEW_MATCHING: True
ATTENTION: True
INDIVIDUAL_SCALE: True
DATASETS: # <----------------------------------------- modification!
TRAIN: ("your_dataset_train",)
TEST: ("your_dataset_test",)
SOLVER:
STEPS: (480000, 520000)
MAX_ITER: 540000
CHECKPOINT_PERIOD: 60000
OUTPUT_DIR: "output/coco/dance_r50_3x/"
Then, you also need to register your dataset by modifying core/data/builtin.py
. You can check the Detectron2 tutorial for this.
It may take some time to learn the Detectron2 framework, but after you get familiar with it you can do a lot with it :)
''' Register COCO dataset with edge map annotations '''
SPLITS_COCO_W_EDGE = { "zh_train": (
"coco/train2017",
"coco/annotations/instances_train2017.json",
# directory for edge map created by datasets/prepare_edge_map.py
# takes ~ 12 mins on a machine with 64 Xeon(R) Gold 6130 CPUs
"coco/edge_train2017"
),
"zh_val": (
"coco/val2017",
"coco/annotations/instances_val2017.json",
"/coco/edge_val2017"
),
}
def register_all_coco_edge(root="datasets"): for name, (image_root, json_file, edge_root) in SPLITS_COCO_W_EDGE.items():
./datasets
. register_coco_edge_map(
name,
_get_builtin_metadata("coco"),
os.path.join(root, image_root),
os.path.join(root, edge_root),
os.path.join(root, json_file) if "://" not in json_file else json_file
)
register_all_coco_edge()
You may need to modify the config file to add your dataset like this:
_BASE_: "Base-DANCE.yaml" MODEL: WEIGHTS: "detectron2://ImageNetPretrained/MSRA/R-50.pkl" RESNETS: DEPTH: 50 EDGE_HEAD: NAME: "EdgeSnakeFPNHead" CONVS_DIM: 256 STRONG_FEAT: True IN_FEATURES: ['p2', 'p3', 'p4', 'p5'] SNAKE_HEAD: NUM_SAMPLING: 196 DETACH: True INITIAL: 'box' NEW_MATCHING: True ATTENTION: True INDIVIDUAL_SCALE: True DATASETS: # <----------------------------------------- modification! TRAIN: ("your_dataset_train",) TEST: ("your_dataset_test",) SOLVER: STEPS: (480000, 520000) MAX_ITER: 540000 CHECKPOINT_PERIOD: 60000 OUTPUT_DIR: "output/coco/dance_r50_3x/"
Then, you also need to register your dataset by modifying
core/data/builtin.py
. You can check the Detectron2 tutorial for this.It may take some time to learn the Detectron2 framework, but after you get familiar with it you can do a lot with it :)
after i register my datasets , the new problem:
Traceback (most recent call last):
File "train_net.py", line 82, in
Hi @zhenghan408 , it still seems to be the dataset registration issue. I would suggest that you use any model in Detectron2 first and follow the tutorial to successfully train on your dataset, then running DANCE using similar registration codes should be fine.
Hi @zhenghan408 , it still seems to be the dataset registration issue. I would suggest that you use any model in Detectron2 first and follow the tutorial to successfully train on your dataset, then running DANCE using similar registration codes should be fine.
thanks a lot ,i want to ask a simple question: i use the code :https://github.com/lkevinzc/dance/blob/master/datasets/prepare_edge_map_cityscapes.py do i also use the code:https://github.com/lkevinzc/dance/blob/master/datasets/prepare_edge_map.py
Hi @zhenghan408 , it still seems to be the dataset registration issue. I would suggest that you use any model in Detectron2 first and follow the tutorial to successfully train on your dataset, then running DANCE using similar registration codes should be fine.
thanks a lot ,i want to ask a simple question: i use the code :https://github.com/lkevinzc/dance/blob/master/datasets/prepare_edge_map_cityscapes.py do i also use the code:https://github.com/lkevinzc/dance/blob/master/datasets/prepare_edge_map.py
Hi @zhenghan408 , actually they are a bit different. The "prepare_edge_map_cityscapes.py" one is for data that is in COCO format; the "prepare_edge_map.py" further requires panoptic annotation (that's why you can see this import).
If your data is in COCO format but does not have panoptic annotation, just use the first one :)
when i training my own dataset ,have the problem about: AssertionError: Attribute 'thing_classes' in the metadata of 'coco_2017_train_edge' cannot be set to a different value!
['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush'] != ['building']
please give a suggestion~