Apache NiFi, Python, YoLoV8, MinIO, S3, Images, Cameras, New York City
We can add a very easy to run Ultralytics YOLO v8 to hit against ingested cameraโs from New York City. As you can see the code is really simple, we just need to load the pretrained model and call predict with some parameters and the image.
from ultralytics import YOLO
import sys
import io
import shutil
shutil.rmtree('runs/detect')
Load a model
model = YOLO('yolov8n.pt') # pretrained YOLOv8n model
source = sys.argv[1]
results = model.predict(source, stream=False, save=True, imgsz=320, conf=0.5)
for r in results:
print(r.tojson())
Output
[
{
"name": "car",
"class": 2,
"confidence": 0.5163618922233582,
"box": {
"x1": 188.54917907714844,
"y1": 141.74185180664062,
"x2": 204.51304626464844,
"y2": 154.35519409179688
}
}
]
YOLOv9 added annotation
NiFi Flow
NiFi Detailed Steps
We invoke an HTTP URL from NY Open Data to get a list of all URLs. We send the metadata to a Kafka topic. We call the webcam URL to get the image. We save it to MinIO. We then save it local in a temporary file to get it analyzed by YOLOv8. We then retrieve the augmented image and send it to Slack.
Execute Shell Script Passing Argument to Python 3
META DATA
{
"Latitude" : 41.51472,
"Longitude" : -74.0733,
"ID" : "Skyline-9873",
"Name" : "I-87 MP 060.40 NB Just North of Interchange 17 (Newburgh/I-84)",
"DirectionOfTravel" : "Northbound",
"RoadwayName" : "I-87 - NYS Thruway",
"Url" : "https://511ny.org/map/Cctv/9873--43",
"VideoUrl" : "https://s58.nysdot.skyvdn.com:443/rtplive/TA_046/playlist.m3u8",
"Disabled" : false,
"Blocked" : false
}
RESOURCES
MinIO Event Notification Using Apache Nifi
This post covers how to configure event notifications on MinIO using Apache Nifi - resulting in fast, scalable andโฆ
blog.min.io
Working with S3 Compatible Data Stores via Apache NiFi
Working With S3 Compatible Data Stores (and handling single source failure) With the major outage of S3 in my region, Iโฆ
community.cloudera.com
Regions and Zones
Describes the Regions, Availability Zones, Local Zones, Outposts, and Wavelength Zones world-wide where you can hostโฆ
docs.aws.amazon.com
ultralytics/ultralytics/data at main ยท ultralytics/ultralytics
NEW - YOLOv8 ๐ in PyTorch > ONNX > OpenVINO > CoreML > TFLite - ultralytics/ultralytics/data at main ยทโฆ
github.com
Home
Explore a complete guide to Ultralytics YOLOv8, a high-speed, high-accuracy object detection & image segmentationโฆ
docs.ultralytics.com
Publish from Kafka, Persist on MinIO
Streaming data is a core component of the modern object storage stack. Whether the source of that data is an edgeโฆ
blog.min.io
Publish Events to Kafka
Table of Contents MinIO supports publishing bucket notification events to a Kafka service endpoint. MinIO relies on theโฆ
min.io
GitHub - IBM/sarama: Sarama is a Go library for Apache Kafka.
Sarama is a Go library for Apache Kafka. Contribute to IBM/sarama development by creating an account on GitHub.
github.com
GitHub - ultralytics/ultralytics: NEW - YOLOv8 ๐ in PyTorch > ONNX > OpenVINO > CoreML > TFLite
NEW - YOLOv8 ๐ in PyTorch > ONNX > OpenVINO > CoreML > TFLite - ultralytics/ultralytics
github.com
Predict
Discover how to use YOLOv8 predict mode for various tasks. Learn about different inference sources like images, videosโฆ
docs.ultralytics.com
Predict
Discover how to use YOLOv8 predict mode for various tasks. Learn about different inference sources like images, videosโฆ
docs.ultralytics.com
Apache Nifi
Python
Top comments (0)