Darknet/YOLO v5.0-117-g31c55275-dirty
Object Detection Framework
 
Loading...
Searching...
No Matches
example Namespace Reference

Variables

str cfg_file = "../cfg/yolov4-tiny.cfg"
 
 class_names = open(names_file).read().splitlines()
 
 colours = darknet.class_colors(class_names)
 
 darknet_image = darknet.make_image(width, height, 3)
 
 detections = darknet.detect_image(network, class_names, darknet_image, thresh=prediction_threshold)
 
 height = darknet.network_height(network)
 
 image_bgr = cv2.imread(filename)
 
 image_resized = cv2.resize(image_rgb, (width, height), interpolation=cv2.INTER_LINEAR)
 
 image_rgb = cv2.cvtColor(image_bgr, cv2.COLOR_BGR2RGB)
 
 image_with_boxes = darknet.draw_boxes(detections, image_resized, colours)
 
str log_file = "output.log"
 
str names_file = "../cfg/coco.names"
 
 network = darknet.load_net_custom(cfg_file.encode("ascii"), weights_file.encode("ascii"), 0, 1)
 
float prediction_threshold = 0.5
 
str weights_file = "../yolov4-tiny.weights"
 
 width = darknet.network_width(network)
 

Detailed Description

This is EXAMPLE python code showing how to use the Python darknet module.
It is NOT a final application!  You must modify this example to make it do what you need.

Variable Documentation

◆ cfg_file

str example.cfg_file = "../cfg/yolov4-tiny.cfg"

◆ class_names

example.class_names = open(names_file).read().splitlines()

◆ colours

example.colours = darknet.class_colors(class_names)

◆ darknet_image

example.darknet_image = darknet.make_image(width, height, 3)

◆ detections

◆ height

example.height = darknet.network_height(network)

◆ image_bgr

example.image_bgr = cv2.imread(filename)

◆ image_resized

example.image_resized = cv2.resize(image_rgb, (width, height), interpolation=cv2.INTER_LINEAR)

◆ image_rgb

example.image_rgb = cv2.cvtColor(image_bgr, cv2.COLOR_BGR2RGB)

◆ image_with_boxes

example.image_with_boxes = darknet.draw_boxes(detections, image_resized, colours)

◆ log_file

str example.log_file = "output.log"

◆ names_file

str example.names_file = "../cfg/coco.names"

◆ network

example.network = darknet.load_net_custom(cfg_file.encode("ascii"), weights_file.encode("ascii"), 0, 1)

◆ prediction_threshold

float example.prediction_threshold = 0.5

◆ weights_file

str example.weights_file = "../yolov4-tiny.weights"

◆ width

example.width = darknet.network_width(network)