Created on 05-15-201802:40 AM - edited 08-17-201907:29 AM
Integrating Darknet YOLOv3 Into Apache NiFi Workflows
Darknet has released a new version of YOLO, version 3. This one is a faster and perhaps more accurate. It's new and shiny and I had to try it. I am liking the results.
Flow to Execute Script
We call the shell script, then I route out the empty results. I use SplitText to split into individual lines. I use ExtractText with ([^:]+):(.*) to split into our name, value pairs.
We also want to process the images produced by YOLOv3.
We grab the newest ones from the output directory. I also add meta data extraction and Tensorflow analysis. This data is stored in attributes and can be saved independently via using AttributesToJSON to build a new flow file that we save off separate probably converting into Apache ORC and storing in HDFS for Apache Hive querying. The image file we can store in the cloud, another file system, send to a front end or save in HDFS. Or even email it to someone.
The parsed YOLOv3 results in Apache NiFi Attributes. As you can see we would grab labelvalue.1 and labelvalue.2 to do our processing. We may want to send this to JMS or MQTT or Apache Kafka for further display in an application or dashboard.
This is an example of the result of our Extract Text.
This is the output that we parse with Apache NiFi
YOLOv3 also generates an image with rectangles and labels.
YOLOv3 does some great classification on multiple items in a picture. I use Python to capture an image from my webcam via OpenCV2. I wrap my call in a shell script that captures the image sends it to Darknet's build of YOLOv3 and send errors to /dev/null.
If you have a good GPU, you can compile with CUDA and OPENCV to do real-time off a webcam