Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Tf object detection as grasp prediction #493

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 118 additions & 1 deletion costar_google_brainrobotdata/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,121 @@ Color augmentation is also available:
4. vrep should load and start the simulation
5. make sure the folder holding `vrep_grasp.py` is on your PYTHONPATH
6. cd to `~/src/costar_ws/src/costar_plan/costar_google_brainrobotdata/`, or wherever you put the repository
7. run `python2 vrep_grasp.py`
7. run `export CUDA_VISIBLE_DEVICES="" && python2 vrep_grasp.py`

## Hyperparameter search


### Google Brain Grasping Dataset

To run the search execute the following command

```
export CUDA_VISIBLE_DEVICES="0" && python2 google_grasp_hyperopt.py --run_name single_prediction_all_transforms
```

Generating a hyperparameter search results summary for google brain grasping dataset classification:

```
python hyperopt_rank.py --log_dir hyperopt_logs_google_brain_classification --sort_by val_acc
```

### Cornell Dataset

#### Regression
```

```

The following commands will generate a hyperopt summary.

Generating a hyperparameter search results summary for cornell regression

```
python hyperopt_rank.py --log_dir hyperopt_logs_cornell_regression --sort_by val_grasp_jaccard
```

#### Classification

```
export CUDA_VISIBLE_DEVICES="0" && python cornell_hyperopt.py --log_dir hyperopt_logs_cornell_classification
```


Generating a hyperparameter search results summary for cornell classification

```
python hyperopt_rank.py --log_dir hyperopt_logs_cornell_classification --sort_by val_binary_accuracy
```


## TF Object Detection API


1. follow the installation instructions for tensorflow_models.sh
in github.com/ahundt/robotics_setup.
2. That will install the [tf object detection
API](https://github.com/tensorflow/models/blob/master/research/object_detection)
3. Perform cornell dataset tfrecord generation for use in object detection

```
python2 cornell_grasp_dataset_writer --write True --padding False --angle_classes True --include_negative_examples False --angle_classes_zero_is_background_class True
```

4. Run `python tf_object_detection.py`, this will download models from the [tf object detection model zoo](https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md).

Model files will be downloaded to

- `~/.keras/datasets/faster_rcnn_inception_resnet_v2_atrous_coco_2018_01_28/`
- `~/.keras/datasets/ssd_mobilenet_v2_coco_2018_03_29/`
- `~/.keras/datasets/faster_rcnn_nas_coco_2018_01_28/`

Next step is to set up configuration files for a training run.

Some reference commands might be at https://github.com/tensorflow/models/issues/3909

TODO(ahundt) how to specify multiple tfrecord files?
(the next batch of text is from [train.py](https://github.com/tensorflow/models/blob/master/research/object_detection/train.py))

The executable `research/object_detection/train.py` is used to train DetectionModels. There are two ways of
configuring the training job:
1) A single pipeline_pb2.TrainEvalPipelineConfig configuration file
can be specified by --pipeline_config_path.
Example usage:
./train \
--logtostderr \
--train_dir=path/to/train_dir \
--pipeline_config_path=pipeline_config.pbtxt
2) Three configuration files can be provided: a model_pb2.DetectionModel
configuration file to define what type of DetectionModel is being trained, an
input_reader_pb2.InputReader file to specify what training data will be used and
a train_pb2.TrainConfig file to configure training parameters.
Example usage:
```
./train \
--logtostderr \
--train_dir=path/to/train_dir \
--model_config_path=model_config.pbtxt \
--train_config_path=train_config.pbtxt \
--input_config_path=train_input_config.pbtxt
```

Here are two example commands to run one after the other from [github issue #1854](https://github.com/tensorflow/models/issues/1854) train with:

```
python object_detection/train.py \
--logtostderr \
--pipeline_config_path=~/.virtualenvs/Project/lib/python2.7/site-packages/tensorflow/models/object_detection/samples/configs/faster_rcnn_resnet101_pets_learn.config \
--train_dir=~/.virtualenvs/Project/models/model/train
```

Then run the following to evaluate:

```
python object_detection/eval.py \
--logtostderr \
--pipeline_config_path=~/.virtualenvs/Project/lib/python2.7/site-packages/tensorflow/models/object_detection/samples/configs/faster_rcnn_resnet101_pets_learn.config \
--checkpoint_dir=~/.virtualenvs/Project/models/model/train \
--eval_dir=~/.virtualenvs/Project/models/model/eval

```
Loading