Metadata-Version: 2.4
Name: owndet
Version: 0.1.0
Summary: Original anchor-free multi-scale object detector trained from scratch
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: torch<3.0,>=2.2
Requires-Dist: numpy<3.0,>=1.26
Requires-Dist: opencv-python<5.0,>=4.9
Requires-Dist: Pillow<13.0,>=10.2
Requires-Dist: PyYAML<7.0,>=6.0
Requires-Dist: tqdm<5.0,>=4.66
Provides-Extra: api
Requires-Dist: fastapi<1.0,>=0.115; extra == "api"
Requires-Dist: uvicorn[standard]<1.0,>=0.30; extra == "api"
Requires-Dist: python-multipart<1.0,>=0.0.9; extra == "api"
Provides-Extra: export
Requires-Dist: onnx<2.0,>=1.16; extra == "export"
Requires-Dist: onnxruntime<2.0,>=1.18; extra == "export"
Provides-Extra: visualization
Requires-Dist: matplotlib<4.0,>=3.8; extra == "visualization"
Provides-Extra: all
Requires-Dist: fastapi<1.0,>=0.115; extra == "all"
Requires-Dist: uvicorn[standard]<1.0,>=0.30; extra == "all"
Requires-Dist: python-multipart<1.0,>=0.0.9; extra == "all"
Requires-Dist: onnx<2.0,>=1.16; extra == "all"
Requires-Dist: onnxruntime<2.0,>=1.18; extra == "all"
Requires-Dist: matplotlib<4.0,>=3.8; extra == "all"
Requires-Dist: psutil<8.0,>=5.9; extra == "all"

# OwnDet

OwnDet is an original, anchor-free, multi-scale object detector implemented in
PyTorch and trained from random initialization without pretrained detector
weights.

## Install

```bash
pip install owndet
```

Install deployment and export features when needed:

```bash
pip install "owndet[api,export]"
```

## Python API

```python
import torch
from owndet import OwnDet

model = OwnDet(num_classes=5, variant="nano").eval()
with torch.inference_mode():
    p3, p4, p5 = model(torch.zeros(1, 3, 640, 640))
```

Load a training checkpoint:

```python
from owndet import load_model

model = load_model("best.pt", variant="small", device="cuda")
```

## Commands

```bash
owndet-check-dataset --root datasets/my_dataset --stage A
owndet-train --stage A --device cuda
owndet-evaluate --checkpoint best.pt --stage A
owndet-infer --image test.jpg --weights best.pt --stage A
owndet-api
```

## Development setup

This stage creates the development environment and verifies it. It deliberately
contains no detector architecture or training logic. Continue only when the
verification script ends with `RESULT: PASS`.

## Project structure

```text
owndet/
├── configs/
├── data/
│   └── __init__.py
├── datasets/
│   └── my_dataset/
│       ├── images/{train,val,test}/
│       ├── labels/{train,val,test}/
│       └── classes.txt
├── models/
│   └── __init__.py
├── losses/
│   └── __init__.py
├── utils/
│   └── __init__.py
├── engine/
│   └── __init__.py
├── scripts/
│   ├── __init__.py
│   └── check_environment.py
├── runs/
├── tests/
│   └── __init__.py
├── train.py
├── evaluate.py
├── inference.py
├── api.py
└── requirements.txt
```

The package directories are ready for later phases. The three top-level entry
points are intentional placeholders and do not yet train or run a model.

## Linux setup

Run from the directory that contains `owndet/`:

```bash
cd owndet
python3.11 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip setuptools wheel
```

For an NVIDIA GPU, install a PyTorch CUDA wheel first. The following uses CUDA
12.6; if the NVIDIA driver does not support it, choose the compatible command
from the official PyTorch installer instead:

```bash
python -m pip install torch --index-url https://download.pytorch.org/whl/cu126
python -m pip install -r requirements.txt
python scripts/check_environment.py
```

For a CPU-only installation:

```bash
python -m pip install torch --index-url https://download.pytorch.org/whl/cpu
python -m pip install -r requirements.txt
python scripts/check_environment.py
```

## Windows PowerShell setup

Run from the directory that contains `owndet/`:

```powershell
Set-Location owndet
py -3.11 -m venv .venv
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip setuptools wheel
```

For an NVIDIA GPU (CUDA 12.6 wheel):

```powershell
python -m pip install torch --index-url https://download.pytorch.org/whl/cu126
python -m pip install -r requirements.txt
python scripts/check_environment.py
```

For CPU only:

```powershell
python -m pip install torch --index-url https://download.pytorch.org/whl/cpu
python -m pip install -r requirements.txt
python scripts/check_environment.py
```

PyTorch publishes platform-specific commands. Before installing on a different
CUDA runtime, select the current stable build, operating system, Pip, Python,
and the appropriate compute platform at <https://pytorch.org/get-started/locally/>.
The CUDA toolkit does not normally need to be installed separately for PyTorch
wheels, but the NVIDIA driver must be compatible.

## Expected output

Exact versions and hardware names will differ. A successful CUDA system looks
similar to:

```text
OwnDet Stage 0 environment check
================================
[PASS] Python: 3.11.x
[PASS] PyTorch: 2.x.x+cuXXX
[PASS] OpenCV: 4.x.x
...
System details
--------------
CPU: ...
System RAM: 31.20 GiB
PyTorch CUDA build: 12.x
CUDA available: True
GPU 0: NVIDIA ...
GPU 0 memory: ... GiB

RESULT: PASS - environment is ready for Stage 1.
```

A CPU-only machine can also pass. In that case, `CUDA available: False` and
`No CUDA GPU detected; CPU inference remains supported` are expected.

## Verification test

The command below must exit with status code `0`:

Linux:

```bash
python scripts/check_environment.py && echo "Stage 0 passed"
```

Windows PowerShell:

```powershell
python scripts/check_environment.py
if ($LASTEXITCODE -eq 0) { Write-Host "Stage 0 passed" } else { throw "Stage 0 failed" }
```

## Troubleshooting

- `python3.11: command not found`: install Python 3.11, then recreate `.venv`.
- PowerShell blocks activation: run the process-scoped `Set-ExecutionPolicy`
  command above; it does not permanently change the machine policy.
- A dependency reports `not importable`: confirm the prompt shows `(.venv)`,
  then rerun `python -m pip install -r requirements.txt`.
- `CUDA available: False` on an NVIDIA machine: run `nvidia-smi`. If it fails,
  install/update the NVIDIA driver. If it works, reinstall PyTorch using a CUDA
  build supported by that driver and selected on the official PyTorch page.
- `No matching distribution found`: verify `python --version` is Python 3.11,
  upgrade pip, and confirm the OS/CPU architecture is supported.
- Out-of-memory errors are not part of this check. Later phases will tune batch
  size; this phase only reports total GPU and system memory.
