Skip to content

Commit 1cf1ae3

Browse files
committed
docs: new commands and format existing docs
1 parent 43d4a5f commit 1cf1ae3

File tree

1 file changed

+58
-11
lines changed

1 file changed

+58
-11
lines changed

README.md

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ Test the whole backend pipeline without the GUI using this command
6060

6161
```sh
6262
python trapdata/tests/test_pipeline.py
63+
# or
64+
ami test pipeline
65+
```
66+
67+
Run all other tests with:
68+
69+
```sh
70+
ami test all
6371
```
6472

6573
## GUI Usage
@@ -149,19 +157,58 @@ A script is available in the repo source to run the commands above.
149157

150158

151159

152-
## KG Notes for adding new models
160+
## Adding new models
153161

154-
- To add new models, save the pt and json files to:
155-
```
156-
~/Library/Application Support/trapdata/models
157-
```
158-
or wherever you set the appropriate dir in settings.
159-
The json file is simply a dict of species name and index.
162+
1) Create a new inference class in `trapdata/ml/models/classification.py` or `trapdata/ml/models/localization.py`. All models inherit from `InferenceBaseClass`, but there are more specific classes for classification and localization and different architectures. Choose the appropriate class to inherit from. It's best to copy an existing inference class that is similar to the new model you are adding.
163+
164+
2) Upload your model weights and category map to a cloud storage service and make sure the file is publicly accessible via a URL. The weights will be downloaded the first time the model is run. Alternatively, you can manually add the model weights to the configured `USER_DATA_PATH` directory under the subdir `USER_DATA_PATH/models/` (on macOS this is `~/Library/Application Support/trapdata/models`). However the model will not be available to other users unless they also manually add the model weights. The category map json file is simply a dict of species names and their indexes in your model's last layer. See the existing category maps for examples.
165+
166+
3) Select your model in the GUI settings or set the `SPECIES_CLASSIFICATION_MODEL` setting. If the model inherits from `SpeciesClassifier` class, it will automatically become one of the valid choices.
160167

161-
Then you need to create a class in `trapdata/ml/models/classification.py` or `trapdata/ml/models/localization.py` and add the model details.
168+
## Clearing the cache & starting fresh
162169

163-
- To clear the cache:
170+
Remove the index of images, all detections and classifications by removing the database file. This will not remove the images themselves, only the metadata about them. The database is located in the user data directory.
164171

172+
On macOS:
165173
```
166-
rm ~/Library/Application\ Support/trapdata/trapdata.db
167-
```
174+
rm ~/Library/Application\ Support/trapdata/trapdata.db
175+
```
176+
177+
On Linux:
178+
```
179+
rm ~/.config/trapdata/trapdata.db
180+
```
181+
182+
On Windows:
183+
```
184+
del %AppData%\trapdata\trapdata.db
185+
```
186+
187+
## Running the web API
188+
189+
The model inference pipeline can be run as a web API using FastAPI. This is what the Antenna platform uses to process images.
190+
191+
To run the API, use the following command:
192+
193+
```sh
194+
ami api
195+
```
196+
197+
View the interactive API docs at http://localhost:2000/
198+
199+
200+
## Web UI demo (Gradio)
201+
202+
A simple web UI is also available to test the inference pipeline. This is a quick way to test models on a remote server via a web browser.
203+
204+
```sh
205+
ami gradio
206+
```
207+
208+
Open http://localhost:7861/
209+
210+
Use ngrok to temporarily expose localhost to the internet:
211+
212+
```sh
213+
ngrok http 7861
214+
```

0 commit comments

Comments
 (0)