diff --git a/PytorchWildlife/utils/post_process.py b/PytorchWildlife/utils/post_process.py index 27a364557..ef6f028b7 100644 --- a/PytorchWildlife/utils/post_process.py +++ b/PytorchWildlife/utils/post_process.py @@ -220,7 +220,7 @@ def save_detection_classification_json( "clf_confidence": [float(x) for x in clf_confidence], } ) - json.dump(json_results, f) + json.dump(json_results, f, indent=4) def save_detection_classification_timelapse_json( diff --git a/demo/image_detection_colabdemo.ipynb b/demo/image_detection_colabdemo.ipynb index 42bdc7a2b..1c2451ea9 100644 --- a/demo/image_detection_colabdemo.ipynb +++ b/demo/image_detection_colabdemo.ipynb @@ -1047,6 +1047,26 @@ " exclude_category_ids=[]) # Category IDs can be found in the definition of each model." ] }, + { + "cell_type": "markdown", + "id": "20251521", + "metadata": {}, + "source": [ + "### 3.1 Timelapse JSON Format:\n", + "PytorchWildlife is compatible with Timelapse, a popular tool to visualize and process camera trap data. This code will output the detection results in a JSON format compatible with Timelapse:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0689bc45", + "metadata": {}, + "outputs": [], + "source": [ + "pw_utils.save_detection_timelapse_json(results, os.path.join(\".\",\"batch_output_timelapse.json\"),\n", + " categories=detection_model.CLASS_NAMES)" + ] + }, { "cell_type": "markdown", "id": "a4ee1d7b",