yuantailing / ctw-baseline

Baseline methods for [CTW dataset](https://ctwdataset.github.io/)
MIT License
329 stars 88 forks source link

Can you provide deploy.prototxt of SSD model please? #8

Closed panyan928 closed 6 years ago

panyan928 commented 6 years ago

Hello, I want to detect my images using SDD model you trained, but I can't find deploy.prototxt. Can you provide ? Thank you very much.

yuantailing commented 6 years ago

SSD prototxt is generated by ssd/ssd_hardcode/ssd_pascal_512.py. Run touch products/VGG_ILSVRC_16_layers_fc_reduced.caffemodel products/val.txt && python3 train.py and you will get everything.

Run cp ../data/annotations/downloads/train.jsonl ../data/annotations/downloads/val.jsonl ../data/annotations/ && python3 decide_cates.py and you will get products/cates.json, the map from label ID to character category.

Please let me know if you have problem using trained models.

panyan928 commented 6 years ago

I don't want to run train, I just detect images.
I have got cates.json. When I run eval.py, it shows no deploy.prototxt F0328 06:13:51.207175 24 io.cpp:45] Check failed: fd != -1 (-1 vs. -1) File not found: products/models/SSD_512x512/deploy.prototxt

yuantailing commented 6 years ago

Run train to generate prototxt, and then CTRL+C.

panyan928 commented 6 years ago

Okay,I will try. Thank you very much.

panyan928 commented 6 years ago

Sorry, I met another problem. It needs labelmap.prototxt.

yuantailing commented 6 years ago

Call function write_caffe_labelmap, which is in ssd/prepare_train_data.py. Sorry so many problems in the tutorial, I will update it and address all problems you met.

panyan928 commented 6 years ago

Hi, I find another problem. After run prepare_train_data.py, It showsname_size_file: "products/val_name_size.txt" in deploy.prototxt. But when test, we need test_name_size.txt, it isn't created in your code. Maybe you can write test.py not eval.py for test if have time.

yuantailing commented 6 years ago

val_name_size.txt is only used in training steps, just touch this file. Maybe test_name_size is not necessary.

panyan928 commented 6 years ago

I didn't download your train data, so after runprepare_train_data.py, val_name_size.txt is empty. When I run eval.py, caffe errors, as follows: F0329 02:41:16.516167 266 detection_output_layer.cpp:98] Check failed: num_test_image_ <= names_.size() (1000 vs. 0)

So I go to check detection_output_layer

if (save_output_param.has_name_size_file()) { string name_size_file = save_output_param.name_size_file(); if (name_size_file.empty()) { // Ignore saving if there is no name_size_file provided. LOG(WARNING) << "Provide name_size_file if output results to files."; needsave = false; } else { std::ifstream infile(name_size_file.c_str()); CHECK(infile.good()) << "Failed to open name size file: " << name_sizefile; // The file is in the following format: // name height width // ... string name; int height, width; while (infile >> name >> height >> width) { names.pushback(name); sizes.push_back(std::make_pair(height, width)); } infile.close(); if (save_output_param.has_num_test_image()) { num_testimage = save_output_param.num_test_image(); } else { num_testimage = names_.size(); } CHECK_LE(num_testimage, names_.size()); } } else { needsave = false; }

It shows it needs image sizes.

yuantailing commented 6 years ago

The idea is to replace training data with an fake empty data, and produce everything you need. Here is the full solution I have tested:

  1. cp ../data/annotations/downloads/train.jsonl ../data/annotations/downloads/val.jsonl ../data/annotations/ && python3 decide_cates.py
  2. echo '{"train":[],"val":[],"test_cls":[],"test_det":[{"image_id":"0000001","file_name":"0000001.jpg"}]}' >../data/annotations/info.json
  3. head ../data/annotations/downloads/train.jsonl -n1 >../data/annotations/train.jsonl, head ../data/annotations/downloads/val.jsonl -n1 >../data/annotations/val.jsonl
  4. python3 prepare_train_data.py, touch products/VGG_ILSVRC_16_layers_fc_reduced.caffemodel && python3 train.py, These 2 commands will result in failure, but .prototxt you need have been generated.
  5. restore trained model to products/models/SSD_512x512/
  6. python3 prepare_test_data.py
  7. python3 eval.py
  8. python3 merge_results.py

Please let me know if you have problem with this solution.

panyan928 commented 6 years ago

Thank you for detailed steps. I have solved it successfully. The key is to change the parameter num_test_images in deploy.prototxt. It must be less than the size of val data in file val.txt, otherwise it will show errors as shown above.

findyy99 commented 4 years ago

Okay,I will try. Thank you very much.

can you share the deploy.prototxt to me use the google drive ? Thank you :)