介紹:
本文提出了自動化的Pruning方法,取代先前大多採用手動調整壓縮率的Pruning方式,在Fine-grained pruning和Structured pruning上都有不錯的效果。概念與NAS自動搜尋網路架構的方式很類似,幾乎不需要調整到Hyperparameter。三位作者皆來自Uber旗下的Uber ATG公司
Fine-grained pruning removes individual parameters from a network, and thus saves the storage space and benefits for embedded systems. Structured pruning, on the other hand, typically removes whole
channels (filters) from a network and thus achieves inference
speed-up with no need of any hardware specialization.
論文:
開發環境安裝
# PyTorch 1.6版本(CUDA 9.2版)pip install torch==1.6.0+cu92 torchvision==0.7.0+cu92 -f https://download.pytorch.org/whl/torch_stable.html# detectron2 (必須安裝0.2.1版本否則會錯誤)python -m pip install detectron2==0.2.1 -f \
https://dl.fbaipublicfiles.com/detectron2/wheels/cu92/torch1.6/index.html# lvis api (dataset設定)
pip install git+https://github.com/l …
卷積網路剪枝論文
YOLOv3/v4實作教學
建議透過以下兩篇文章理解剪枝程式的撰寫方式,但不採用這兩篇內文所提供的程式碼。原因在於作者所提供的程式碼似乎只適用於YOLOv3,我自己透過YOLOv4實測發現似乎會有一些Bug存在。
建議使用的程式碼
# 以PyTorch_YOLOv4-tiny為例:# 把train.py第408行的
SummaryWriter(comment=opt.name)
# 改成SummaryWriter("../../../../../../tensorflow/logs",comment=opt.name)
其中 "../../../../../../tensorflow/logs",代表的是相對路徑到根目錄中的tensorflow/logs資料夾。
它的作用原理就是將SummaryWriter寫入的內容從原本目前的資料夾(預設),移動到/root/notebooks/tensorflow當中。
1/8更新:絕對路徑也能正常使用,請讀者根據自己的需求進行調整測試。
1/10更新:每完成一次的訓練(例如300 epochs)後,請將logs資料夾移除,再重新建立logs資料夾,藉此清空前次訓練得到的紀錄。
介紹
ml-visuals專案提供了預先製作好的PPT檔案,使用者將所需的元素從該份PPT檔案複製到自己的簡報當中,並進行內容的修改即可。甚至,國外有人在寫論文時,也把ml-visuals所提供的元素,當成是模型的架構圖放在論文當中。
PPT連結
https://docs.google.com/presentation/d/11mR1nkIR9fbHegFkcFq8z9oDQ5sjv8E3JJp1LfLGKuk/edit#slide=id.p
GitHub連結
Example
實作的思路
在上文當中介紹了如何進行自動化標記圖片,我將其流程統整如下:
程式碼
今天在微信的公眾號上面看到這篇介紹g++、CMake和Makefile的文章,寫的還蠻簡單易懂的,能夠多少增加有關這方面的知識。尤其每次在使用YOLOv3或YOLOv4時,都必須先透過make指令來編譯darknet,卻不曾理解過Makefile當中所撰寫的內容,這篇文章,或許就是最好的入門文章之一
安裝OpenCV
# YOLOv5最低需求為4.1.2版本以上# 注意事項:安裝過新版本(4.4.0)的OpenCV會導致使用Webcam偵測時出現低FPS的問題,請依照此連結的指令安裝(4.2.0版本)
安裝YOLOv5
# 基本環境建置
git clone https://github.com/ultralytics/yolov5
cd yolov5
pip install -U pycocotools
pip install -r requirements.txt python detect.py --source file.jpg # image
file.mp4 # video
dir/ # directory
0 # webcam
'rtsp://170.93.1.139/rtplive/XXX' # rtsp
'http://11.50.2.8/PLTV/888/2/30/1.m3u8'
# http
安裝OpenCV
# 若後續會用到YOLOv5請透過以下連結的指令安裝(原因):
編譯Darknet
在編譯darknet之後遇到 error while loading shared libraries: libopencv_highgui.so.X.X: cannot open,請先參考下文進行編譯
$ git clone https://github.com/AlexeyAB/darknet.git
$ cd darknet$ nano MakefileGPU=1
CUDNN=1
CUDNN_HALF=1
OPENCV=1
AVX=0
OPENMP=1
LIBSO=1
ZED_CAMERA=0
ZED_CAMERA_v2_8=0
......
USE_CPP=0
DEBUG=0
ARCH= -gencode arch=compute_53,code=[sm_53,compute_53]$ make$ wget https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v4_pre/yolov4-tiny.weights#使用Webcam偵測
$ ./darknet detector demo cfg/coco.data cfg/yolov4-tiny.cfg yolov4-tiny.weights -c 0#使用CSI Camera偵測
$ ./darknet detector demo data/coco.data cfg/yolov4-tiny.cfg yolov4-tiny.weights " nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=3820, height=2464, framerate=21/1, format=NV12' ! nvvidconv flip-method=0 ! 'video/x-raw,width=960, height=616' ! nvvidconv ! nvegltransform ! …
程式碼
前陣子在做華為垃圾偵測專案的時候,就遇到了voc格式的轉換問題,當時是使用convert2Yolo搭配以下指令進行轉換:
python3 example.py --datasets VOC --img_path ../trainval/VOC2007/JPEGImages --label ../trainval/VOC2007/Annotations/ --convert_output_path ./yolo/ --img_type ".jpg" --manifest_path ./ --cls_list_file ../trainval/train_classes.txt
介紹
但是在pprp/voc2007_for_yolo_torch當中,作者提供了另一種進行格式轉換的方式。與convert2Yolo兩者都是不錯的選擇,但pprp提供的程式除了做格式轉換外還能按照比例切割訓練 / 測試 /驗證集,省下自己寫切割資料集程式的時間。