A minimal working example of a video analytics framework with object detection (YOLOv8n) as the backend task.
- Self-contained: all you need is contained in this repo, e.g., the model checkpoint, the dataset, the example log file and results plot, etc
- Two roles:
edge
to send frames, andcloud
to infer - Communication: implemented with Socket, lightweight and efficient
- Performance monitor: an easy implementation to log and show performance
- Evaluator: automatically generate ground truth results and evaluate results
- Multi-thread: a single procedure implemented as a thread, working in pipelines
- Multi-task running: easy to run a bunch of task in one script
- Plot example: an actual example of how to plot the expected figure
- Modify
HOME_DIR
insrc/config.yaml
to the actual location, changeshow_image
to False if you do not have a screen available - In one terminal,
cd src/ && python edge.py
- In another terminal,
cd src/ && python cloud.py
- Enjoy!
dataset/
: used to host the dataset, or point to the actual datasetground_truth/
: used to host the ground truth results, one folder for a videolog/
: used to save logsmodels/
: used to host model checkpointsplot/
: used to save data analysis resultsresults/
: used to host experimental results datasrc/
:config.yaml
: configuration parameters for edge and cloudedge.py
: code for the edge sidecloud.py
: code for the cloud sidelog.txt
: log filetools/
:video_source.py
: a loader to read in videos/imagesutils.py
: miscelleneous utility functionslog.py
: logging scriptssocket.py
: communications sockets between edge and cloudperf.py
: performance monitoreval.py
: evaluation scriptsimage_codecs.py
: encoding and decoding images
pip install ultralytics
pip install SciencePlots
others are common packages
- Modify code to fit your own scenario, e.g., task, role of edge and cloud, encoding/decoding, frame filtering, etc
- Best to check actual performance with a screen for debugging
- Best to set all path in the code to absolute path starting with
/
, because the code will be called by other scripts (i.e.,run.py
) - If you have a bug in the code when modifying it, the
edge.py
andcloud.py
may not exit correctly, which will result in thesocket
to be still in use without the resource being released. Just wait one or two minutes and then it would be good again.