Skip to content

Commit 44ac39e

Browse files
authored
Tiny yolov2 example (#92)
* feat: testing the tiny yolo v2 model * wip: processing output of tiny yolo v2 * add softmax * bug: the image encoding / decoding is not working * chore: maintenance * fix: bad commit * chore: new way to evaluate for testing purpose * chore: back to the [][][]int output for ease of processing * feat: test * fix: images are handled as 8 bits * feat: display elements with confidence > 30% * feat: drawibg rectangle on the picture, but result is still weird * feat: prediction looks ok! * chore: add a readme * chore: housecleaning * feat: add basic labeling * chore: housecleaning * chore: add a pointer to the example subdirectory * chore: changed the threshold * chore: add output information * feat: auto-resize of the image and sanitization with IoU * chore: changed default value * chore: housekeeping * feat: by default, do not write output file
1 parent eaa0c8f commit 44ac39e

File tree

2 files changed

+215
-140
lines changed

2 files changed

+215
-140
lines changed

examples/tiny_yolov2/README.md

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,35 @@
33
to run this utility you need:
44

55
- the onnx definition of tiny yolo v2 from the [model zoo](https://github.com/onnx/models/tree/master/tiny_yolov2).
6-
- a 416x416 jpeg picture
6+
- a jpeg picture
77

8-
then
8+
## Usage
99

10-
`go run main.go -model /path/to/tiny_yolov2/model.onnx -img /path/to/picture_416x416.jpg`
10+
```
11+
$ go run main.go -h
12+
-h help
13+
-img string
14+
path of an input jpeg image (use - for stdin)
15+
-model string
16+
path to the model file (default "model.onnx")
17+
-output string
18+
path of an output png file (use - for stdout)
19+
-s silent mode (useful if output is -)
20+
This application is configured via the environment. The following environment
21+
variables can be used:
1122
23+
KEY TYPE DEFAULT REQUIRED DESCRIPTION
24+
YOLO_CONFIDENCE_THRESHOLD Float 0.30 true
25+
YOLO_PROBA_THRESHOLD Float 0.90 true
26+
```
1227

13-
ex:
28+
to run it, simply do a
29+
`go run main.go -model /path/to/tiny_yolov2/model.onnx -img /path/to/picture.jpg`
1430

15-
```
16-
✗ go run main.go -model $MODELDIR/tiny_yolov2/model.onnx -img data/dog_416.jpg
17-
at (162,0)-(189,206) with confidence 0.95%: [{0.9998071754247418 dog} {0.00018703953064835692 cat} {2.115350363488541e-06 person}]
18-
at (0,3)-(438,346) with confidence 0.85%: [{0.9999962088094221 bicycle} {2.4332601660991103e-06 chair} {4.6456437678137356e-07 person}]
19-
at (0,73)-(126,295) with confidence 0.83%: [{0.9999995178370005 car} {3.5306012468841564e-07 bus} {1.0748795966861477e-07 person}]
20-
at (0,43)-(430,320) with confidence 0.73%: [{0.9999789093484178 bicycle} {2.013909263985852e-05 chair} {6.396542550263407e-07 boat}]
21-
at (152,0)-(226,187) with confidence 0.66%: [{0.9982670709247383 dog} {0.0016460507909590047 cat} {5.957194709763225e-05 person}]
22-
at (0,83)-(103,325) with confidence 0.66%: [{0.9999934470064776 car} {4.297399737329603e-06 person} {2.082974674910856e-06 bus}]
23-
at (157,0)-(186,200) with confidence 0.64%: [{0.999784279956219 dog} {0.00019693142718305628 cat} {8.454914041169167e-06 bird}]
24-
at (0,0)-(413,362) with confidence 0.62%: [{0.9986541066305761 bicycle} {0.0008222933798651681 chair} {0.00032344712097440875 motorbike}]
25-
at (0,0)-(400,363) with confidence 0.55%: [{0.9999220651658735 bicycle} {5.773722286386036e-05 chair} {6.478719961409336e-06 person}]
26-
at (0,0)-(448,338) with confidence 0.51%: [{0.9995790811257635 bicycle} {0.0002938493348981077 chair} {5.05680835872687e-05 dog}]
27-
at (143,0)-(223,186) with confidence 0.45%: [{0.9857089464884052 dog} {0.01341958871066549 cat} {0.0007088810484281701 person}]
28-
at (0,71)-(112,263) with confidence 0.34%: [{0.9999317843569847 car} {4.842326315789941e-05 person} {1.0402486318194522e-05 bus}]
29-
at (146,0)-(184,241) with confidence 0.33%: [{0.9999781504060399 dog} {6.9390734196093085e-06 cat} {5.307627835320137e-06 chair}]
30-
at (15,36)-(446,327) with confidence 0.31%: [{0.9999871477975073 bicycle} {7.80820896521431e-06 boat} {3.1919688616376533e-06 chair}]
31-
{0.9999995178370005 car}
32-
{0.9999962088094221 bicycle}
33-
{0.9999934470064776 car}
34-
{0.9999871477975073 bicycle}
35-
{0.9999789093484178 bicycle}
36-
{0.9999781504060399 dog}
37-
{0.9999317843569847 car}
38-
{0.9999220651658735 bicycle}
39-
{0.9998071754247418 dog}
40-
{0.999784279956219 dog}
41-
{0.9995790811257635 bicycle}
42-
{0.9986541066305761 bicycle}
43-
{0.9982670709247383 dog}
44-
{0.9857089464884052 dog}
45-
```
31+
if you want to generate an anotated output picture in png, use the `-output` parameter
32+
33+
34+
You can alter the output by playing with the environment variables
35+
36+
- `YOLO_CONFIDENCE_THRESHOLD`: bypass the boxes with a confidence lower than this value
37+
- `YOLO_PROBA_THRESHOLD`: bypass the boxes with a class detection lower than this value

0 commit comments

Comments
 (0)