Install fotonet
fotonet is a pure-Python library with no compiled extensions of its own. One command installs it, and the first call downloads the verified release weights automatically.
From PyPI
python -m pip install fotonetRequires Python 3.10 or newer. PyTorch is installed as a dependency; install the CUDA build first if you want GPU acceleration and want to control the version:
# pick the PyTorch build you need, then:
python -m pip install fotonet
# verify
python -c "from fotonet import Fotonet; print(Fotonet('fotonete'))"The package is also on PyPI and the source is on GitHub. Both link back to this site.
Quick start
Fotonet("fotonete") resolves the release checkpoint for the model
generation you name, downloads it once, and caches it. You do not download weights by
hand and no weights live in the Git repository.
from fotonet import Fotonet
model = Fotonet("fotonete")
results = model.predict("image.jpg", conf=0.25, imgsz=640)
for det in results[0].boxes:
print(det.cls, det.conf, det.xyxy)For a BGR frame straight out of OpenCV:
import cv2
from fotonet import Fotonet
model = Fotonet("fotonete")
frame = cv2.imread("image.jpg")
results = model.predict_bgr(frame, conf=0.25, imgsz=640)First run downloads weights. The checkpoint is a few megabytes and is
cached under ~/.cache/fotonet/models. Later runs start instantly. Set
FOTONETE_CACHE_DIR to move the cache, or
FOTONETE_MODEL_PATH to pin a specific checkpoint file.
Devices
fotonet auto-detects CUDA and falls back to CPU, so the same code runs on a workstation and a laptop without configuration. On CPU it is slower but entirely usable for images and short clips; the benchmarks page has the numbers.
- GPU — CUDA is used automatically when a compatible device is visible to PyTorch.
- CPU — the default fallback. Set the device explicitly with
Fotonet("fotonete", device="cpu")to force it. - Browser — the exported ONNX model runs client-side through ONNX Runtime Web on WebGPU or WASM, which is what the live demo uses.
From source
git clone https://github.com/hazegreleases/fotonet.git
cd fotonet
python -m pip install -e ".[dev]"The full command-line interface ships with the package:
fotonet train model=fotonete data=coco.yaml epochs=300 imgsz=640
fotonet val model=fotonete data=coco.yaml imgsz=640
fotonet export model=fotonete format=onnx path=fotonete.onnxTraining and export details are on the documentation page.