TensorFlow安裝 + 簡單圖像視頻檢測

(anaconda安裝過程略(* ̄3 ̄)╭

yolov3-wider_16000.weights資源鏈接:https://pan.baidu.com/s/1N7zTVE9TIS7VhUida6Xz2Q 提取碼:nowr

yolov3.weight資源鏈接:https://pan.baidu.com/s/1MEWpEh-Xlp4yAJhpDUgrvw 提取碼:6ij3 

 

1.tensorflow的安裝過程

1.打開anaconda prompt(cmd也可)

2.(這裏使用了豆瓣的鏡像)輸入conda create --name TensorFlow python=3.5.4

3.輸入pip install --index-url https://pypi.douban.com/simple tensorflow==1.12

4.tensorflow安裝完成後輸入activate tensorflow,表示激活tensorflow,激活後會顯示:

    接下來的每一行之前都會有 "(tensorflow)"

5.輸入pip install opencv-python

6.(這裏和下面都使用了清華的鏡像)輸入pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-contrib-python

7.輸入pip install -i https://pypi.tuna.tsinghua.edu.cn/simple numpy==1.14.5

8.輸入pip install -i https://pypi.tuna.tsinghua.edu.cn/simple keras==2.2.4

9.輸入pip install -i https://pypi.tuna.tsinghua.edu.cn/simple matplotlib

10.輸入pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pillow

到這裏就安裝好了。

 

2.把tensorflow導入pycharm

參考https://blog.csdn.net/discoverer100/article/details/84312674

1.首先File -> Settings

2.在Project Interpreter欄裏點右上角那個齒輪

3.然後點Add

4.如圖所示

5.選擇tensorflow安裝目錄中的python.exe,然後全OK就好了

3.圖片檢測

1.點這裏,命令行的方式運行

2.輸入python yolo_video.py --image,會出現輸入圖片名的提示:

3.輸入圖片名

4.運行結果如下:

4.視頻檢測

輸入

python yolo_video.py  --input D:/QQ文件/代碼/python/yolov3-phone-detection/data/3.mp4 --output D:/QQ文件/代碼/python/yolov3-phone-detection/data/res.mp4

加粗的部分是待處理視頻的路徑和自定義的檢測結果輸出路徑

運行就可以,運行後結果會出現在剛纔設置的文價夾下

5.調用攝像頭檢測

(1)修改yolo.py第203行,去掉第二個參數,將第204行修改成vid = cv2.VideoCapture(0)

         修改前:

         修改後:(0是默認打開攝像頭)


(2)修改yolo_video.py第78行,去掉第二個參數

         修改前:

             修改後:


(3)命令行輸入python yolo_video.py --input

運行結果:

哈哈哈哈哈哈哈哈哈哈見笑

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章