Skip to main content

FOMO - Lightweight Point Localization models.

Project description

FOMO: Fast Object Localization

FOMO is a lightweight MobileNetV2-based point localization model designed for edge AI applications. Instead of regressing bounding boxes, FOMO downsamples the input image (for example, mapping a 192x192 input to a 24x24 grid) and predicts class probabilities and coordinates on a per-cell basis. This makes it highly efficient and ideal for counting tasks such as headcount, queue monitoring, and item counting.

Installation

Install the package via PyPI:

pip install fomo-edge-ai

Or install from source in editable mode:

git clone https://github.com/fomo-edge-ai/fomo.git
cd fomo
pip install -e .

Example: Training and Inference

The following example demonstrates how to train a model on the SJSU Headcount dataset and perform inference on validation images.

1. Download the Dataset

The dataset should be in standard YOLO-format layout. You can download the dataset from Hugging Face:

from pathlib import Path
from huggingface_hub import snapshot_download

DATASET_ROOT = Path("sjsu-headcount-scene-1")
snapshot_download(
    repo_id="bdanko/sjsu-headcount-scene-1",
    repo_type="dataset",
    local_dir=str(DATASET_ROOT),
    local_dir_use_symlinks=False
)

2. Training the Model

Initialize a new model and run training:

import torch
from fomo.models.fomo.model import FOMO

device = "cuda" if torch.cuda.is_available() else "cpu"

# Initialize model
model = FOMO(model_path=None, size="m", nb_classes=1, device=device)

# Start training (allows experimental training flag)
results = model.train(
    allow_experimental=True,
    data="sjsu-headcount-scene-1/data.yaml",
    epochs=10,
    batch=16,
    lr0=3e-4,
    device=device,
    project="runs/fomo",
    name="sjsu_headcount_m",
)

3. Inference and Visualization

Load the best checkpoint and run predictions:

from PIL import Image
from fomo import FOMO

# Load trained checkpoint
model = FOMO("runs/fomo/sjsu_headcount_m/weights/best.pt", device=device)

# Load image and predict
pil_img = Image.open("sjsu-headcount-scene-1/valid/images/sample.jpg").convert("RGB")
result = model.predict(pil_img, conf=0.80)

# Retrieve point coordinates (mapped back to original image resolution)
if result.points is not None and len(result.points) > 0:
    xy = result.points.xy.cpu().numpy()     # (N, 2) pixel coordinates
    confs = result.points.conf.cpu().numpy() # (N,) confidence scores
    
    for (px, py), conf in zip(xy, confs):
        print(f"Detected object at: x={px:.1f}, y={py:.1f} with confidence {conf:.2f}")

License

Code is licensed under the Apache License 2.0. Pre-trained weights are hosted externally and may inherit separate licensing terms. Check details in the specific weight repositories.

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

fomo_edge_ai-0.0.2.tar.gz (694.1 kB view details)

Uploaded Source

Built Distribution

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

fomo_edge_ai-0.0.2-py3-none-any.whl (732.2 kB view details)

Uploaded Python 3

File details

Details for the file fomo_edge_ai-0.0.2.tar.gz.

File metadata

  • Download URL: fomo_edge_ai-0.0.2.tar.gz
  • Upload date:
  • Size: 694.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for fomo_edge_ai-0.0.2.tar.gz
Algorithm Hash digest
SHA256 388f8592396364401c5a1b8b4920f8f27c03b4d4f1acef6193af39978087d58e
MD5 8625f936c1e9df2b2d990b654a43b7c7
BLAKE2b-256 23ef19015bf79f0f3157a90200514f0080f1eb57808ccfab7b59c137aa43c7fe

See more details on using hashes here.

File details

Details for the file fomo_edge_ai-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: fomo_edge_ai-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 732.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for fomo_edge_ai-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d06be794d8ea29a3f250ca3560328f3cd68dbdafcbc211e0d9c70dc3d071857d
MD5 5fb287b67e2d662ebc039edfdc606ae8
BLAKE2b-256 c78b276f211f867f8d2a96e06a24fda33fd5b1a3078f5c2f6eb331e5b8bdcd6b

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