fotonet 0.1.0a0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fotonet-0.1.0a0/MANIFEST.in +13 -0
- fotonet-0.1.0a0/PKG-INFO +165 -0
- fotonet-0.1.0a0/README.md +126 -0
- fotonet-0.1.0a0/docs/contributing.md +13 -0
- fotonet-0.1.0a0/docs/export.md +36 -0
- fotonet-0.1.0a0/docs/inference.md +63 -0
- fotonet-0.1.0a0/docs/installation.md +55 -0
- fotonet-0.1.0a0/docs/model-zoo.md +28 -0
- fotonet-0.1.0a0/docs/quickstart.md +42 -0
- fotonet-0.1.0a0/docs/release-checklist.md +16 -0
- fotonet-0.1.0a0/docs/security.md +5 -0
- fotonet-0.1.0a0/docs/training.md +53 -0
- fotonet-0.1.0a0/docs/transform-api.md +64 -0
- fotonet-0.1.0a0/examples/README.md +21 -0
- fotonet-0.1.0a0/examples/export_onnx.py +30 -0
- fotonet-0.1.0a0/examples/predict_folder.py +32 -0
- fotonet-0.1.0a0/examples/predict_image.py +30 -0
- fotonet-0.1.0a0/examples/train_custom_yolo.py +34 -0
- fotonet-0.1.0a0/examples/transform_crop.py +30 -0
- fotonet-0.1.0a0/examples/transform_example.py +5 -0
- fotonet-0.1.0a0/fotonet/__init__.py +32 -0
- fotonet-0.1.0a0/fotonet/_torch_notice.py +21 -0
- fotonet-0.1.0a0/fotonet/cli/__init__.py +0 -0
- fotonet-0.1.0a0/fotonet/cli/main.py +145 -0
- fotonet-0.1.0a0/fotonet/config/models/fotonetl-p2.yaml +29 -0
- fotonet-0.1.0a0/fotonet/config/models/fotonetl.yaml +32 -0
- fotonet-0.1.0a0/fotonet/config/models/fotonetm-p2.yaml +29 -0
- fotonet-0.1.0a0/fotonet/config/models/fotonetm.yaml +32 -0
- fotonet-0.1.0a0/fotonet/config/models/fotonetn-p2.yaml +30 -0
- fotonet-0.1.0a0/fotonet/config/models/fotonetn.yaml +30 -0
- fotonet-0.1.0a0/fotonet/config/models/fotonets-p2.yaml +29 -0
- fotonet-0.1.0a0/fotonet/config/models/fotonets.yaml +32 -0
- fotonet-0.1.0a0/fotonet/config/models/fotonetx-p2.yaml +29 -0
- fotonet-0.1.0a0/fotonet/config/models/fotonetx.yaml +32 -0
- fotonet-0.1.0a0/fotonet/config/recipes/fotonetn_scratch.yaml +129 -0
- fotonet-0.1.0a0/fotonet/data/__init__.py +0 -0
- fotonet-0.1.0a0/fotonet/data/augmentations/__init__.py +40 -0
- fotonet-0.1.0a0/fotonet/data/augmentations/boxes.py +126 -0
- fotonet-0.1.0a0/fotonet/data/augmentations/compose.py +114 -0
- fotonet-0.1.0a0/fotonet/data/augmentations/geometric.py +103 -0
- fotonet-0.1.0a0/fotonet/data/augmentations/hyp.py +55 -0
- fotonet-0.1.0a0/fotonet/data/augmentations/image.py +97 -0
- fotonet-0.1.0a0/fotonet/data/dataset.py +521 -0
- fotonet-0.1.0a0/fotonet/engine/__init__.py +0 -0
- fotonet-0.1.0a0/fotonet/engine/model.py +1038 -0
- fotonet-0.1.0a0/fotonet/engine/results.py +600 -0
- fotonet-0.1.0a0/fotonet/engine/runtime.py +121 -0
- fotonet-0.1.0a0/fotonet/engine/trainer.py +1486 -0
- fotonet-0.1.0a0/fotonet/export/__init__.py +3 -0
- fotonet-0.1.0a0/fotonet/export/backends.py +249 -0
- fotonet-0.1.0a0/fotonet/metrics/__init__.py +3 -0
- fotonet-0.1.0a0/fotonet/metrics/map.py +244 -0
- fotonet-0.1.0a0/fotonet/models/__init__.py +0 -0
- fotonet-0.1.0a0/fotonet/models/backbone.py +239 -0
- fotonet-0.1.0a0/fotonet/models/fotonet.py +112 -0
- fotonet-0.1.0a0/fotonet/models/head.py +264 -0
- fotonet-0.1.0a0/fotonet/models/neck.py +187 -0
- fotonet-0.1.0a0/fotonet/models/scales.py +98 -0
- fotonet-0.1.0a0/fotonet/utils/__init__.py +0 -0
- fotonet-0.1.0a0/fotonet/utils/boxes.py +79 -0
- fotonet-0.1.0a0/fotonet/utils/config.py +101 -0
- fotonet-0.1.0a0/fotonet/utils/general.py +13 -0
- fotonet-0.1.0a0/fotonet/utils/loss.py +659 -0
- fotonet-0.1.0a0/fotonet/utils/matcher.py +296 -0
- fotonet-0.1.0a0/fotonet/utils/nms.py +62 -0
- fotonet-0.1.0a0/fotonet.egg-info/PKG-INFO +165 -0
- fotonet-0.1.0a0/fotonet.egg-info/SOURCES.txt +71 -0
- fotonet-0.1.0a0/fotonet.egg-info/dependency_links.txt +1 -0
- fotonet-0.1.0a0/fotonet.egg-info/entry_points.txt +2 -0
- fotonet-0.1.0a0/fotonet.egg-info/requires.txt +22 -0
- fotonet-0.1.0a0/fotonet.egg-info/top_level.txt +1 -0
- fotonet-0.1.0a0/pyproject.toml +62 -0
- fotonet-0.1.0a0/setup.cfg +4 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
include README.md
|
|
2
|
+
include pyproject.toml
|
|
3
|
+
recursive-include docs *.md
|
|
4
|
+
recursive-include examples *.py *.md
|
|
5
|
+
recursive-include fotonet/config *.yaml
|
|
6
|
+
recursive-exclude datasets *
|
|
7
|
+
recursive-exclude dev-tools *
|
|
8
|
+
recursive-exclude docs/superpowers *
|
|
9
|
+
exclude examples/compare_fotonet_yolo_gt.py
|
|
10
|
+
recursive-exclude tests *
|
|
11
|
+
recursive-exclude logs *
|
|
12
|
+
recursive-exclude runs *
|
|
13
|
+
global-exclude __pycache__ *.py[cod] *.pt *.pth *.onnx *.engine *.torchscript *.metadata.json
|
fotonet-0.1.0a0/PKG-INFO
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fotonet
|
|
3
|
+
Version: 0.1.0a0
|
|
4
|
+
Summary: Lightweight NMS-free object detection with an Ultralytics-like API.
|
|
5
|
+
Author: FOTO-NET contributors
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/serionn/fotonet
|
|
8
|
+
Project-URL: Documentation, https://github.com/serionn/fotonet#readme
|
|
9
|
+
Project-URL: Source, https://github.com/serionn/fotonet
|
|
10
|
+
Keywords: object-detection,computer-vision,deep-learning,fotonet
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Image Recognition
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
Requires-Dist: numpy>=1.23
|
|
23
|
+
Requires-Dist: pillow>=9.0
|
|
24
|
+
Requires-Dist: pyyaml>=6.0
|
|
25
|
+
Requires-Dist: opencv-python>=4.7
|
|
26
|
+
Requires-Dist: matplotlib>=3.6
|
|
27
|
+
Requires-Dist: scipy>=1.10
|
|
28
|
+
Requires-Dist: tqdm>=4.64
|
|
29
|
+
Provides-Extra: metrics
|
|
30
|
+
Requires-Dist: pycocotools>=2.0.7; extra == "metrics"
|
|
31
|
+
Provides-Extra: export
|
|
32
|
+
Requires-Dist: onnx>=1.14; extra == "export"
|
|
33
|
+
Requires-Dist: onnxsim>=0.4.36; extra == "export"
|
|
34
|
+
Provides-Extra: dev
|
|
35
|
+
Requires-Dist: build>=1.2; extra == "dev"
|
|
36
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
37
|
+
Requires-Dist: tomli>=2.0; python_version < "3.11" and extra == "dev"
|
|
38
|
+
Requires-Dist: twine>=5.0; extra == "dev"
|
|
39
|
+
|
|
40
|
+

|
|
41
|
+
|
|
42
|
+
# FOTO-NET
|
|
43
|
+
|
|
44
|
+
FOTO-NET is a lightweight NMS-free object detector with an Ultralytics-like Python API and an application-friendly transform layer for working with detection boxes.
|
|
45
|
+
|
|
46
|
+
This is the alpha release, everything is subject to change. Not recommended for production workflows, just a demo of what is coming.
|
|
47
|
+
|
|
48
|
+
## What It Is
|
|
49
|
+
|
|
50
|
+
FOTO-NET focuses on practical object detection:
|
|
51
|
+
|
|
52
|
+
- compact model scales
|
|
53
|
+
- NMS-free one-to-one inference
|
|
54
|
+
- optional one-to-many training supervision
|
|
55
|
+
- small-object friendly P2 variants
|
|
56
|
+
- direct Python results objects
|
|
57
|
+
- transform helpers for crops, anchors, pixel movement, containment, and box manipulation
|
|
58
|
+
- export paths for ONNX, TorchScript, TensorRT, and CoreML where dependencies are available
|
|
59
|
+
|
|
60
|
+
## Alpha Status
|
|
61
|
+
|
|
62
|
+
The alpha release is intended for experimentation, training runs, integration tests, and feedback. The core Python API, training path, inference path, transform API, and ONNX export should be usable. CoreML export code exists, but it should not be treated as certified until fresh platform-specific verification is published.
|
|
63
|
+
|
|
64
|
+
## Install
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
git clone https://github.com/hazegreleases/fotonet.git
|
|
68
|
+
cd fotonet
|
|
69
|
+
python -m pip install torch torchvision numpy pillow pyyaml opencv-python matplotlib scipy tqdm
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Quick Start
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from fotonet import FOTONET
|
|
76
|
+
|
|
77
|
+
model = FOTONET("fotonetn")
|
|
78
|
+
results = model.predict("image.jpg", conf=0.25)
|
|
79
|
+
|
|
80
|
+
for box in results.boxes:
|
|
81
|
+
print(box.cls, box.conf, box.xyxy)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
CLI:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
python -m fotonet.cli.main predict model=fotonet-n source=image.jpg conf=0.25 save=true
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Transform API
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
from fotonet import AnchorPoint
|
|
94
|
+
|
|
95
|
+
box = results.boxes[0]
|
|
96
|
+
crop = (
|
|
97
|
+
box.transform
|
|
98
|
+
.setAnchor(AnchorPoint.CENTER)
|
|
99
|
+
.pixelExpand(40)
|
|
100
|
+
.clamp()
|
|
101
|
+
.crop(results.orig_img)
|
|
102
|
+
)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
The raw box formats remain available through `box.xywh`, `box.xyxy`, and `results.boxes.numpy()`.
|
|
106
|
+
|
|
107
|
+
## Training
|
|
108
|
+
|
|
109
|
+
FOTO-NET expects YOLO-format labels:
|
|
110
|
+
|
|
111
|
+
```text
|
|
112
|
+
class_id x_center y_center width height
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Train through Python:
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
from fotonet import FOTONET
|
|
119
|
+
|
|
120
|
+
model = FOTONET("fotonetn")
|
|
121
|
+
model.train(data="data.yaml", epochs=100, imgsz=640, batch=16)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Train through CLI:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
fotonet train model=fotonetn data=data.yaml epochs=100 imgsz=640 batch=16
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Export
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
from fotonet import FOTONET
|
|
134
|
+
|
|
135
|
+
model = FOTONET("fotonet-n")
|
|
136
|
+
model.export(format="onnx", path="dev-tools/runs/fotonet.onnx", imgsz=640)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Model Weights
|
|
140
|
+
|
|
141
|
+
The alpha repository includes `fotonet-n` as the public nano checkpoint. Training outputs and development weights live outside the public surface.
|
|
142
|
+
|
|
143
|
+
## Alpha Checkpoint Metrics
|
|
144
|
+
|
|
145
|
+
`fotonet-n` is the alpha nano checkpoint included in this repository.
|
|
146
|
+
|
|
147
|
+
| Checkpoint | mAP@.50:.95 | Parameters | MACs at 640 | GFLOPs at 640 |
|
|
148
|
+
|---|---:|---:|---:|---:|
|
|
149
|
+
| `fotonet-n` | 22.68% | 2.75M | 2.43G | 4.85G |
|
|
150
|
+
|
|
151
|
+
Inference times are not out yet because the benchmark computer is IO bottlenecked, so the timing numbers are not reliable enough to publish.
|
|
152
|
+
|
|
153
|
+
## Documentation
|
|
154
|
+
|
|
155
|
+
- Installation: `docs/installation.md`
|
|
156
|
+
- Quick start: `docs/quickstart.md`
|
|
157
|
+
- Inference: `docs/inference.md`
|
|
158
|
+
- Training: `docs/training.md`
|
|
159
|
+
- Export: `docs/export.md`
|
|
160
|
+
- Transform API: `docs/transform-api.md`
|
|
161
|
+
- Model zoo: `docs/model-zoo.md`
|
|
162
|
+
|
|
163
|
+
## License
|
|
164
|
+
|
|
165
|
+
FOTO-NET is licensed under the Apache License, Version 2.0.
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
# FOTO-NET
|
|
4
|
+
|
|
5
|
+
FOTO-NET is a lightweight NMS-free object detector with an Ultralytics-like Python API and an application-friendly transform layer for working with detection boxes.
|
|
6
|
+
|
|
7
|
+
This is the alpha release, everything is subject to change. Not recommended for production workflows, just a demo of what is coming.
|
|
8
|
+
|
|
9
|
+
## What It Is
|
|
10
|
+
|
|
11
|
+
FOTO-NET focuses on practical object detection:
|
|
12
|
+
|
|
13
|
+
- compact model scales
|
|
14
|
+
- NMS-free one-to-one inference
|
|
15
|
+
- optional one-to-many training supervision
|
|
16
|
+
- small-object friendly P2 variants
|
|
17
|
+
- direct Python results objects
|
|
18
|
+
- transform helpers for crops, anchors, pixel movement, containment, and box manipulation
|
|
19
|
+
- export paths for ONNX, TorchScript, TensorRT, and CoreML where dependencies are available
|
|
20
|
+
|
|
21
|
+
## Alpha Status
|
|
22
|
+
|
|
23
|
+
The alpha release is intended for experimentation, training runs, integration tests, and feedback. The core Python API, training path, inference path, transform API, and ONNX export should be usable. CoreML export code exists, but it should not be treated as certified until fresh platform-specific verification is published.
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
git clone https://github.com/hazegreleases/fotonet.git
|
|
29
|
+
cd fotonet
|
|
30
|
+
python -m pip install torch torchvision numpy pillow pyyaml opencv-python matplotlib scipy tqdm
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Quick Start
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from fotonet import FOTONET
|
|
37
|
+
|
|
38
|
+
model = FOTONET("fotonetn")
|
|
39
|
+
results = model.predict("image.jpg", conf=0.25)
|
|
40
|
+
|
|
41
|
+
for box in results.boxes:
|
|
42
|
+
print(box.cls, box.conf, box.xyxy)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
CLI:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
python -m fotonet.cli.main predict model=fotonet-n source=image.jpg conf=0.25 save=true
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Transform API
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from fotonet import AnchorPoint
|
|
55
|
+
|
|
56
|
+
box = results.boxes[0]
|
|
57
|
+
crop = (
|
|
58
|
+
box.transform
|
|
59
|
+
.setAnchor(AnchorPoint.CENTER)
|
|
60
|
+
.pixelExpand(40)
|
|
61
|
+
.clamp()
|
|
62
|
+
.crop(results.orig_img)
|
|
63
|
+
)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The raw box formats remain available through `box.xywh`, `box.xyxy`, and `results.boxes.numpy()`.
|
|
67
|
+
|
|
68
|
+
## Training
|
|
69
|
+
|
|
70
|
+
FOTO-NET expects YOLO-format labels:
|
|
71
|
+
|
|
72
|
+
```text
|
|
73
|
+
class_id x_center y_center width height
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Train through Python:
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from fotonet import FOTONET
|
|
80
|
+
|
|
81
|
+
model = FOTONET("fotonetn")
|
|
82
|
+
model.train(data="data.yaml", epochs=100, imgsz=640, batch=16)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Train through CLI:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
fotonet train model=fotonetn data=data.yaml epochs=100 imgsz=640 batch=16
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Export
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
from fotonet import FOTONET
|
|
95
|
+
|
|
96
|
+
model = FOTONET("fotonet-n")
|
|
97
|
+
model.export(format="onnx", path="dev-tools/runs/fotonet.onnx", imgsz=640)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Model Weights
|
|
101
|
+
|
|
102
|
+
The alpha repository includes `fotonet-n` as the public nano checkpoint. Training outputs and development weights live outside the public surface.
|
|
103
|
+
|
|
104
|
+
## Alpha Checkpoint Metrics
|
|
105
|
+
|
|
106
|
+
`fotonet-n` is the alpha nano checkpoint included in this repository.
|
|
107
|
+
|
|
108
|
+
| Checkpoint | mAP@.50:.95 | Parameters | MACs at 640 | GFLOPs at 640 |
|
|
109
|
+
|---|---:|---:|---:|---:|
|
|
110
|
+
| `fotonet-n` | 22.68% | 2.75M | 2.43G | 4.85G |
|
|
111
|
+
|
|
112
|
+
Inference times are not out yet because the benchmark computer is IO bottlenecked, so the timing numbers are not reliable enough to publish.
|
|
113
|
+
|
|
114
|
+
## Documentation
|
|
115
|
+
|
|
116
|
+
- Installation: `docs/installation.md`
|
|
117
|
+
- Quick start: `docs/quickstart.md`
|
|
118
|
+
- Inference: `docs/inference.md`
|
|
119
|
+
- Training: `docs/training.md`
|
|
120
|
+
- Export: `docs/export.md`
|
|
121
|
+
- Transform API: `docs/transform-api.md`
|
|
122
|
+
- Model zoo: `docs/model-zoo.md`
|
|
123
|
+
|
|
124
|
+
## License
|
|
125
|
+
|
|
126
|
+
FOTO-NET is licensed under the Apache License, Version 2.0.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Use small focused pull requests.
|
|
4
|
+
|
|
5
|
+
Run the test suite before submitting:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
python -m unittest discover -s tests -p "test_*.py"
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Keep public docs free of local absolute paths.
|
|
12
|
+
|
|
13
|
+
Do not commit datasets, checkpoints, logs, or exported engines.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Export
|
|
2
|
+
|
|
3
|
+
FOTO-NET alpha provides export helpers for inference graphs. Export support depends on the local toolchain.
|
|
4
|
+
|
|
5
|
+
## ONNX
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
from fotonet import FOTONET
|
|
9
|
+
|
|
10
|
+
model = FOTONET("fotonet-n")
|
|
11
|
+
model.export(format="onnx", path="dev-tools/runs/fotonet.onnx", imgsz=640)
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
ONNX export writes a metadata JSON file next to the artifact.
|
|
15
|
+
|
|
16
|
+
## TorchScript
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
model.export(format="torchscript", path="fotonet.torchscript", imgsz=640)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## TensorRT
|
|
23
|
+
|
|
24
|
+
TensorRT export requires `trtexec` in `PATH`.
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
model.export(format="tensorrt", path="fotonet.engine", imgsz=640, half=True)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## CoreML
|
|
31
|
+
|
|
32
|
+
CoreML code exists, but this alpha does not treat CoreML as certified unless a fresh platform-specific verification is published.
|
|
33
|
+
|
|
34
|
+
## Output Format
|
|
35
|
+
|
|
36
|
+
Exported graphs output the raw one-to-one inference tensor. Application code is responsible for postprocessing unless a future release adds packaged postprocess graphs.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Inference
|
|
2
|
+
|
|
3
|
+
## Python Inference
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
from fotonet import FOTONET
|
|
7
|
+
|
|
8
|
+
model = FOTONET("fotonet-n")
|
|
9
|
+
results = model.predict("image.jpg", conf=0.25, imgsz=640)
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Folder Inference
|
|
13
|
+
|
|
14
|
+
```python
|
|
15
|
+
from fotonet import FOTONET
|
|
16
|
+
|
|
17
|
+
model = FOTONET("fotonet-n")
|
|
18
|
+
results = model.predict("images", batch=8)
|
|
19
|
+
for result in results:
|
|
20
|
+
print(result)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## BGR Frames
|
|
24
|
+
|
|
25
|
+
OpenCV users can call `predict_bgr()` with BGR `uint8` frames:
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
result = model.predict_bgr(frame, conf=0.25)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Results Objects
|
|
32
|
+
|
|
33
|
+
`Results` contains:
|
|
34
|
+
|
|
35
|
+
- `orig_img`: original image object or array
|
|
36
|
+
- `boxes`: iterable detection collection
|
|
37
|
+
- `scores`: confidence tensor
|
|
38
|
+
- `classes`: class id tensor
|
|
39
|
+
- `names`: class name mapping
|
|
40
|
+
|
|
41
|
+
Each `DetectionBox` exposes:
|
|
42
|
+
|
|
43
|
+
- `idx`
|
|
44
|
+
- `conf`
|
|
45
|
+
- `cls_id`
|
|
46
|
+
- `cls`
|
|
47
|
+
- `xywh`
|
|
48
|
+
- `xyxy`
|
|
49
|
+
- `transform`
|
|
50
|
+
|
|
51
|
+
## Visualization and Export Helpers
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
plot = results.plot()
|
|
55
|
+
results.save("dev-tools/runs/prediction.jpg")
|
|
56
|
+
json_text = results.to_json()
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
`to_pandas()` requires pandas.
|
|
60
|
+
|
|
61
|
+
## Inference Timing
|
|
62
|
+
|
|
63
|
+
Inference times are not out yet because the benchmark computer is IO bottlenecked, so the timing numbers are not reliable enough to publish.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Installation
|
|
2
|
+
|
|
3
|
+
## Requirements
|
|
4
|
+
|
|
5
|
+
FOTO-NET alpha targets Python 3.10 or newer. A CUDA-capable PyTorch install is recommended for training, but CPU installs are useful for API tests, documentation examples, and small export smoke checks.
|
|
6
|
+
|
|
7
|
+
Install PyTorch from the official PyTorch instructions for your platform first when you need a specific CUDA build.
|
|
8
|
+
|
|
9
|
+
## Public Alpha Checkout
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
git clone https://github.com/hazegreleases/fotonet.git
|
|
13
|
+
cd fotonet
|
|
14
|
+
python -m pip install torch torchvision numpy pillow pyyaml opencv-python matplotlib scipy tqdm
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Run Python examples from the repository root so the local `fotonet` package is importable.
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
python examples/transform_crop.py
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Optional ONNX Dependencies
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
python -m pip install onnx onnxsim
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
ONNX export works best when `onnx` is installed. `onnxsim` is optional and only used for graph simplification.
|
|
30
|
+
|
|
31
|
+
## Optional Metrics Dependencies
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
python -m pip install pycocotools
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`pycocotools` enables COCO-style validation metrics. Without it, FOTO-NET can still run model construction, inference, training code paths, and local tests that do not require COCO evaluation.
|
|
38
|
+
|
|
39
|
+
## CUDA Notes
|
|
40
|
+
|
|
41
|
+
Use a PyTorch build that matches your driver and CUDA runtime. Training speed depends heavily on GPU memory, batch size, image size, and whether validation is running on the full dataset.
|
|
42
|
+
|
|
43
|
+
## Troubleshooting
|
|
44
|
+
|
|
45
|
+
If imports fail after cloning, run:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
python -c "from fotonet import FOTONET; print(FOTONET('fotonetn').nc)"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
If export dependencies are missing, install them directly:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
python -m pip install onnx onnxsim
|
|
55
|
+
```
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Model Zoo
|
|
2
|
+
|
|
3
|
+
The alpha checkout includes the public nano checkpoint as `fotonet-n`.
|
|
4
|
+
|
|
5
|
+
## Alpha Checkpoint
|
|
6
|
+
|
|
7
|
+
| Checkpoint | Architecture | mAP@.50:.95 | Parameters | MACs at 640 | GFLOPs at 640 | Weights |
|
|
8
|
+
|---|---|---:|---:|---:|---:|---|
|
|
9
|
+
| `fotonet-n` | `fotonetn` | 22.68% | 2.75M | 2.43G | 4.85G | Included |
|
|
10
|
+
|
|
11
|
+
The MACs and GFLOPs numbers are for a 640x640 input. GFLOPs are estimated as two FLOPs per MAC.
|
|
12
|
+
|
|
13
|
+
Inference times are not out yet because the benchmark computer is IO bottlenecked, so the timing numbers are not reliable enough to publish.
|
|
14
|
+
|
|
15
|
+
## Public Architectures
|
|
16
|
+
|
|
17
|
+
| Name | Purpose | P2 | Quality Head | Status |
|
|
18
|
+
|---|---|---|---|---|
|
|
19
|
+
| `fotonetn` | Nano general detector | yes | yes | alpha checkpoint |
|
|
20
|
+
| `fotonetn0` | Edge nano detector without P2 | no | no | alpha architecture |
|
|
21
|
+
| `fotonets` | Small detector | yes | yes | alpha architecture |
|
|
22
|
+
| `fotonetm` | Medium detector | yes | yes | alpha architecture |
|
|
23
|
+
| `fotonetl` | Large detector | yes | yes | alpha architecture |
|
|
24
|
+
| `fotonetx` | Extra-large detector | yes | yes | alpha architecture |
|
|
25
|
+
|
|
26
|
+
## Development Weights
|
|
27
|
+
|
|
28
|
+
Training checkpoints and comparison weights are development artifacts. Keep them out of the public surface.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Quick Start
|
|
2
|
+
|
|
3
|
+
This alpha release is a demo of what is coming. It is not recommended for production workflows.
|
|
4
|
+
|
|
5
|
+
## Construct a Model
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
from fotonet import FOTONET
|
|
9
|
+
|
|
10
|
+
model = FOTONET("fotonetn")
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Constructing a named scale builds the architecture. Released weights are needed for meaningful detections.
|
|
14
|
+
|
|
15
|
+
## Run Inference With a Checkpoint
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from fotonet import FOTONET
|
|
19
|
+
|
|
20
|
+
model = FOTONET("fotonet-n")
|
|
21
|
+
results = model.predict("image.jpg", conf=0.25)
|
|
22
|
+
print(results)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Inspect Results
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
for box in results.boxes:
|
|
29
|
+
print(box.cls, box.conf, box.xywh, box.xyxy)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## CLI Inference
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
python -m fotonet.cli.main predict model=fotonet-n source=image.jpg conf=0.25 save=true
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Train a YOLO Dataset
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
fotonet train model=fotonetn data=data.yaml epochs=100 imgsz=640 batch=16
|
|
42
|
+
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Alpha Release Checklist
|
|
2
|
+
|
|
3
|
+
- [ ] Full tests pass on a clean clone.
|
|
4
|
+
- [ ] README contains no emojis.
|
|
5
|
+
- [ ] README hero image loads from the raw banner URL.
|
|
6
|
+
- [ ] `.gitignore` excludes datasets, logs, weights, exports, and caches.
|
|
7
|
+
- [ ] No local absolute paths appear in public docs or examples.
|
|
8
|
+
- [ ] `python -m build` succeeds.
|
|
9
|
+
- [ ] `twine check dist/*` succeeds.
|
|
10
|
+
- [ ] Editable install works.
|
|
11
|
+
- [ ] CLI help works.
|
|
12
|
+
- [ ] At least one inference example runs.
|
|
13
|
+
- [ ] At least one transform example runs.
|
|
14
|
+
- [ ] Weights are attached to GitHub Releases, not committed.
|
|
15
|
+
- [ ] SHA256 checksums are published for release weights.
|
|
16
|
+
- [ ] GitHub release notes state alpha limitations.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Training
|
|
2
|
+
|
|
3
|
+
This alpha release is not recommended for production workflows. The training path exists so users can experiment, reproduce runs, and help harden the project.
|
|
4
|
+
|
|
5
|
+
## Dataset Format
|
|
6
|
+
|
|
7
|
+
FOTO-NET expects YOLO-format labels:
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
class_id x_center y_center width height
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Coordinates are normalized to the image size.
|
|
14
|
+
|
|
15
|
+
## `data.yaml`
|
|
16
|
+
|
|
17
|
+
A minimal dataset config should include:
|
|
18
|
+
|
|
19
|
+
```yaml
|
|
20
|
+
path: /path/to/dataset
|
|
21
|
+
train: images/train
|
|
22
|
+
val: images/val
|
|
23
|
+
nc: 80
|
|
24
|
+
names:
|
|
25
|
+
0: class_0
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Use paths that are valid on your machine. Do not commit local dataset paths to shared configs.
|
|
29
|
+
|
|
30
|
+
## Python Training
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from fotonet import FOTONET
|
|
34
|
+
|
|
35
|
+
model = FOTONET("fotonetn")
|
|
36
|
+
model.train(data="data.yaml", epochs=100, imgsz=640, batch=16)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## CLI Training
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
fotonet train model=fotonetn data=data.yaml epochs=100 imgsz=640 batch=16
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Resume and Pretrained Modes
|
|
46
|
+
|
|
47
|
+
`resume=True` means continue from a full training checkpoint such as `fotonet_last.pt`. It restores training state, optimizer state, scheduler state, scaler state, and epoch position.
|
|
48
|
+
|
|
49
|
+
`pretrained=True` means load model weights only and start with a fresh optimizer and scheduler.
|
|
50
|
+
|
|
51
|
+
`resume=True` and `pretrained=True` are mutually exclusive.
|
|
52
|
+
|
|
53
|
+
`fotonet_best.pt` can be a slim inference checkpoint. `fotonet_last.pt` is the resumable training checkpoint.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Transform API
|
|
2
|
+
|
|
3
|
+
The transform API is a mutable spatial helper attached to each detection box.
|
|
4
|
+
|
|
5
|
+
Read `box.xywh` for the original detection center and size. Use `box.transform` for working spatial operations such as cropping, moving, expanding, anchoring, and containment checks.
|
|
6
|
+
|
|
7
|
+
## Basic Usage
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from fotonet import AnchorPoint
|
|
11
|
+
|
|
12
|
+
box = results.boxes[0]
|
|
13
|
+
crop = (
|
|
14
|
+
box.transform
|
|
15
|
+
.setAnchor(AnchorPoint.CENTER)
|
|
16
|
+
.pixelExpand(40)
|
|
17
|
+
.clamp()
|
|
18
|
+
.crop(results.orig_img)
|
|
19
|
+
)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Properties
|
|
23
|
+
|
|
24
|
+
- `box.transform.xywh`: normalized center x, center y, width, height
|
|
25
|
+
- `box.transform.xyxy`: normalized x1, y1, x2, y2
|
|
26
|
+
- `position`: normalized anchor position
|
|
27
|
+
- `pixelPosition`: anchor position in pixels
|
|
28
|
+
- `size`: normalized width and height
|
|
29
|
+
- `pixelSize`: width and height in pixels
|
|
30
|
+
- `corner[index]`: normalized corner point, 1 through 4
|
|
31
|
+
- `side[index]`: normalized side midpoint, 1 through 4
|
|
32
|
+
|
|
33
|
+
## Methods
|
|
34
|
+
|
|
35
|
+
- `setAnchor(anchor)`: set the anchor used by scale and expansion operations
|
|
36
|
+
- `move((dx, dy))`: move in normalized units
|
|
37
|
+
- `pixelMove((dx, dy))`: move in pixels
|
|
38
|
+
- `scale((sx, sy))`: scale about the active anchor
|
|
39
|
+
- `expand(padding)`: expand in normalized units
|
|
40
|
+
- `pixelExpand(padding)`: expand in pixels
|
|
41
|
+
- `clamp()`: clamp the box to image bounds
|
|
42
|
+
- `setBox(mode=1)`: make the region square
|
|
43
|
+
- `setAspectRatio((w, h), mode=1)`: enforce an aspect ratio
|
|
44
|
+
- `crop(image)`: crop from a PIL image or NumPy array
|
|
45
|
+
- `contains(point=...)`: normalized point or region containment
|
|
46
|
+
- `pixelContains(point=...)`: pixel point or region containment
|
|
47
|
+
- `iou(other)`: intersection over union
|
|
48
|
+
- `distance(point)`: normalized distance from active anchor
|
|
49
|
+
- `focus(x, y, w, h)`: focus on a relative subregion
|
|
50
|
+
- `focusReset()`: restore the original detection box
|
|
51
|
+
|
|
52
|
+
## Anchors
|
|
53
|
+
|
|
54
|
+
Available anchors include:
|
|
55
|
+
|
|
56
|
+
- `AnchorPoint.CENTER`
|
|
57
|
+
- `AnchorPoint.TOP_LEFT`
|
|
58
|
+
- `AnchorPoint.TOP_RIGHT`
|
|
59
|
+
- `AnchorPoint.BOTTOM_LEFT`
|
|
60
|
+
- `AnchorPoint.BOTTOM_RIGHT`
|
|
61
|
+
- `AnchorPoint.TOP`
|
|
62
|
+
- `AnchorPoint.BOTTOM`
|
|
63
|
+
- `AnchorPoint.LEFT`
|
|
64
|
+
- `AnchorPoint.RIGHT`
|