telloの画像でtiny yolo and v3 を試してみる
やりたいこと
安い割に性能がなかなか良い中国製 Toy Drone "tello"のカメラを使って、yoloをまわす。
今回はpytorchでやってみる。
Shanghai Maker Carnivalのための準備 !
pytorchのインストール
python2.7のCPUバージョン
pip install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp27-cp27mu-linux_x86_64.whl
pip install torchvision
pipのエラーが出たら以下で対処。いつのまにこんなことに。。。
python2.7 GPUバージョン(CUDA 8.x)
pip install http://download.pytorch.org/whl/cu80/torch-0.4.1-cp27-cp27mu-linux_x86_64.whl
pip install torchvision
CUDA8.0 and cuDNN6 のインストール
Telloをpythonで操作するための設定
ffmpegのインストール
git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
./configure --disable-static --enable-shared --disable-x86asm
make -j 4
sudo make install
PyAvのインストール
sudo pip install av==0.5.2
パスの設定
Tellopy
以下に従ってイントール
pip install tellopy
画像の取得や処理は以下のスクリプトを実行
処理を早くしたいときは以下の対策
こうするとtelloの画像が取得できる
yolo v2 and 3 by Pytorch
GitHub - marvis/pytorch-yolo2: Convert https://pjreddie.com/darknet/yolo/ into pytorch
YOLOtiny_v2_chainer/tiny-yolo-voc.weights at master · leetenki/YOLOtiny_v2_chainer · GitHub
上記を参考に実行。
yolo v2 by web cam
- python demo.py cfg/tiny-yolo-voc.cfg tiny-yolo-voc.weights
yolo v3 by image
- python detect.py cfg/yolov3.cfg yolov3.weights data/dog.jpg
pytorchのバージョンの問題でエラーが発生。以下で対処。
The actual solution is changing conv_model.weight.data.copy_(torch.from_numpy(buf[start:start+num_w])); start = start + num_w to conv_model.weight.data.copy_(torch.reshape(torch.from_numpy(buf[start:start+num_w]),(conv_model.weight.shape[0],conv_model.weight.shape[1], conv_model.weight.shape[2],conv_model.weight.shape[3]))); start=start + num_w
tello画像を使ってyoloを回す
GitHub - marvis/pytorch-yolo2: Convert https://pjreddie.com/darknet/yolo/ into pytorch のdemo.pyの入力にGitHub - hanyazou/TelloPy: DJI Tello drone controller python packageのvideo_effect.pyで取得した画像を入れる。
所感
明後日から初めての中国。。。
Let's Enjoy !!!