centos7安裝視頻標註工具vatic
https://www.zhihu.com/video/921676593573801984
前言:若你跟著官方cvondrick/vatic 文檔做的話一定會痛不欲生踩坑無數。。。不要問我怎麼知道的,希望此篇可以幫助和我一樣正在踩坑的小夥伴們。
centos是現成的,先裝docker
yum -y install dockeryum makecache fast
配置一下阿里鏡像加速器(需要登錄阿里賬號查看地址替換掉XXXXX)
vim /etc/docker/daemon.json{ "registry-mirrors": ["XXXXXXX"]}sudo systemctl daemon-reloadsudo systemctl restart dockersystemctl enable docker
ok,下面安裝vatic
docker pull jldowns/vatic-docker
裝好後啟動
docker run -t -i -P jldowns/vatic-docker /bin/bashcd /root/vatic./startup.shturkic status --verify
複製一個SSH隧道
docker ps -l
會看到埠映射的地址,我的是32771
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESe3786c618f69 jldowns/vatic-docker "/bin/bash" 41 seconds ago Up 38 seconds 0.0.0.0:32771->80/tcp, 0.0.0.0:32770->443/tcp desperate_newton
然後去瀏覽器輸入地址就可以看到頁面了。。。。
啟動docker時用
docker run -t -i -P -v /home/ffmpeg-project:/root/vatic/ffmpeg-project --privileged=true jldowns/vatic-docker /bin/bash
可以把本地/home/ffmpeg-project目錄映射到docker的/root/vatic/ffmpeg-project目錄
在centos /home/ffmpeg-project目錄下放入一些視頻,並創建directory目錄,若你已經安裝ffmpeg,可以寫一個小腳本批量轉換視頻【在宿主機轉碼可以獲得更好的性能】
vi convert_mp4_to_jpg.sh#!/bin/bash#Program:# convert MP4 to jpg#History:#2017/12/02 raulxty@163.com First releasePATH=/root/anaconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/binexport PATHfilelist=$(find *.mp4)OLDIFS="$IFS"IFS=$"
"for filename in *.mp4#$(find -iname *.mp4)do mkdir "ffout-${filename%.*}" ffmpeg -i $filename /home/ffmpeg-project/"ffout-${filename%.*}"/%03d.jpgdoneIFS=$OLDIFS
很快就把所有視頻變成圖片幀啦!
將視頻格式化為vatic可以理解的格式:
turkic formatframes ffmpeg-project/ffout-*/ ffmpeg-project/directory
導入視頻:
turkic load aaa ffmpeg-project/directory/ Car Person Bicycle Fence IndicatorLight indicator LaneLine Tricycle zebraCrossing --offline
aaa是識別碼,ffmpeg-project/directory/是圖片幀目錄,後面的Car,Person等是標籤,--offline 表示不發布亞馬遜Mturk
發布命令:
turkic publish --offline
刪除視頻
turkic delete aaa --force
一次完整的批量視頻發布流程
#!/bin/bashfind /root/vatic/ffmpeg-project/import/VideoDownload/*.mp4 >/root/vatic/ffmpeg-project/import/Video.listcd /root/vaticsed -i s/.mp4//g /root/vatic/ffmpeg-project/import/Video.listsed -i s//root/vatic/ffmpeg-project/import/VideoDownload///g /root/vatic/ffmpeg-project/import/Video.list#cat /root/vatic/ffmpeg-project/import/Video.list | while read linefor line in $(cat /root/vatic/ffmpeg-project/import/Video.list)do mkdir /root/vatic/ffmpeg-project/import/JPG2format/$line turkic extract /root/vatic/ffmpeg-project/import/VideoDownload/"${line}.mp4" /root/vatic/ffmpeg-project/import/JPG2format/$line --no-resize turkic load $line /root/vatic/ffmpeg-project/import/JPG2format/$line car people middleMedian offsideMedian curb roadBarriers roadSign streetLight fence reflector vegetation manholeCover flyover ditch retainingWall High-speedDrain trashCan telephoneBooth OtherBoxes busStop police checkpoint --offline;done
發布任務
turkic publish --offline
一次完整的批量視頻導出流程
vi /root/vatic/ffmpeg-project/output/output.list#!/bin/bashfor outputdlist in $(cat /root/vatic/ffmpeg-project/output/output.list)do turkic dump $outputdlist -o /root/vatic/ffmpeg-project/output/OutputXML/"${outputdlist}.xml" --merge --xml mkdir /root/vatic/ffmpeg-project/output/OutputJPG/$outputdlist turkic visualize $outputdlist /root/vatic/ffmpeg-project/output/OutputJPG/$outputdlist --merge --labels --renumber ffmpeg -f image2 -i /root/vatic/ffmpeg-project/output/OutputJPG/$outputdlist/%d.jpg /root/vatic/ffmpeg-project/output/OutputVideo/"${outputdlist}.mp4"donetar cvf /root/vatic/ffmpeg-project/output.tar /root/vatic/ffmpeg-project/output cd /root/vatic/ffmpeg-project/output/OutputJPGrm -rf *cd /root/vatic/ffmpeg-project/output/OutputXMLrm -rf *cd /root/vatic/ffmpeg-project/output/OutputVideorm -rf *echo "execution succeed,it is at /root/vatic/ffmpeg-project/output.tar"
推薦閱讀:
※FoolNLTK中文詞法分析工具
※日本用AI進行計程車調度:能準確預測需求,並幫助公司提高營業額
※AI大事件 | 斯坦福初創公司發力AI硬體,DeepMind刪除神經元了解深度學習
※使用 Tensorflow 構建生成式對抗網路(GAN)
TAG:AI技術 |