Skip to content

Commit

Permalink
WIP: work on new install script for docker
Browse files Browse the repository at this point in the history
  • Loading branch information
tdurand committed May 9, 2019
1 parent 3736e49 commit e2540f2
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -3,6 +3,7 @@
.next/
node_modules/
*.ffm
*.bak
prototype/video
history.db
static/trackerHistory.json
Expand Down
8 changes: 8 additions & 0 deletions README.md
Expand Up @@ -53,6 +53,14 @@ If your jetson does not have jetpack 4.2 *(CUDA 10, TensorRT 5, cuDNN 7.3, Ubunt

Open a terminal or ssh to you jetson and run this command (make sure your webcam is connected):


# https://unix.stackexchange.com/questions/306007/how-to-pass-argument-to-script-which-is-input-to-bash

```bash
sudo wget -O - https://raw.githubusercontent.com/moovel/lab-opendatacam/v2/docker/run-jetson/run-opendatacam.sh | bash -s PLATFORM=nano
```


**For Jetson Nano:**

```bash
Expand Down
4 changes: 2 additions & 2 deletions config.json
@@ -1,7 +1,7 @@
{
"PATH_TO_YOLO_DARKNET" : "/darknet",
"VIDEO_INPUT": "usbcam",
"NEURAL_NETWORK": "yolov3-tiny",
"VIDEO_INPUT": "TO_SPECIFY_VIDEO_INPUT",
"NEURAL_NETWORK": "TO_SPECIFY_NEURAL_NETWORK",
"VIDEO_INPUTS_PARAMS": {
"file": "demo_stuttgart.mp4",
"usbcam": "v4l2src ! video/x-raw, framerate=30/1, width=640, height=360 ! videoconvert ! appsink",
Expand Down
1 change: 1 addition & 0 deletions doc/HOTSPOT.md
@@ -0,0 +1 @@
TODO
103 changes: 103 additions & 0 deletions docker/run-jetson/install-opendatacam.sh
@@ -0,0 +1,103 @@
#!/bin/bash

# exit when any command fails
set -e

VERSION=v2
# # PLATFORM in ["nano","xavier","tx2","dockernvidia"]
PLATFORM=undefined

DEFAUT_VIDEO_INPUT_nano=raspberrycam
DEFAUT_VIDEO_INPUT_tx2=usbcam
DEFAUT_VIDEO_INPUT_xavier=usbcam

DEFAUT_NEURAL_NETWORK_nano=yolov3-tiny
DEFAUT_NEURAL_NETWORK_tx2=yolov2-voc
DEFAUT_NEURAL_NETWORK_xavier=yolov3


# animals_moo=cow; sound=moo; i="animals_$sound"; echo "${!i}"

echo "Installing opendatacam docker image"

display_usage() {
echo
echo "Usage: $0"

echo " -p, --platform Specify platform : nano, xavier, tx2"
echo " -h, --help Display usage instructions"
echo
}

raise_error() {
local error_message="$@"
echo "${error_message}" 1>&2;
}

argument="$1"

if [[ -z $argument ]] ; then
raise_error "Expected argument to be present"
display_usage
else
case $argument in
-h|--help)
display_usage
;;
-p|--platform)
# TODO Check if existing docker image is running and stop it if it is the case

# Platform is specified
PLATFORM=$2
# TODO verify if PLATFORM is oneOf(nano, xavier, tx2)
echo "Installing opendatacam $VERSION for platform: $2"
# Get the run-docker script
wget -N https://raw.githubusercontent.com/moovel/lab-opendatacam/$VERSION/docker/run-jetson/run-docker.sh

# Chmod to give exec permissions
chmod 777 run-docker.sh

# Get the config file
wget -N https://raw.githubusercontent.com/moovel/lab-opendatacam/$VERSION/config.json

# Replace VIDEO_INPUT and NEURAL_NETWORK with default config for this platform
sed -i'.bak' -e 's/TO_FILL_VIDEO_INPUT/$DEFAUT_VIDEO_INPUT_$PLATFORM/g' config.json
# sed -i'.bak' -e 's/TO_FILL_NEURAL_NETWORK/yolov3/g' config.json

# Pull, install and run opendatacam container when docker starts (on boot with --restart unless-stopped, -d is for detached mode)
# sudo ./darknet-docker.sh run -d --restart unless-stopped tdurand/opendatacam:v2.0.0-beta.1-nano

# Message that docker container has been started and opendatacam will be available shorty on <IP>
echo "Opendatacam docker container started successfully, it might take up to 1 min to start the node app"
echo "Open browser at http://<IP_OF_JETSON>:8080 or http://localhost:8080"
echo "Opendatacam will start automaticaly on boot when you restart you jetson"
echo "If you want to stop it or update it blabalbalabl"

;;
*)
raise_error "Unknown argument: ${argument}"
display_usage
;;
esac
fi

echo "Finished script $0"


# "SETTINGS_BY_PLATFORM": {
# "nano": {
# "VIDEO_INPUT": "raspberrycam",
# "NEURAL_NETWORK": "yolov3-tiny"
# },
# "tx2": {
# "VIDEO_INPUT": "usbcam",
# "NEURAL_NETWORK": "yolov2-voc"
# },
# "xavier": {
# "VIDEO_INPUT": "usbcam",
# "NEURAL_NETWORK": "yolov3"
# }
# },



6 changes: 4 additions & 2 deletions docker/run-jetson/darknet-docker.sh → docker/run-jetson/run-docker.sh 100644 → 100755
@@ -1,10 +1,12 @@
#!/bin/bash

# This script is meant to serve as a placeholder until nvidia-docker is
# available on the Jetson TX2. Its recommended usage is the equivalent to a
# available on the Jetson platform. Its recommended usage is the equivalent to a
# vanilla `docker run` command with no spaces between `docker` and `run`:
#
# ./darknet-docker run --rm -it somedockerimage
# It does mount all the necessary dependencies for GPU usage from the docker image, like CUDA, CUDNN
#
# ./run-docker run --rm -it somedockerimage to run interactively
#

# Reference: strace -v -f /darknet/darknet detector test cfg/voc.data cfg/tiny-yolo-voc.cfg tiny-yolo-voc.weights data/dog.jpg 2>&1 | grep etc
Expand Down

0 comments on commit e2540f2

Please sign in to comment.