aim-uofa / AdelaiDet

AdelaiDet is an open source toolbox for multiple instance-level detection and recognition tasks.
https://git.io/AdelaiDet
Other
3.37k stars 646 forks source link

关于condinst训练问题,不能预测 #378

Open hustzlb opened 3 years ago

hustzlb commented 3 years ago

我是用自己做的coco数据集,我的数据集只有4类,我并没有引入新的扩展数据集,直接按照coco的格式放到默认数据集下,然后在adet/config/defaults.py中将所有分类为80的换成4,在D2/d2/data/builtin_meta.py中COCO_CATEGORIES = 改成我自己的,assert len(thing_ids) == 80, len(thing_ids)这些也改成4,训练能跑起来,跑了25000圈,我用demo测试,结果啥都测不出来,还有哪些地方需要改呢?还是我改错了?有哪位大神告诉我一下!

jiafeier commented 3 years ago

Detectron2官方给的示例代码有添加自定义COCO数据集的方法,不需要去改代码https://colab.research.google.com/drive/16jcaJoc6bCFAQ96jDe2HwtXj7BMD_-m5#scrollTo=PIbAM2pv-urF,使用register_coco_instances注册就行了。

hustzlb commented 3 years ago

Detectron2官方给的示例代码有添加自定义COCO数据集的方法,不需要去改代码https://colab.research.google.com/drive/16jcaJoc6bCFAQ96jDe2HwtXj7BMD_-m5#scrollTo=PIbAM2pv-urF,使用register_coco_instances注册就行了。

谢谢,昨晚我试了一下,我是这样弄的:

if your dataset is in COCO format, this cell can be replaced by the following three lines:

from detectron2.data.datasets import register_coco_instances register_coco_instances("my_dataset_train", {}, "./datasets/coco/annotations/instances_train2017.json", "./datasets/coco/train2017") register_coco_instances("my_dataset_val", {}, "json_annotation_val.json", "datasets/coco")

from detectron2.structures import BoxMode

import torch, torchvision

Some basic setup:

Setup detectron2 logger

import detectron2 from detectron2.utils.logger import setup_logger setup_logger()

import some common libraries

import numpy as np import os, json, cv2, random

import some common detectron2 utilities

from detectron2 import model_zoo from detectron2.engine import DefaultPredictor from detectron2.config import get_cfg from detectron2.utils.visualizer import Visualizer from detectron2.data import MetadataCatalog, DatasetCatalog

import time

MetadataCatalog.get("my_dataset_train").thing_classes = ["crack", "desquamation", "scratch", "edgeCrack"] from detectron2.engine import DefaultTrainer

cfg = get_cfg()

cfg.OUTPUT_DIR='/data-output'

cfg.merge_from_file(model_zoo.get_config_file("COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml")) cfg.DATASETS.TRAIN = ("my_dataset_train",) cfg.DATASETS.TEST = () cfg.DATALOADER.NUM_WORKERS = 2 cfg.MODEL.WEIGHTS = model_zoo.get_checkpoint_url("COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml") # Let training initialize from model zoo cfg.SOLVER.IMS_PER_BATCH = 8 cfg.SOLVER.BASE_LR = 0.00025 # pick a good LR cfg.SOLVER.MAX_ITER = 300 # 300 iterations seems good enough for this toy dataset; you will need to train longer for a practical dataset cfg.SOLVER.STEPS = [] # do not decay learning rate cfg.MODEL.ROI_HEADS.BATCH_SIZE_PER_IMAGE = 128 # faster, and good enough for this toy dataset (default: 512) cfg.MODEL.ROI_HEADS.NUM_CLASSES = 4 # only has one class (ballon). (see https://detectron2.readthedocs.io/tutorials/datasets.html#update-the-config-for-new-datasets)

NOTE: this config means the number of classes, but a few popular unofficial tutorials incorrect uses num_classes+1 here.

os.makedirs(cfg.OUTPUT_DIR, exist_ok=True) trainer = DefaultTrainer(cfg) trainer.resume_or_load(resume=False) trainer.train()

训练指令 CUDA_VISIBLE_DEVICES=1,2 OMP_NUM_THREADS=1 python my_datasets.py

最后几部生成是这样的: [05/28 21:15:04 d2.utils.events]: eta: 0:00:00 iter: 299 total_loss: 0.6836 loss_cls: 0.1688 loss_box_reg: 0.3225 loss_mask: 0.1392 loss_rpn_cls: 0.004659 loss_rpn_loc: 0.03857 time: 1.1746 data_time: 0.4707 lr: 0.00024917 max_mem: 5840M [05/28 21:15:04 d2.engine.hooks]: Overall training speed: 298 iterations in 0:05:50 (1.1746 s / it) [05/28 21:15:04 d2.engine.hooks]: Total training time: 0:05:51 (0:00:01 on hooks) Segmentation fault

测试指令: CUDA_VISIBLE_DEVICES=1,2 python demo/demo.py --config-file mask_rcnn_R_50_FPN_3x.yaml --input 51.jpg 55jpg --opts MODEL.WEIGHTS output/model_final.pth [05/29 10:47:44 detectron2]: Arguments: Namespace(confidence_threshold=0.3, config_file='mask_rcnn_R_50_FPN_3x.yaml', input=['51.jpg', '55jpg'], opts=['MODEL.WEIGHTS', 'output/model_final.pth'], output=None, video_input=None, webcam=False) Traceback (most recent call last): File "demo/demo.py", line 73, in cfg = setup_cfg(args) File "demo/demo.py", line 23, in setup_cfg cfg.merge_from_file(args.config_file) File "/home/zhanglibin/detectron2/detectron2/config/config.py", line 31, in merge_from_file loaded_cfg = self.load_yaml_with_base(cfg_filename, allow_unsafe=allow_unsafe) File "/home/zhanglibin/anaconda3/envs/ADet/lib/python3.7/site-packages/fvcore/common/config.py", line 61, in load_yaml_with_base cfg = yaml.safe_load(f) File "/home/zhanglibin/anaconda3/envs/ADet/lib/python3.7/site-packages/yaml/init.py", line 162, in safe_load return load(stream, SafeLoader) File "/home/zhanglibin/anaconda3/envs/ADet/lib/python3.7/site-packages/yaml/init.py", line 114, in load return loader.get_single_data() File "/home/zhanglibin/anaconda3/envs/ADet/lib/python3.7/site-packages/yaml/constructor.py", line 49, in get_single_data node = self.get_single_node() File "/home/zhanglibin/anaconda3/envs/ADet/lib/python3.7/site-packages/yaml/composer.py", line 36, in get_single_node document = self.compose_document() File "/home/zhanglibin/anaconda3/envs/ADet/lib/python3.7/site-packages/yaml/composer.py", line 58, in compose_document self.get_event() File "/home/zhanglibin/anaconda3/envs/ADet/lib/python3.7/site-packages/yaml/parser.py", line 118, in get_event self.current_event = self.state() File "/home/zhanglibin/anaconda3/envs/ADet/lib/python3.7/site-packages/yaml/parser.py", line 193, in parse_document_end token = self.peek_token() File "/home/zhanglibin/anaconda3/envs/ADet/lib/python3.7/site-packages/yaml/scanner.py", line 129, in peek_token self.fetch_more_tokens() File "/home/zhanglibin/anaconda3/envs/ADet/lib/python3.7/site-packages/yaml/scanner.py", line 223, in fetch_more_tokens return self.fetch_value() File "/home/zhanglibin/anaconda3/envs/ADet/lib/python3.7/site-packages/yaml/scanner.py", line 579, in fetch_value self.get_mark()) yaml.scanner.ScannerError: mapping values are not allowed here in "mask_rcnn_R_50_FPN_3x.yaml", line 101, column 65

能帮我分析一下是什么原因吗?

ALmagical commented 3 years ago

from detectron2.data.datasets import register_coco_instances register_coco_instances("my_dataset_train", {}, "./datasets/coco/annotations/instances_train2017.json", "./datasets/coco/train2017") register_coco_instances("my_dataset_val", {}, "json_annotation_val.json", "datasets/coco")

你可以试试把这个加到train_net.py 前面

Yszzz-z commented 2 years ago

我是用自己做的coco数据集,我的数据集只有4类,我并没有引入新的扩展数据集,直接按照coco的格式放到默认数据集下,然后在adet/config/defaults.py中将所有分类为80的换成4,在D2/d2/data/builtin_meta.py中COCO_CATEGORIES = 改成我自己的,assert len(thing_ids) == 80, len(thing_ids)这些也改成4,训练能跑起来,跑了25000圈,我用demo测试,结果啥都测不出来,还有哪些地方需要改呢?还是我改错了?有哪位大神告诉我一下!

你好,请问你的问题解决了没有,能用condinst预测了么

hustzlb commented 2 years ago

我的能运行起来,但是效果并没有论文里说的那么好,我觉着远不如mask rcnn,修改参数的话,我刚你找找我是怎么改的,你等我上午面试完的

发自我的 iPhone

在 2021年9月27日,上午9:42,Yszzz-z @.***> 写道:

我是用自己做的coco数据集,我的数据集只有4类,我并没有引入新的扩展数据集,直接按照coco的格式放到默认数据集下,然后在adet/config/defaults.py中将所有分类为80的换成4,在D2/d2/data/builtin_meta.py中COCO_CATEGORIES = 改成我自己的,assert len(thing_ids) == 80, len(thing_ids)这些也改成4,训练能跑起来,跑了25000圈,我用demo测试,结果啥都测不出来,还有哪些地方需要改呢?还是我改错了?有哪位大神告诉我一下!

你好,请问你的问题解决了没有,能用condinst预测了么

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

Yszzz-z commented 2 years ago

我的能运行起来,但是效果并没有论文里说的那么好,我觉着远不如mask rcnn,修改参数的话,我刚你找找我是怎么改的,你等我上午面试完的 发自我的 iPhone 在 2021年9月27日,上午9:42,Yszzz-z @.***> 写道: 我是用自己做的coco数据集,我的数据集只有4类,我并没有引入新的扩展数据集,直接按照coco的格式放到默认数据集下,然后在adet/config/defaults.py中将所有分类为80的换成4,在D2/d2/data/builtin_meta.py中COCO_CATEGORIES = 改成我自己的,assert len(thing_ids) == 80, len(thing_ids)这些也改成4,训练能跑起来,跑了25000圈,我用demo测试,结果啥都测不出来,还有哪些地方需要改呢?还是我改错了?有哪位大神告诉我一下! 你好,请问你的问题解决了没有,能用condinst预测了么 — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

我的能运行起来,但是效果并没有论文里说的那么好,我觉着远不如mask rcnn,修改参数的话,我刚你找找我是怎么改的,你等我上午面试完的 发自我的 iPhone 在 2021年9月27日,上午9:42,Yszzz-z @.***> 写道: 我是用自己做的coco数据集,我的数据集只有4类,我并没有引入新的扩展数据集,直接按照coco的格式放到默认数据集下,然后在adet/config/defaults.py中将所有分类为80的换成4,在D2/d2/data/builtin_meta.py中COCO_CATEGORIES = 改成我自己的,assert len(thing_ids) == 80, len(thing_ids)这些也改成4,训练能跑起来,跑了25000圈,我用demo测试,结果啥都测不出来,还有哪些地方需要改呢?还是我改错了?有哪位大神告诉我一下! 你好,请问你的问题解决了没有,能用condinst预测了么 — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

请问可以留个联系方式么,能不能有偿请教一些问题

hustzlb commented 2 years ago

这个网络我研究的也不多,搭建就花了很长时间,最后跑实验感觉效果也不好,后来就没有再弄,你问的问题我可能都不会😂😂😂

发自我的 iPhone

在 2021年9月27日,上午9:52,Yszzz-z @.***> 写道:

我的能运行起来,但是效果并没有论文里说的那么好,我觉着远不如mask rcnn,修改参数的话,我刚你找找我是怎么改的,你等我上午面试完的 发自我的 iPhone … 在 2021年9月27日,上午9:42,Yszzz-z @.***> 写道: 我是用自己做的coco数据集,我的数据集只有4类,我并没有引入新的扩展数据集,直接按照coco的格式放到默认数据集下,然后在adet/config/defaults.py中将所有分类为80的换成4,在D2/d2/data/builtin_meta.py中COCO_CATEGORIES = 改成我自己的,assert len(thing_ids) == 80, len(thing_ids)这些也改成4,训练能跑起来,跑了25000圈,我用demo测试,结果啥都测不出来,还有哪些地方需要改呢?还是我改错了?有哪位大神告诉我一下! 你好,请问你的问题解决了没有,能用condinst预测了么 — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

我的能运行起来,但是效果并没有论文里说的那么好,我觉着远不如mask rcnn,修改参数的话,我刚你找找我是怎么改的,你等我上午面试完的 发自我的 iPhone … 在 2021年9月27日,上午9:42,Yszzz-z @.***> 写道: 我是用自己做的coco数据集,我的数据集只有4类,我并没有引入新的扩展数据集,直接按照coco的格式放到默认数据集下,然后在adet/config/defaults.py中将所有分类为80的换成4,在D2/d2/data/builtin_meta.py中COCO_CATEGORIES = 改成我自己的,assert len(thing_ids) == 80, len(thing_ids)这些也改成4,训练能跑起来,跑了25000圈,我用demo测试,结果啥都测不出来,还有哪些地方需要改呢?还是我改错了?有哪位大神告诉我一下! 你好,请问你的问题解决了没有,能用condinst预测了么 — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

请问可以留个联系方式么,能不能有偿请教一些问题

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

Yszzz-z commented 2 years ago

我就是在搭建和训练这里有很多问题😂

hustzlb commented 2 years ago

下午的吧,一会我要面试了

发自我的 iPhone

在 2021年9月27日,上午9:55,Yszzz-z @.***> 写道:

我就是在搭建和训练这里有很多问题😂

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

Yszzz-z commented 2 years ago

好滴

hustzlb commented 2 years ago

你把你联系方式发给我一份

发自我的 iPhone

在 2021年9月27日,上午9:57,Yszzz-z @.***> 写道:

好滴

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

baimaoyoumo commented 2 years ago

我的能跑起来,效果并没有论文里说的那么好,我觉着远不如面具 rcnn,修改参数的话,我刚你找我是怎么改的,你等我早上面试的发完自我的苹果手机 在 2021年9月27日,上午9:42,Yszzz-z @.***> 写道: 我是用自己做的coco数据集,我的数据集只有4类,我并没有引入新的扩展数据集,直接按照coco的格式放到默认数据集下,然后在adet/config/defaults.py中将所有分类为80的换成4,在D2/d2/data/builtin_meta.py中COCO_CATEGORIES = 改成我自己的,assert len(thing_ids) == 80, len(thing_ids)这些也改成4,训练能跑起来,跑了25000圈,我用demo测试,结果啥都测不出来,还有哪些地方需要改呢?还是我改错了?有哪位大神告诉我一下! 你好,请问你的问题解决了没有,能用condinst预测了么 — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

我也遇到了condinst的效果没有maskrcnn好的效果,请问您这个问题解决了吗?

hustzlb commented 2 years ago

没有呀,没再弄,本来打算写在论文里,后来时间来不及就不弄了,从此再也不会做图像了,我毕业了,哈哈哈哈

发自我的 iPhone

在 2022年4月12日,下午2:55,baimaoyoumo @.***> 写道:

我的能跑起来,效果并没有论文里说的那么好,我觉着远不如面具 rcnn,修改参数的话,我刚你找我是怎么改的,你等我早上面试的发完自我的苹果手机 … 在 2021年9月27日,上午9:42,Yszzz-z @.***> 写道: 我是用自己做的coco数据集,我的数据集只有4类,我并没有引入新的扩展数据集,直接按照coco的格式放到默认数据集下,然后在adet/config/defaults.py中将所有分类为80的换成4,在D2/d2/data/builtin_meta.py中COCO_CATEGORIES = 改成我自己的,assert len(thing_ids) == 80, len(thing_ids)这些也改成4,训练能跑起来,跑了25000圈,我用demo测试,结果啥都测不出来,还有哪些地方需要改呢?还是我改错了?有哪位大神告诉我一下! 你好,请问你的问题解决了没有,能用condinst预测了么 — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

我也遇到了condinst的效果没有maskrcnn好的效果,请问您这个问题解决了吗?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.