Youtube Auto cat flap examples
https://www.youtube.com/watch?v=VDU2EMxDElc&t=34s
https://www.youtube.com/watch?v=emWBobbEPwY
Here with other texts in lable.txt
class1 = Background
class2 = Cat with prey
class3 = Cat no prey
$ python load_test_export.py
Only need to do the installation step 1 to 6
https://github.com/ollewelin/Installing-and-Test-PyTorch-C-API-on-Ubuntu-with-GPU-enabled
https://pytorch.org/tutorials/beginner/transfer_learning_tutorial.html
https://github.com/dusty-nv/jetson-inference
...
# Here the size of each output sample is set to 3.
# Alternatively, it can be generalized to nn.Linear(num_ftrs, len(class_names)).
model_ft.fc = nn.Linear(num_ftrs, 3) # change here number of classes
...
$ ./data/hymenoptera_data/train/Background/imgXX.jpg
$ ./data/hymenoptera_data/train/Cat1/imgXX.jpg
$ ./data/hymenoptera_data/train/Cat2/imgXX.jpg
$ ./data/hymenoptera_data/val/Background/imgXX.jpg
$ ./data/hymenoptera_data/val/Cat1/imgXX.jpg
$ ./data/hymenoptera_data/val/Cat2/imgXX.jpg
$ python train.py
Then close the two test windows to export to ONNX model
Follow instructions from :
https://github.com/dusty-nv/jetson-inference/blob/master/docs/jetpack-setup-2.md
https://developer.nvidia.com/embedded/learn/get-started-jetson-nano-devkit
Or
https://developer.nvidia.com/embedded/learn/get-started-jetson-nano-2gb-devkit
imagenet3.cpp
Will collect image if class 1 > thresshold probablility and store on external USB hard drive ..
olle@olle-TUF-Gaming-FX505DT-FX505DT:~$
$ git clone https://github.com/ollewelin/PyTorch-Training-Resnet50
$ cd PyTorch-Training-Resnet50
$ cat model_31* > model_31.tar.gz
$ gunzip model_31.tar.gz
$ tar -xf model_31.tar
$ cp model_31.pt model_saved.pt
$ python load_test_export.py
(base) olle@olle-TUF-Gaming-FX505DT-FX505DT:~/PyTorch-Training-Resnet50$ python load_test_export.py
Hejvdsgdg
Export model to ONNX
(base) olle@olle-TUF-Gaming-FX505DT-FX505DT:~/PyTorch-Training-Resnet50$
$ cp model_saved.onnx model_31.onnx
$ scp ~/PyTorch-Training-Resnet50/model_28.onnx [email protected].<xxx>.<xxx>:~/jetson-inference/examples/my-recognition
$ ifconfig
$ arp -a
jetson@jetson-desktop:~$ ip addr
192.168.1.<xxx>
olle@olle-TUF-Gaming-FX505DT-FX505DT:~$ ssh [email protected].<xxx>.<xxx>
jetson@jetson-desktop:~$ sudo apt-get update
jetson@jetson-desktop:~$ git clone --recursive https://github.com/dusty-nv/jetson-inference
jetson@jetson-desktop:~$ git clone https://github.com/ollewelin/PyTorch-Training-Resnet50
jetson@jetson-desktop:~$ cp ~/PyTorch-Training-Resnet50/labels.txt ~/jetson-inference/examples/my-recognition
jetson@jetson-desktop:~$ cp ~/PyTorch-Training-Resnet50/CMakeLists.txt ~/jetson-inference/examples/my-recognition
jetson@jetson-desktop:~$ cp ~/PyTorch-Training-Resnet50/imagenet2.cpp ~/jetson-inference/examples/my-recognition
jetson@jetson-desktop:~$ cp ~/PyTorch-Training-Resnet50/imagenet3.cpp ~/jetson-inference/examples/my-recognition
jetson@jetson-desktop:~$ cp ~/PyTorch-Training-Resnet50/start.sh ~/jetson-inference/examples/my-recognition
jetson@jetson-desktop:~$ cd jetson-inference
jetson@jetson-desktop:~/jetson-inference$ docker/run.sh --volume /:/olle_test1
jetson@jetson-desktop:~/jetson-inference$ cd ../olle_test1/home/jetson/jetson-inference/examples/my-recognition
root@jetson-desktop:/olle_test1/home/jetson/jetson-inference/examples/my-recognition# cmake CMakeLists.txt
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found CUDA: /usr/local/cuda (found version "10.2")
-- Configuring done
-- Generating done
-- Build files have been written to: /olle_test1/home/jetson/jetson-inference/examples/my-recognition
root@jetson-desktop:/olle_test1/home/jetson/jetson-inference/examples/my-recognition# make
Scanning dependencies of target imagenet2
[ 50%] Building CXX object CMakeFiles/imagenet2.dir/imagenet2.cpp.o
[100%] Linking CXX executable imagenet2
[100%] Built target imagenet2
root@jetson-desktop:/olle_test1/home/jetson/jetson-inference/examples/my-recognition#
$ cd jetson-inference
$ docker/run.sh --volume /:/olle_test1 -r "bash ../olle_test1/home/jetson/jetson-inference/examples/my-recognition/start.sh"
Or all from bash start_script.sh
$ cd jetson-inference
$ ~/jetson-inference/bash start_script.sh
Cat example model_31.onnx
$ root@jetson-desktop:/olle_test1/home/jetson/jetson-inference/examples/my-recognition#./imagenet2 --model=./model_31.onnx --input_blob=input --output_blob=output --labels=./labels.txt csi://0
Or less printout's and other thresshold Cat with prey
$ ./imagenet3 --model=./model_31.onnx --input_blob=input --output_blob=output --labels=./labels.txt csi://0
Or first example
root@jetson-desktop:/olle_test1/home/jetson/jetson-inference/examples/my-recognition#./imagenet2 --model=./resnet50.onnx --input_blob=input --output_blob=output --labels=./labels.txt csi://0
Jetson nano Build from source
https://github.com/dusty-nv/jetson-inference/blob/master/docs/building-repo-2.md
$ sudo apt-get update
$ sudo apt-get install git cmake libpython3-dev python3-numpy
$ git clone --recursive https://github.com/dusty-nv/jetson-inference
$ cd jetson-inference
$ mkdir build
$ cd build
$ cmake ../
$ make -j$(nproc)
$ sudo make install
$ sudo ldconfig
Run the “User Accounts” app, then click the “Unlock” button in the top right of the window and enter your sudo password, and then you can enable/disable Automatic Login for your account.
SSH From PC side
ssh [email protected]
sudo vim ~/../../etc/profile.d/bash_completion.sh
Vim guide
https://coderwall.com/p/adv71w/basic-vim-commands-for-getting-started
R - to replace more than one character
R
bash ~/jetson-inference/examples/my-recognition/start_rtp.sh
bash ~/jetson-inference/start_script.sh
:wq - to save and exit
press ESC to set VIM to command mode
:wq
sudo reboot
https://gstreamer.freedesktop.org/documentation/installing/on-linux.html?gi-language=c
sudo apt-get update
sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio
gst-launch-1.0 -v udpsrc port=1234 caps = "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" ! rtph264depay ! decodebin ! videoconvert ! autovideosink