-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
code/simclr-pytorch-reefs/evaluation/embeddings/YAMNet_embedding_extractor.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# import torch\n", | ||
"# import torch.nn as nn\n", | ||
"# import torchvision.models as models\n", | ||
"# from torch.utils.data import DataLoader" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Importing necessary modules\n", | ||
"import json\n", | ||
"\n", | ||
"# Load the JSON file\n", | ||
"json_path = '/home/ben/reef-audio-representation-learning/data/dataset.json'\n", | ||
"with open(json_path, 'r') as f:\n", | ||
" dataset_json = json.load(f)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 11, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Initialize an empty list to store the filtered entries\n", | ||
"filtered_entries = []\n", | ||
"\n", | ||
"# Filter entries based on 'data_type' and 'dataset'\n", | ||
"for entry in dataset_json['audio']:\n", | ||
" if entry['data_type'] == 'test_data' and entry['dataset'] == 'test_australia':\n", | ||
" # Convert the 'class' to numeric\n", | ||
" numeric_class = int(entry['class'].replace('class', ''))\n", | ||
" \n", | ||
" # Create a new dictionary with 'file_path' and numeric 'class'\n", | ||
" filtered_entry = {\n", | ||
" 'file_name': entry['file_name'],\n", | ||
" 'class': numeric_class\n", | ||
" }\n", | ||
" \n", | ||
" # Append the filtered entry to the list\n", | ||
" filtered_entries.append(filtered_entry)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "simclr_pytorch_reefs", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.12" | ||
}, | ||
"orig_nbformat": 4 | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Binary file not shown.