Yolo scripts

=== commands ===
./darknet detector demo ./cfg/coco.data ./cfg/yolov3.cfg ./yolov3.weights farm.mp4 -i 0 -thresh 0.30
./darknet detector demo ./cfg/coco.data ./cfg/yolov3.cfg ./yolov3.weights japan.mp4 -i 0 -thresh 0.25
./darknet detector demo ./cfg/yolo9000.data ./cfg/yolov3.cfg ./yolov3.weights car2.mp4 -i 0 -thresh 0.30
./darknet detector demo ./cfg/coco.data ./cfg/yolov3.cfg ./yolov3.weights test.mp4 -i 0 -thresh 0.25 -ext_output > result.txt
./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights http://192.168.1.201:8081//video?dummy=param.mjpg -i 0
./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights http://192.168.1.201:8081//video?dummy=param.mjpg -i 0 -ext_output > res.txt
=== folder detection images ===
https://groups.google.com/forum/?nomobile=true#!topic/darknet/w60i9rlxx8w
#!/bin/bash
#cd /home/siddique/Desktop
ls /home/siddiquemu/Desktop/Homography/stitching/cam8/*.png > \
/home/siddiquemu/Desktop/Homography/stitching/cam8/cam8list.txt
cd /home/siddiquemu/Desktop/Homography/stitching/cam8
declare -i var=10000
for path in $(cat camlist.txt)
 do #echo $path
 cd ../
 cd /home/siddiquemu/darknet
 ./darknet detect cfg/yolo.cfg yolo.weights -thresh 0.25 $path
 echo $path
 #Copy result from darknet root to anaother folder with original name
 cp /home/siddiquemu/darknet/predictions.png \
 /home/siddiquemu/Desktop/yoloResult/cam8/$var.png
 var=$var+1
Solved it through python.darknet or darknet.py, you can get it from pjreddie github link for darknet. Git clone it and keep GPU = 1 (If you need to run with GPU) in Makefile
Then run make in this folder (cd darknet). After successful make, try this:
import python.darknet
import os, sys
import numpy as np
from PIL import Image
import matplotlib.pyplot as plt
import matplotlib.patches as patches
net = python.darknet.load_net(b"config/yolo-obj.cfg",b"backup/yolo-obj_4100.weights",0)
meta = python.darknet.load_meta(b"config/obj.data")
folder = "test_images/"
files = os.listdir(folder)
for f in files:
 if f.endswith(".jpg") or f.endswith(".jpeg") or f.endswith(".png"):
 print (f)
 path = bytes(os.path.join(folder, f), encoding="utf-8")
 r = python.darknet.detect(net, meta, path)
 print(r)
 name = r[0][0]
 predict = r[0][1]
 
 x = r[0][2][0]
 y = r[0][2][1]
 w = r[0][2][2]
 z = r[0][2][3]
 
 x_max = (2*x+w)/2
 x_min = (2*x-w)/2
 y_min = (2*y-z)/2
 y_max = (2*y+z)/2
 print(x_min, y_min, x_max, y_max)
 image = Image.open(path)
 cropped = image.crop((x_min, y_min+20, x_max, y_max))
 saving_path = "crop_images/"+f
 save_file = open(saving_path, 'w')
 cropped.save(saving_path)
 save_file.close()
This will return cropped images based on predicted coordinates
P.S: Use GPU for faster results or else it takes at least for seconds for one detection even though weights were being loaded only once
Hope this helps
=== links ===
Yolo
Category:Yolo
Category:Neural networks yolo