Code Monkey home page Code Monkey logo

betapose's Introduction

Betapose: Estimating 6D Pose From Localizing Designated Surface Keypoints

Please refer to our paper for detailed explanation. Arxiv Link is here. In the following, ROOT refers to the folder containing this README file.

0. News:

Before you running this repository, please look at this one: https://github.com/sjtuytc/segmentation-driven-pose. It's much greater because it's:

  1. RGB only.
  2. SOTA precision and speed.
  3. Multi Object.
  4. Training end-to-end instead of two-step.
  5. Code super easy to understand and fully open-source.

Ⅰ. Installation

  1. All the codes are tested in Python, CUDA 8.0 and CUDNN 5.1.
  2. Install pytorch 0.4.0 and other dependencies.
  3. Download LineMod dataset here. Only folders called models and test are needed. Put them in DATAROOT/models and DATAROOT/test where DATAROOT can be any folder you'd like to place LineMod dataset.

Ⅱ. Designate Keypoints

You can skip this step since we have provided designated keypoints files in '$ROOT/1_keypoint_designator/assets/sifts/'.

  1. The related code is in $ROOT/1_keypoint_designator/.
    $ cd ROOT/1_keypoint_designator/
  2. Place the input model file (e.g. DATAROOT/models/obj_01.ply) in $./assets/models/
  3. Build the code and run it. Just type:
    $ sh build_and_run.sh
    The output file is in $./assets/sifts/. It's a ply file storing the 3D coordinates of designated keypoints.

Ⅲ. Annotate Keypoints

  1. The related code is in $ROOT/2_keypoint_annotator/.
    $ cd ROOT/2_keypoint_annotator/
  2. Run keypoint annotator on one object of LineMod.
    $ python annotate_keypoint.py --obj_id 1 --total_kp_number 50 --output_base ROOT/3_6Dpose_estimator/data --sixd_base DATAROOT
    Type the following to see the meaning of options.
    $ python annotate_keypoint.py -h
  3. The annotated keypoints are in file annot_train.h5 and annot_eval.h5. The corresponding training images are in folders train and eval.

Ⅳ. Training

Train Object Detector YOLOv3

  1. Relative files locate in $ROOT/3_6Dpose_estimator/train_YOLO.
    $ cd ROOT/3_6Dpose_estimator/train_YOLO
  2. Build Darknet (YOLOv3).
    $ make
  3. Prepare data as AlexeyAB/darknet's instructions. Refer to folder ./scripts for more help.
  4. Download pretrained darknet53 here
  5. Run train_single.sh or train_all.sh to train the network.
  6. Put trained weights (e.g. 01.weights) in folder $ROOT/3_6Dpose_estimator/models/yolo/.

Train Keypoint Detector (KPD)

  1. Relative code is in $ROOT/3_6Dpose_estimator/train_KPD/
    $ cd ROOT/3_6Dpose_estimator/train_KPD
  2. Modify Line 19, 21, 39, 46 of file./src/utils/dataset/coco.py to previously annotated dataset. Examples are given in these lines.
  3. Train on Linemod dataset without DPG.
    $ python src/train.py --trainBatch 28 --expID seq5_Nov_1_1 --optMethod adam
  4. Train on Linemod dataset with DPG. Just add a --addDPG option. and load the model trained after in the second step.
    $ python src/train.py --trainBatch 28 --expID seq5_dpg_Nov_1_1 --optMethod adam --loadModel ./exp/coco/seq5_Nov_1_1/model_100.pkl --addDPG
  5. (Optional) Visualize training process. Type
    $ tensorboard --logdir ./

Ⅴ. Evaluate

  1. Move back to the root of pose estimator.

    $ cd ROOT/3_6Dpose_estimator/
  2. Run the following command.

    $ CUDA_VISIBLE_DEVICES=1 python3 betapose_evaluate.py --nClasses 50 --indir /01/eval --outdir examples/seq1 --sp --profile

    The output json file containing predicted 6D poses will be in examples/seq1.

betapose's People

Contributors

sjtuytc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

betapose's Issues

Couldn't open file: data_linemod_gt/02/all.txt

Sorry for bothering you. I run the file gt_single_object.py ,then create the folder data_linemod_gt, I run train_single.sh, then I got the following information:

Total BFLOPS 65.290
Loading weights from darknet53.conv.74...
seen 64
Done!
Learning Rate: 0.001, Momentum: 0.9, Decay: 0.0005
Couldn't open file: data_linemod_gt/02/all.txt

What should I do?

No errors, but method doesn't detect any objects

I am running everything on Windows and I've finally managed to get everything to run without errors. But I have the following problem when I run the betapose_evaluate.py, the method doesn't detect any objects in all images. I am almost sure the problem is in the first step (object detection with YOLO), because it is the one that detects the object.

Here is what I've done to create the yolo weights file:

  1. I've compiled YOLO directly from its original source, because I am on windows and the make step that you've described wouldn't have worked for me. This means I didn't use the contents of the train_YOLO folder at all.
  2. I've then trained the network for the APE object from the LINEMOD dataset. I've trained it with 2000 iterations
  3. I've tested the weights with the YOLO program compiled in step 1) and it worked fine - it detected objects as expected.

BUT when I use the weight file in the betapose_evaluate.py it doesn't work. Can you tell me if you have made any major changes in the darknet code(train_YOLO)? Is my problem that I haven't used a darknet built from the train_YOLO folder? Here is a link to my weights for the APE object from the LINEMOD dataset - https://www.dropbox.com/s/2e3xdshsavp3t5a/01.weights?dl=0 and here is an example image with an APE in it - https://www.dropbox.com/s/rhar1p251dp4z31/000002.jpg?dl=0

P.S. Could you also recommend an open-sourced method for synthetic dataset generation?

No such file or directory: 'DATAROOT/kpmodels/obj_01.ply'

Traceback (most recent call last):
  File "annotate_keypoint.py", line 360, in <module>
    bench = load_bench(sixd_base)
  File "annotate_keypoint.py", line 73, in load_bench
    bench.kpmodels['{:02d}'.format(ID)].load(os.path.join(base_path, 'kpmodels/' + name + '.ply'), scale=bench.scale_to_meters)
  File "/home/Workspace/Project/betapose/2_keypoint_annotator/utils/model.py", line 80, in load
    data = PlyData.read(path)
  File "/home/anaconda3/envs/pytorch/lib/python2.7/site-packages/plyfile.py", line 390, in read
    (must_close, stream) = _open_stream(stream, 'read')
  File "/home/anaconda3/envs/pytorch/lib/python2.7/site-packages/plyfile.py", line 469, in _open_stream
    return (True, open(stream, read_or_write[0] + 'b'))

What is kpmodels?You just say

Only folders called models and test are needed. Put them in DATAROOT/models and DATAROOT/test

one image inference

Hi,
I would like to take an image, forward it after the training and show results on the original image.
what are the functions that apply the different transformations to the input image to make inference? and how can i return to the original image and project results on it?

Cannot reproduce paper results

Hi,

I tried to train your network on the Linemod Ape object (01). I followed every steps of your tutorial.
But when I run betapose_evaluate, I cannot find results as you mention in your paper, especially with ADD metric.
Do you have pkl (output of train KPD) file on the Ape object so I can check if the problem come from my learning ?

Regards

License?

What is the license for this code? Lack of license implies full copyright protection.

A bout dataset preparation

Hello, sjtuytc.

Thanks for you grate work and sharing.
I want to run your code(train and test), but as you said we need to prepare data by ourself.
I will try to prepare data as darknet , but can you show me the whole dataset folder structure? so that I can more efficiently do this work.

Thanks,
Yuning

How to prepare data as AlexeyAB/darknet's instructions?

Please tell me how to prepare data as AlexeyAB/darknet's instructions? I download the darknet'code, but the "README.md" in ./scripts folder just some website of dataset. I don't know how to prepare data as AlexeyAB/darknet's instructions.

how to select the most confident keypoint for pnp?

"when on the Occlusion dataset we only keep l = 10 most confident keypoints and abandon other low-confident keypoints".
hi~ I wonder how you select the most 10 confident keypoint for pnp? what's the confidence based on ?
I can't find the relevant code, could you give me some help?
best wishes.

some problems about sixd.py

As title, when I tried to load sixd data I met some problems.

You load sixd data from 'gt.yml'(Is it from scene_gt.json?) In sixd.py, and this code: fr.gt.append((gt['obj_id'], pose, gt['obj_bb'])) for loading pose and ground truth bbox. But in gt.yml file I can't find 'obj_bb' items.
I also try to delete this item and just load pose, but It seems use for cropping image.
can you give me some suggestions?

thanks,
yuning

Missing folder and a file in train_KPD/src/predict folder

from predict.annot.coco_minival import Mscoco_minival

Hello I am trying to train a KPD, but I get this error:

Traceback (most recent call last): File "src/train.py", line 14, in <module> from evaluation import prediction File "...\betapose\3_6Dpose_estimator\train_KPD\src\evaluation.py", line 9, in <module> from predict.annot.coco_minival import Mscoco_minival ModuleNotFoundError: No module named 'predict.annot'

Could you please upload this missing file?

I met a problem

Scanning dependencies of target pcl-sift [ 50%] Building CXX object CMakeFiles/pcl-sift.dir/main.cpp.o [100%] Linking CXX executable pcl-sift /usr/bin/ld: warning: libboost_system.so.1.58.0, needed by /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/libpcl_common.so, may conflict with libboost_system.so.1.60.0 /usr/bin/ld: warning: libboost_thread.so.1.58.0, needed by /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/libpcl_common.so, may conflict with libboost_thread.so.1.60.0 /usr/bin/ld: warning: libboost_filesystem.so.1.58.0, needed by /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/libpcl_io.so, may conflict with libboost_filesystem.so.1.60.0 /usr/bin/ld: warning: libboost_iostreams.so.1.58.0, needed by /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/libpcl_io.so, may conflict with libboost_iostreams.so.1.60.0 /usr/bin/ld: warning: libboost_chrono.so.1.58.0, needed by /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/libpcl_io.so, may conflict with libboost_chrono.so.1.60.0 CMakeFiles/pcl-sift.dir/main.cpp.o:在函数‘main’中: /home/panxiang/ldd/betapose-master/1_keypoint_designator/main.cpp:93:对‘pcl::visualization::PCLVisualizer::PCLVisualizer(std::string const&, bool)’未定义的引用 /home/panxiang/ldd/betapose-master/1_keypoint_designator/main.cpp:101:对‘pcl::visualization::PCLVisualizer::setPointCloudRenderingProperties(int, double, std::string const&, int)’未定义的引用 CMakeFiles/pcl-sift.dir/main.cpp.o:在函数‘pcl::PLYWriter::write(std::string const&, pcl::PCLPointCloud2 const&, Eigen::Matrix<float, 4, 1, 0, 4, 1> const&, Eigen::Quaternion<float, 0> const&, bool)’中: /usr/include/pcl-1.7/pcl/io/ply_io.h:630:对‘pcl::PLYWriter::writeBinary(std::string const&, pcl::PCLPointCloud2 const&, Eigen::Matrix<float, 4, 1, 0, 4, 1> const&, Eigen::Quaternion<float, 0> const&, bool)’未定义的引用 /usr/include/pcl-1.7/pcl/io/ply_io.h:632:对‘pcl::PLYWriter::writeASCII(std::string const&, pcl::PCLPointCloud2 const&, Eigen::Matrix<float, 4, 1, 0, 4, 1> const&, Eigen::Quaternion<float, 0> const&, int, bool)’未定义的引用 CMakeFiles/pcl-sift.dir/main.cpp.o:在函数‘pcl::PLYWriter::write(std::string const&, pcl::PCLPointCloud2 const&, Eigen::Matrix<float, 4, 1, 0, 4, 1> const&, Eigen::Quaternion<float, 0> const&, bool, bool)’中: /usr/include/pcl-1.7/pcl/io/ply_io.h:653:对‘pcl::PLYWriter::writeBinary(std::string const&, pcl::PCLPointCloud2 const&, Eigen::Matrix<float, 4, 1, 0, 4, 1> const&, Eigen::Quaternion<float, 0> const&, bool)’未定义的引用 /usr/include/pcl-1.7/pcl/io/ply_io.h:655:对‘pcl::PLYWriter::writeASCII(std::string const&, pcl::PCLPointCloud2 const&, Eigen::Matrix<float, 4, 1, 0, 4, 1> const&, Eigen::Quaternion<float, 0> const&, int, bool)’未定义的引用 CMakeFiles/pcl-sift.dir/main.cpp.o:在函数‘pcl::search::OrganizedNeighbor<pcl::PointXYZ>::OrganizedNeighbor(bool, float, unsigned int)’中: /usr/include/pcl-1.7/pcl/search/organized.h:95:对‘pcl::search::Search<pcl::PointXYZ>::Search(std::string const&, bool)’未定义的引用 collect2: error: ld returned 1 exit status CMakeFiles/pcl-sift.dir/build.make:352: recipe for target 'pcl-sift' failed make[2]: *** [pcl-sift] Error 1 CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/pcl-sift.dir/all' failed make[1]: *** [CMakeFiles/pcl-sift.dir/all] Error 2 Makefile:83: recipe for target 'all' failed make: *** [all] Error 2 build_and_run.sh: 5: build_and_run.sh: ./pcl-sift: not found **I have encountered this problem, how can I solve it?**

How to prepare data

Sorry for disturbance. Can you provide the file structure in './betapose/3_6Dpose_estimator/train_YOLO/scripts'?
In AlexeyAB/darknet the file structure is
├── VOCdevkit
│ └── VOC2007
│ ├── Annotations
│ │ ├──.xml
│ │ └── .xml
│ ├── ImageSets
│ │ ├── Layout
│ │ ├── Main
│ │ │ ├── test.txt
│ │ │ ├── train.txt
│ │ │ └── val.txt
│ │ └── Segmentation
│ ├── JPEGImages
│ │ ├──.jpg
│ │ └──.jpg
│ └── labels
│ └── .txt
└── voc_label.py

but you hadn't provide the voc_label.py and .xmlfiles

RuntimeError: Expected object of type torch.FloatTensor but found type torch.LongTensor for argument #2 'other'

Thank you for your help. I have new problems again.
Create new model ############# Starting Epoch 0 ############# 0%| | 0/17 [00:00<?, ?it/s]Traceback (most recent call last): File "src/train.py", line 226, in <module> main() File "src/train.py", line 171, in main loss, acc = train(train_loader, m, criterion, optimizer, writer) File "src/train.py", line 27, in train for i, (inps, labels, setMask, imgset) in enumerate(train_loader_desc): File "/home/ltr/anaconda3/envs/betapose/lib/python3.6/site-packages/tqdm/_tqdm.py", line 1022, in __iter__ for obj in iterable: File "/home/ltr/anaconda3/envs/betapose/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 286, in __next__ return self._process_next_batch(batch) File "/home/ltr/anaconda3/envs/betapose/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 307, in _process_next_batch raise batch.exc_type(batch.exc_msg) RuntimeError: Traceback (most recent call last): File "/home/ltr/anaconda3/envs/betapose/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 57, in _worker_loop samples = collate_fn([dataset[i] for i in batch_indices]) File "/home/ltr/anaconda3/envs/betapose/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 57, in <listcomp> samples = collate_fn([dataset[i] for i in batch_indices]) File "/media/ltr/新加卷2/betapose/3_6Dpose_estimator/train_KPD/src/utils/dataset/coco.py", line 75, in __getitem__ 'coco', sf, self, train=self.is_train) File "/media/ltr/新加卷2/betapose/3_6Dpose_estimator/train_KPD/src/utils/pose.py", line 142, in generateSampleBox inp = rotate(inp) File "/media/ltr/新加卷2/betapose/3_6Dpose_estimator/train_KPD/src/torchsample/torchsample/transforms/affine_transforms.py", line 322, in __call__ center=True) File "/media/ltr/新加卷2/betapose/3_6Dpose_estimator/train_KPD/src/torchsample/torchsample/utils.py", line 131, in th_affine2d x_transformed = th_bilinear_interp2d(x.contiguous(), new_coords) File "/media/ltr/新加卷2/betapose/3_6Dpose_estimator/train_KPD/src/torchsample/torchsample/utils.py", line 167, in th_bilinear_interp2d x0_ix = x0.mul(stride[1]).long() RuntimeError: Expected object of type torch.FloatTensor but found type torch.LongTensor for argument #2 'other'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.