Skip to content

Commit

Permalink
makefile cuda option, use allencv latest
Browse files Browse the repository at this point in the history
  • Loading branch information
sethah committed Jun 10, 2019
1 parent 35055b0 commit e38b8d0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
15 changes: 11 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ PROFILE = default
PROJECT_NAME = tennis
PYTHON_INTERPRETER = python3
USE_GPU = 0
ifeq ($(USE_GPU), 1)
CUDA_DEVICE = 0
else
CUDA_DEVICE = -1
endif
DATA_DIR = $(PROJECT_DIR)/data

ifeq (,$(shell which conda))
Expand All @@ -36,8 +41,10 @@ test_all:
${RUNTEST} ${ALLMODULES}

## Make Dataset
data: requirements
$(PYTHON_INTERPRETER) deeptennis/data/make_dataset.py
data:
mkdir -p $(DATA_DIR)/processed
mkdir -p $(DATA_DIR)/interim
mkdir -p $(DATA_DIR)/raw

ALL_VIDEOS=$(wildcard $(DATA_DIR)/raw/*.mp4)

Expand Down Expand Up @@ -68,7 +75,7 @@ player_tracking: $(addprefix $(DATA_DIR)/interim/player_tracking/, $(addsuffix .
$(DATA_DIR)/interim/player_tracking/%.json: $(DATA_DIR)/processed/frames/%
find $(DATA_DIR)/processed/frames/$(basename $(notdir $<)) -type f -printf '{"image_path": "%p"}\n' | sort > /tmp/player_tracking_temp.json && \
allennlp predict $(MODEL_PATH) /tmp/player_tracking_temp.json \
--cuda-device 0 --output-file $@ --silent --predictor default_image \
--cuda-device $(CUDA_DEVICE) --output-file $@ --silent --predictor default_image \
--batch-size 4 \
--overrides '{"dataset_reader": {"type": "image_annotation", "augmentation": [{"type": "resize","height": 512, "width": 512}, {"type": "normalize"}], "lazy": true}, "model": {"roi_box_head": {"decoder_thresh": 0.01}}}' \
--include-package allencv.data.dataset_readers \
Expand All @@ -80,7 +87,7 @@ $(DATA_DIR)/interim/player_tracking/%.json: $(DATA_DIR)/processed/frames/%
--include-package allencv.predictors \
&& rm /tmp/player_tracking_temp.json

$(DATA_DIR)/interim/tracking_videos/%: $(DATA_DIR)/interim/player_tracking/%.json
data/interim/tracking_videos/%: $(DATA_DIR)/interim/player_tracking/%.json
python $(PROJECT_DIR)/scripts/make_tracking_video.py \
--tracking-path $(addsuffix .json, $(DATA_DIR)/interim/player_tracking/$(basename $(notdir $<))) \
--frame-path $(DATA_DIR)/processed/frames/$(basename $(notdir $<)) \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ python -m allencv.service.server_simple \
--include-package allencv.predictors \
--title "Player detector" \
--detection \
--overrides '{"dataset_reader": {"type": "image_annotation", "augmentation": [{"type": "resize", "height": 512, "width": 512}, {"type": "normalize"}], "lazy": true}, "model": {"roi_box_head": {"decoder_detections_per_image": 50}}}'
--overrides '{"dataset_reader": {"type": "image_annotation", "augmentation": [{"type": "resize", "height": 512, "width": 512}, {"type": "normalize"}], "lazy": true}, "model": {"roi_box_head": {"decoder_detections_per_image": 50}, "rpn": {"archive_file": "https://deeptennis.s3-us-west-1.amazonaws.com/player_rpn_res50_fpn.tar.gz"}}}'
```

Navigate to `localhost:8000` and select an image of a tennis point to view the model's detections.
Expand Down
2 changes: 1 addition & 1 deletion experiment_config/player_kprcnn.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ local MODEL = {
"type": "keypoint_rcnn",
"rpn": {
"type": "pretrained_rpn",
"archive_file": std.extVar("RPN_PATH"),
"archive_file": "https://deeptennis.s3-us-west-1.amazonaws.com/player_rpn_res50_fpn.tar.gz",
"requires_grad": true
},
"train_rpn": true,
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ lime
shap
umap
mlflow
allencv>=0.1.3
git+https://github.com/sethah/allencv

0 comments on commit e38b8d0

Please sign in to comment.