Hi~ I'm currently transforming pascal voc format to coco format for only object detection. But I run the command below:
python2 tools/train_net.py \
--cfg configs/getting_started/tutorial_1gpu_e2e_faster_rcnn_R-50-FPN.yaml \
OUTPUT_DIR /tmp/detectron-output
And I got the error like this.
The final error message is:
File "/home/mq/caffe2/build/caffe2/python/workspace.py", line 189, in CallWithExceptionIntercept
return func(*args, **kwargs)
RuntimeError: [enforce fail at pybind_state.cc:867] success. Error running net generalized_rcnn
In my /home/m/detectron/lib/datasets/data/coco/annotations folder I have instances_minival2014.json, 'instances_train2014.json', 'instances_valminusminival2014.json'. The file names are right? So I think it's the content in the Json files caused the problem. And in the Json file I have
{
"annotations": [
{
"area": 1666,
"bbox": [
489,
382,
34,
49
],
"category_id": 1,
"id": 1,
"ignore": 0,
"image_id": 1,
"iscrowd": 0,
"segmentation": [
[
489,
382,
489,
431,
523,
431,
523,
382
]
]
},
{
"area": 1120,
"bbox": [
391,
322,
28,
40
],
"category_id": 1,
"id": 2,
"ignore": 0,
"image_id": 1,
"iscrowd": 0,
"segmentation": [
[
391,
322,
391,
362,
419,
362,
419,
322
]
]
}
],
"categories": [
{
"id": 1,
"name": "head",
"supercategory": "none"
},
{
"id": 2,
"name": "person",
"supercategory": "none"
}
],
"images": [
{
"file_name": "02480220171101071303.jpg",
"height": 576,
"id": 1,
"width": 704
},
{
"file_name": "02473620171101063102.jpg",
"height": 576,
"id": 2,
"width": 704
}
],
"type": "instances"
}
I follow the format from here. I believe they are alright except the order of these nodes. Is that right? Any help will be appreciated. Thanks!
The json format is alright. It's because the "file_name" in it different from my image file caused the problem.
Hello, what should I do?Ransform from pascal voc format to coco format for object detection锛宼hanks
@ZSSNIKE, I used a script which was mentioned here.
@v-ilin did the script work well? How was your xml files arranged before?
@BanuSelinTosun it worked well. Just put a folder 'annotations' with XML files near the script and run it. It will compose a result file 'instances.json'.
@v-ilin you mean all my put all my xml files in annotations folder, right?
My other question is, this is presumable for training and validation, how can we run the test results like the coco test? Would it be possible?
@BanuSelinTosun you are right.
When you are setting up a config file you can specify a test dataset which will be used for validation when a training will end, so you need two JSON files with annotations - train, val.
@v-ilin Thank you v-ilin. I downloaded the coco dataset and run a training using those, however it has a lot of json files, not just 1 for train and 1 for val. It is a bit confusing or empirical since I have not seen any clear directions on how to train this system (I am using a docker image in a Linux VM). Do you suggest any detailed documentation on how to utilize detectron and train it?
Thank you,
Selin
@BanuSelinTosun I am using the docker image too. A little example of how to run a train is described here. You need to add a config file in which you have to specify a train dataset. All datasets are configured in dataset_catalog.py and each of it is described by one annotation file.
@v-ilin
Thank you.
I have seen the 1st link you send, and it did work to get my model. But I am not sure what are the next steps? Which file I need to add my images to get the inference from? How do I add a config file? Is it just adding the lines for the name of the data set and the annotation file to that python file? If not, where do I get the config files? Or how do I write one?
Additionally, this is for entire Detectron Community:
It seems to me that Object Detection API is easier to use and easier to utilize.
What is the advantage of Detectron other than the mask predictions? How do we obtain the human pose predictions?
Sincerely,
Selin
@BanuSelinTosun An example of how to run inference is described here. Instead of pretrained weights use your trained model as a parameter --wts. Also you need to specify a config file (.yml). Create a new file based on existing configs, specify a dataset name and use it while training and inference.
@v-ilin "it worked well. Just put a folder 'annotations' with XML files near the script and run it. It will compose a result file 'instances.json'."
Awesome @v-ilin. You solved all my problems on this format conversion from Pascal_voc to Detectron COCO formatting! Just an issue: when I run the script, it asks for the folder 'Annotations'.
Next we want to train our own detector on a custom dataset using it. Any other tip for its implementation with Detectron using the Caffe2 libraries? We have 200 classes instead of 80.
We won't do transfer learning (we'll fit/train our own model, calculating new weights), but we want to
use Detectron to gain in efficiency and scalability.
In short, Is it only necessary to 1.- convert the dataset to COCO format (train & val), 2.- change the number of classes (from 80 [COCO data set] to 200 [custom data set]), the only changes required in order to be able to use Detectron for object detection with bounding boxes (no mask atm), or is there any other important step to do?
@Jalagarto also you have to add info about your datasets (paths to directories and json files) to file dataset_catalog.py and then specify datasets names in the config file (.yml) in TRAIN.DATASETS and TEST.DATASETS.
When you will run inference (it may or not be automatically after training) it will take names of classes from dummy_datasets.py so I changed it to get my class names on images.
You can specify a value of TRAIN.SNAPSHOT_ITERS. It's a model checkpoint period and as said in core/config.py it depends on number of GPUs. I used only 1 GPU and also decreased the value to save a model more frequently.
Most helpful comment
@v-ilin Thank you v-ilin. I downloaded the coco dataset and run a training using those, however it has a lot of json files, not just 1 for train and 1 for val. It is a bit confusing or empirical since I have not seen any clear directions on how to train this system (I am using a docker image in a Linux VM). Do you suggest any detailed documentation on how to utilize detectron and train it?
Thank you,
Selin