Skip to main content

YO-FLO: A proof-of-concept in using advanced vision models as a YOLO alternative.

Project description

YOFLO

Real-time object detection and visual Q&A using Microsoft Florence-2. Like YOLO, but with language understanding.

Install

pip install yoflo

Quick Start

# Download model and run object detection on webcam
python -m yoflo -dm -od

# Or use the daemon for repeated fast queries
python -m yoflo.daemon start --model large
python -m yoflo.daemon query --image photo.jpg --action detect
python -m yoflo.daemon query --image photo.jpg --question "Is there a cat?" --action ask

Features

Object Detection (-od)

Detect objects in video streams or images.

# Detect all objects
python -m yoflo -dm -od

# Filter to specific classes
python -m yoflo -dm -od person car dog

# From RTSP stream
python -m yoflo -dm -od -rtsp rtsp://192.168.1.100:554/stream

# From YouTube live stream
python -m yoflo -dm -od -yt "https://www.youtube.com/watch?v=..."

Yes/No Questions (-ph)

Ask binary questions about what the model sees.

python -m yoflo -dm -ph "Is the door open?"
python -m yoflo -dm -ph "Is anyone wearing a hard hat?"

Inference Chains (-ic)

Ask multiple questions per frame. Returns PASS if 2+ are true.

python -m yoflo -dm -ic "Is there a person?" "Are they seated?" "Are they at a desk?"

Headless Mode (-hl)

No GUI window. Use on servers or for better performance (~20% faster).

python -m yoflo -dm -od -hl

Screenshot on Detection (-ss)

Auto-save timestamped screenshots when objects are detected.

python -m yoflo -dm -od cat -ss

Logging (-lf)

Write detections to alerts.log.

python -m yoflo -dm -od -lf

Video Recording (-r)

Record video based on triggers.

# Record when objects detected
python -m yoflo -dm -od -r od

# Record when inference is "yes", stop on "no"
python -m yoflo -dm -ph "Is there motion?" -r infy

# Record when inference is "no", stop on "yes"
python -m yoflo -dm -ph "Is the area clear?" -r infn

Multi-Camera (-wi, -rtsp)

Monitor multiple feeds simultaneously.

# Multiple webcams
python -m yoflo -dm -od -wi 0 1 2

# Multiple RTSP streams
python -m yoflo -dm -od -rtsp rtsp://cam1/stream rtsp://cam2/stream

Inference Rate Control (-il, -ir)

# Limit to 5 inferences per second
python -m yoflo -dm -od -il 5

# Display inference rate
python -m yoflo -dm -od -ir

Pretty Print (-pp)

Formatted detection output instead of raw JSON.

python -m yoflo -dm -od -pp

4-Bit Quantization (-4bit)

Reduce VRAM usage with quantized model.

python -m yoflo -dm -od -4bit

PTZ Camera Control

Control pan/tilt/zoom cameras via HID (USB) or ONVIF (IP network).

HID PTZ (Logitech PTZ Pro, etc.):

pip install hid

# Manual PTZ control with keyboard
python -m yoflo -dm -od -ptz

# Auto-track an object class
python -m yoflo -dm -od person -ptz track -to person

ONVIF PTZ (Hikvision, Dahua, Axis, most IP cameras):

pip install onvif-zeep
# or: pip install yoflo[onvif]

# Connect to ONVIF camera and auto-track
python -m yoflo -dm -od person -onvif 192.168.1.100 -onvif-user admin -onvif-pass password -to person

# ONVIF will auto-detect the camera's RTSP stream if no other source specified
Flag Description
-ptz Enable HID PTZ (USB cameras)
-onvif HOST Enable ONVIF PTZ (IP cameras)
-onvif-port N ONVIF port (default: 80)
-onvif-user USER ONVIF username (default: admin)
-onvif-pass PASS ONVIF password
-to CLASS Object class to auto-track

Daemon Mode

Keep the model loaded in memory for fast repeated queries. No 90-second reload each time.

# Start daemon (loads model once)
python -m yoflo.daemon start --model large

# Query instantly
python -m yoflo.daemon query --image photo.jpg --action detect
python -m yoflo.daemon query --image "https://youtube.com/watch?v=..." --action detect
python -m yoflo.daemon query --image photo.jpg --question "Do you see a car?" --action ask

# Check status
python -m yoflo.daemon status

# Stop daemon
python -m yoflo.daemon stop

Python client:

from yoflo.client import YofloClient

client = YofloClient()
detections = client.detect("image.jpg")
answer = client.ask("image.jpg", "Is there a person?")

Model Options

Model Size Flag
Florence-2-base-ft 233M params --model base
Florence-2-large-ft 770M params --model large

Use -dm to auto-download, or -mp /path/to/model for local models.

All Flags

Flag Description
-dm Download model from HuggingFace
-mp PATH Use local model directory
-od [CLASSES] Object detection (optional class filter)
-ph QUESTION Yes/no question
-ic Q1 Q2 ... Inference chain (multiple questions)
-hl Headless mode (no display)
-ss Screenshot on detection
-lf Log to alerts.log
-ir Display inference rate
-il N Limit to N inferences/second
-pp Pretty print output
-wi 0 1 2 Webcam indices
-rtsp URL ... RTSP stream URLs
-yt URL YouTube live stream URL
-r od|infy|infn Recording trigger mode
-4bit 4-bit quantization
-ptz [track] HID PTZ control (USB cameras)
-onvif HOST ONVIF PTZ control (IP cameras)
-onvif-port N ONVIF port (default: 80)
-onvif-user USER ONVIF username
-onvif-pass PASS ONVIF password
-to CLASS Object class to track

Requirements

  • Python 3.8+
  • CUDA GPU with 8GB+ VRAM (16GB recommended for large model)
  • Works on Windows, Linux, macOS

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yoflo-1.4.0.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yoflo-1.4.0-py3-none-any.whl (23.2 kB view details)

Uploaded Python 3

File details

Details for the file yoflo-1.4.0.tar.gz.

File metadata

  • Download URL: yoflo-1.4.0.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for yoflo-1.4.0.tar.gz
Algorithm Hash digest
SHA256 94636850165b7b3a683f9f76cccb84e7ee544ff1e7f9ee8bc0ec378311e7b2fe
MD5 ae6b9206600ae8863353ce1eacb32c41
BLAKE2b-256 17bec62633bbac90d325feec5cccfb001484f4634178dd01fdaa5ac90725c1c1

See more details on using hashes here.

File details

Details for the file yoflo-1.4.0-py3-none-any.whl.

File metadata

  • Download URL: yoflo-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 23.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for yoflo-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 58741489eaf6d1cf734bc5b519ea79ce816090494f82dab35c554b2358f8a1c9
MD5 5423511157cb51b0471a82a472a64efd
BLAKE2b-256 5bd2811be427e316959dce3abd40d0abe2967047a37c568fde2572ebc87b549a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page