Skip to content

Commit

Permalink
Update documentation to add supported species, and update the two Gra…
Browse files Browse the repository at this point in the history
…dio apps
  • Loading branch information
bluemellophone committed Oct 4, 2022
1 parent 6af0f64 commit 471503c
Show file tree
Hide file tree
Showing 10 changed files with 232 additions and 66 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ To then add GPU acceleration, you need to replace `onnxruntime` with `onnxruntim
How to Run
----------

You can run the tile-base Gradio demo with:
You can run the tile-based Gradio demo with:

.. code-block:: console
(.venv) $ python app.py
or, you can run the image-base Gradio demo with:
or, you can run the image-based Gradio demo with:

.. code-block:: console
Expand Down
61 changes: 42 additions & 19 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,26 @@

from scoutbot import loc, wic

PHASE1 = [
'Phase 1',
int(wic.CONFIGS['phase1']['thresh'] * 100),
int(loc.CONFIGS['phase1']['thresh'] * 100),
int(loc.CONFIGS['phase1']['nms'] * 100),
]
MVP = [
'MVP',
int(wic.CONFIGS['mvp']['thresh'] * 100),
int(loc.CONFIGS['mvp']['thresh'] * 100),
int(loc.CONFIGS['mvp']['nms'] * 100),
]


def predict(filepath, config, wic_thresh, loc_thresh, nms_thresh):
start = time.time()

if config == 'MVP':
if config == MVP[0]:
config = 'mvp'
elif config == 'Phase 1':
elif config == PHASE1[0]:
config = 'phase1'
else:
raise ValueError()
Expand All @@ -22,8 +35,6 @@ def predict(filepath, config, wic_thresh, loc_thresh, nms_thresh):
loc_thresh /= 100.0
nms_thresh /= 100.0

nms_thresh = 1.0 - nms_thresh

# Load data
img = cv2.imread(filepath)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
Expand Down Expand Up @@ -80,12 +91,12 @@ def predict(filepath, config, wic_thresh, loc_thresh, nms_thresh):
gr.Radio(
label='Model Configuration',
type='value',
choices=['Phase 1', 'MVP'],
value='MVP',
choices=[PHASE1[0], MVP[0]],
value=MVP[0],
),
gr.Slider(label='WIC Confidence Threshold', value=7),
gr.Slider(label='Localizer Confidence Threshold', value=14),
gr.Slider(label='Localizer NMS Threshold', value=80),
gr.Slider(label='WIC Confidence Threshold', value=MVP[1]),
gr.Slider(label='Localizer Confidence Threshold', value=MVP[2]),
gr.Slider(label='Localizer NMS Threshold', value=MVP[3]),
],
outputs=[
gr.Image(type='numpy'),
Expand All @@ -94,16 +105,28 @@ def predict(filepath, config, wic_thresh, loc_thresh, nms_thresh):
gr.Textbox(label='Predicted Localizer Detections', interactive=False),
],
examples=[
['examples/07a4b8db-f31c-261d-4580-e9402768fd45.true.jpg', 'MVP', 7, 14, 80],
['examples/15e815d9-5aad-fa53-d1ed-33429020e15e.true.jpg', 'MVP', 7, 14, 80],
['examples/1bb79811-3149-7a60-2d88-613dc3eeb261.true.jpg', 'MVP', 7, 14, 80],
['examples/1e8372e4-357d-26e6-d7fd-0e0ae402463a.true.jpg', 'MVP', 7, 14, 80],
['examples/201bc65e-d64e-80d3-2610-5865a22d04b4.false.jpg', 'MVP', 7, 14, 80],
['examples/3affd8b6-9722-f2d5-9171-639615b4c38f.true.jpg', 'MVP', 7, 14, 80],
['examples/4aedb818-f2f4-e462-8b75-5c8e34a01a59.false.jpg', 'MVP', 7, 14, 80],
['examples/474bc2b6-dc51-c1b5-4612-efe810bbe091.true.jpg', 'MVP', 7, 14, 80],
['examples/c3014107-3464-60b5-e04a-e4bfafdf8809.false.jpg', 'MVP', 7, 14, 80],
['examples/f835ce33-292a-9116-794e-f8859b5956ec.true.jpg', 'MVP', 7, 14, 80],
# Phase 1
['examples/07a4b8db-f31c-261d-4580-e9402768fd45.true.jpg'] + PHASE1,
['examples/15e815d9-5aad-fa53-d1ed-33429020e15e.true.jpg'] + PHASE1,
['examples/1bb79811-3149-7a60-2d88-613dc3eeb261.true.jpg'] + PHASE1,
['examples/1e8372e4-357d-26e6-d7fd-0e0ae402463a.true.jpg'] + PHASE1,
['examples/201bc65e-d64e-80d3-2610-5865a22d04b4.false.jpg'] + PHASE1,
['examples/3affd8b6-9722-f2d5-9171-639615b4c38f.true.jpg'] + PHASE1,
['examples/4aedb818-f2f4-e462-8b75-5c8e34a01a59.false.jpg'] + PHASE1,
['examples/474bc2b6-dc51-c1b5-4612-efe810bbe091.true.jpg'] + PHASE1,
['examples/c3014107-3464-60b5-e04a-e4bfafdf8809.false.jpg'] + PHASE1,
['examples/f835ce33-292a-9116-794e-f8859b5956ec.true.jpg'] + PHASE1,
# MVP
['examples/07a4b8db-f31c-261d-4580-e9402768fd45.true.jpg'] + MVP,
['examples/15e815d9-5aad-fa53-d1ed-33429020e15e.true.jpg'] + MVP,
['examples/1bb79811-3149-7a60-2d88-613dc3eeb261.true.jpg'] + MVP,
['examples/1e8372e4-357d-26e6-d7fd-0e0ae402463a.true.jpg'] + MVP,
['examples/201bc65e-d64e-80d3-2610-5865a22d04b4.false.jpg'] + MVP,
['examples/3affd8b6-9722-f2d5-9171-639615b4c38f.true.jpg'] + MVP,
['examples/4aedb818-f2f4-e462-8b75-5c8e34a01a59.false.jpg'] + MVP,
['examples/474bc2b6-dc51-c1b5-4612-efe810bbe091.true.jpg'] + MVP,
['examples/c3014107-3464-60b5-e04a-e4bfafdf8809.false.jpg'] + MVP,
['examples/f835ce33-292a-9116-794e-f8859b5956ec.true.jpg'] + MVP,
],
cache_examples=True,
allow_flagging='never',
Expand Down
69 changes: 48 additions & 21 deletions app2.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,28 @@
import numpy as np

import scoutbot
from scoutbot import agg, loc, wic

PHASE1 = [
'Phase 1',
int(wic.CONFIGS['phase1']['thresh'] * 100),
int(loc.CONFIGS['phase1']['thresh'] * 100),
int(loc.CONFIGS['phase1']['nms'] * 100),
int(agg.CONFIGS['phase1']['thresh'] * 100),
int(agg.CONFIGS['phase1']['nms'] * 100),
]
MVP = [
'MVP',
int(wic.CONFIGS['mvp']['thresh'] * 100),
int(loc.CONFIGS['mvp']['thresh'] * 100),
int(loc.CONFIGS['mvp']['nms'] * 100),
int(agg.CONFIGS['mvp']['thresh'] * 100),
int(agg.CONFIGS['mvp']['nms'] * 100),
]


def predict(
filepath, config, wic_thresh, loc_thresh, agg_thresh, loc_nms_thresh, agg_nms_thresh
filepath, config, wic_thresh, loc_thresh, loc_nms_thresh, agg_thresh, agg_nms_thresh
):
start = time.time()

Expand All @@ -26,9 +44,6 @@ def predict(
agg_thresh /= 100.0
agg_nms_thresh /= 100.0

loc_nms_thresh = 1.0 - loc_nms_thresh
agg_nms_thresh = 1.0 - agg_nms_thresh

# Load data
img = cv2.imread(filepath)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
Expand Down Expand Up @@ -81,14 +96,14 @@ def predict(
gr.Radio(
label='Model Configuration',
type='value',
choices=['Phase 1', 'MVP'],
value='MVP',
choices=[PHASE1[0], MVP[0]],
value=MVP[0],
),
gr.Slider(label='WIC Confidence Threshold', value=7),
gr.Slider(label='Localizer Confidence Threshold', value=14),
gr.Slider(label='Aggregation Confidence Threshold', value=51),
gr.Slider(label='Localizer NMS Threshold', value=80),
gr.Slider(label='Aggregation NMS Threshold', value=80),
gr.Slider(label='WIC Confidence Threshold', value=MVP[1]),
gr.Slider(label='Localizer Confidence Threshold', value=MVP[2]),
gr.Slider(label='Localizer NMS Threshold', value=MVP[3]),
gr.Slider(label='Aggregation Confidence Threshold', value=MVP[4]),
gr.Slider(label='Aggregation NMS Threshold', value=MVP[5]),
],
outputs=[
gr.Image(type='numpy'),
Expand All @@ -97,16 +112,28 @@ def predict(
gr.Textbox(label='Predicted Detections', interactive=False),
],
examples=[
['examples/0d4e4df2-7b69-91b1-1985-c8421f2f3253.jpg', 'MVP', 7, 14, 51, 80, 80],
['examples/18cef191-74ed-2b5e-55a5-f58bd3d483ff.jpg', 'MVP', 7, 14, 51, 80, 80],
['examples/1be4d40a-6fd0-42ce-da6c-294e45781f41.jpg', 'MVP', 7, 14, 51, 80, 80],
['examples/1d3c85e9-ee24-f290-e7e1-6e338f2eaebb.jpg', 'MVP', 7, 14, 51, 80, 80],
['examples/3e043302-af1c-75a7-4057-3a2f25c123bf.jpg', 'MVP', 7, 14, 51, 80, 80],
['examples/43ecc08d-502a-7a51-9d68-3e40a76439a2.jpg', 'MVP', 7, 14, 51, 80, 80],
['examples/479058af-e774-e6aa-a2b0-9a42dd6ff8b1.jpg', 'MVP', 7, 14, 51, 80, 80],
['examples/7c910b87-ae3a-f580-d431-03cd89793803.jpg', 'MVP', 7, 14, 51, 80, 80],
['examples/8fa04489-cd94-7d8f-7e2e-5f0fe2f7ae76.jpg', 'MVP', 7, 14, 51, 80, 80],
['examples/bb7b4345-b98a-c727-4c94-6090f0aa4355.jpg', 'MVP', 7, 14, 51, 80, 80],
# Phase 1
['examples/0d4e4df2-7b69-91b1-1985-c8421f2f3253.jpg'] + PHASE1,
['examples/18cef191-74ed-2b5e-55a5-f58bd3d483ff.jpg'] + PHASE1,
['examples/1be4d40a-6fd0-42ce-da6c-294e45781f41.jpg'] + PHASE1,
['examples/1d3c85e9-ee24-f290-e7e1-6e338f2eaebb.jpg'] + PHASE1,
['examples/3e043302-af1c-75a7-4057-3a2f25c123bf.jpg'] + PHASE1,
['examples/43ecc08d-502a-7a51-9d68-3e40a76439a2.jpg'] + PHASE1,
['examples/479058af-e774-e6aa-a2b0-9a42dd6ff8b1.jpg'] + PHASE1,
['examples/7c910b87-ae3a-f580-d431-03cd89793803.jpg'] + PHASE1,
['examples/8fa04489-cd94-7d8f-7e2e-5f0fe2f7ae76.jpg'] + PHASE1,
['examples/bb7b4345-b98a-c727-4c94-6090f0aa4355.jpg'] + PHASE1,
# MVP
['examples/0d4e4df2-7b69-91b1-1985-c8421f2f3253.jpg'] + MVP,
['examples/18cef191-74ed-2b5e-55a5-f58bd3d483ff.jpg'] + MVP,
['examples/1be4d40a-6fd0-42ce-da6c-294e45781f41.jpg'] + MVP,
['examples/1d3c85e9-ee24-f290-e7e1-6e338f2eaebb.jpg'] + MVP,
['examples/3e043302-af1c-75a7-4057-3a2f25c123bf.jpg'] + MVP,
['examples/43ecc08d-502a-7a51-9d68-3e40a76439a2.jpg'] + MVP,
['examples/479058af-e774-e6aa-a2b0-9a42dd6ff8b1.jpg'] + MVP,
['examples/7c910b87-ae3a-f580-d431-03cd89793803.jpg'] + MVP,
['examples/8fa04489-cd94-7d8f-7e2e-5f0fe2f7ae76.jpg'] + MVP,
['examples/bb7b4345-b98a-c727-4c94-6090f0aa4355.jpg'] + MVP,
],
cache_examples=True,
allow_flagging='never',
Expand Down
85 changes: 85 additions & 0 deletions docs/_static/theme.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,88 @@
.wy-nav-content {
max-width: 900px !important;
}

.black {
color: black;
}

.gray {
color: gray;
}

.grey {
color: gray;
}

.silver {
color: silver;
}

.white {
color: white;
}

.maroon {
color: maroon;
}

.red {
color: red;
}

.magenta {
color: magenta;
}

.fuchsia {
color: fuchsia;
}

.pink {
color: pink;
}

.orange {
color: orange;
}

.yellow {
color: yellow;
}

.lime {
color: lime;
}

.green {
color: green;
font-weight: bold;
}

.olive {
color: olive;
}

.teal {
color: teal;
}

.cyan {
color: cyan;
}

.aqua {
color: aqua;
}

.blue {
color: blue;
}

.navy {
color: navy;
}

.purple {
color: purple;
}
25 changes: 25 additions & 0 deletions docs/colors.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.. Color profiles for Sphinx.
.. role:: black
.. role:: gray
.. role:: grey
.. role:: silver
.. role:: white
.. role:: maroon
.. role:: red
.. role:: magenta
.. role:: fuchsia
.. role:: pink
.. role:: orange
.. role:: yellow
.. role:: lime
.. role:: green
.. role:: olive
.. role:: teal
.. role:: cyan
.. role:: aqua
.. role:: blue
.. role:: navy
.. role:: purple

.. (c) Lilian Besson, 2011-2016, https://bitbucket.org/lbesson/web-sphinx/
30 changes: 17 additions & 13 deletions docs/onnx.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. include:: colors.rst

CDN Model Download (ONNX)
-------------------------

Expand Down Expand Up @@ -39,15 +41,15 @@ are not clean and are mapped, for convience, when the final detection labels are
supported species for each model:

- Phase 1: ``phase1``
- `elephant_savanna`
- :green:`elephant_savanna`
- - mapped to: `elephant`

- MVP: ``mvp``
- `buffalo`
- :green:`buffalo`
- `camel`
- `canoe`
- `car`
- `cow`
- :green:`cow`
- `crocodile`
- `dead_animalwhite_bones`
- - mapped to: `white_bones`
Expand All @@ -56,7 +58,7 @@ supported species for each model:
- `eland`
- `elecarcass_old`
- - mapped to: `white_bones`
- `elephant`
- :green:`elephant`
- `gazelle_gr`
- - mapped to: `gazelle_grants`
- `gazelle_grants`
Expand All @@ -65,25 +67,27 @@ supported species for each model:
- `gazelle_thomsons`
- `gerenuk`
- `giant_forest_hog`
- `giraffe`
- :green:`giraffe`
- `goat`
- `hartebeest`
- `hippo`
- :green:`hartebeest`
- :green:`hippo`
- `impala`
- `kob`
- :green:`kob`
- `kudu`
- `motorcycle`
- `oribi`
- `oryx`
- :green:`oryx`
- `ostrich`
- `roof_grass`
- `roof_mabati`
- `sheep`
- `test`
- `topi`
- :green:`topi`
- `vehicle`
- `warthog`
- `waterbuck`
- :green:`warthog`
- :green:`waterbuck`
- `white_bones`
- `wildebeest`
- `zebra`
- :green:`zebra`

All species above that are highlighted in green have an Average Precision (AP) of at least 50%. The other species are supported in a preliminary sense and should not be heavily relied on.
Loading

0 comments on commit 471503c

Please sign in to comment.