- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Created on 05-15-2018 02:40 AM - edited 08-17-2019 07: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 Extract Text 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
Example Output:
/Volumes/seagate/models/darknet-master/images/yolo_image_img_20180514183707.jpg: Predicted in 26.351510 seconds. cell phone: 72% chair: 78% chair: 72% chair: 59% person: 100% chair: 83%
Example Run:
./darknet detect cfg/yolov3.cfg cfg/yolov3.weights /Volumes/seagate/StrataNYC2018/kafka.jpg
Source: https://github.com/tspannhw/nifi-yolo3/tree/master
Reference:
See: https://github.com/pjreddie/darknet See: https://pjreddie.com/darknet/yolo/
Download the training weights and data (https://pjreddie.com/media/files/yolov3.weights)
See: https://pjreddie.com/media/files/papers/YOLOv3.pd
@article{yolov3, title={YOLOv3: An Incremental Improvement}, author={Redmon, Joseph and Farhadi, Ali}, journal = {arXiv}, year={2018} }