Skip to content

Commit

Permalink
Typing error fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gagewrye committed Nov 23, 2024
1 parent 15f9fb3 commit c6f4ef2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions DroneClassification/data/MemoryMapDataset.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from torch.utils.data import Dataset, Sampler, BatchSampler, DataLoader
import numpy as np
from typing import Optional
from typing import Optional, List, Tuple
import torch

class MemmapDataset(Dataset):
def __init__(self, images: np.ndarray, labels: np.ndarray, validation_indices: Optional[tuple] = None,):
def __init__(self, images: np.ndarray, labels: np.ndarray, validation_indices: Optional[Tuple] = None,):
"""
Inputs are expected to be memory mapped numpy arrays (.npy)
Expand All @@ -30,7 +30,7 @@ def __init__(self, images: np.ndarray, labels: np.ndarray, validation_indices: O
def __len__(self) -> int:
return self.images.shape[0]

def __getitem__(self, idx) -> tuple:
def __getitem__(self, idx) -> Tuple:
image = self.images[idx]
label = self.labels[idx]

Expand Down Expand Up @@ -58,7 +58,7 @@ def split(self, split_ratio: float):

return train_dataset, val_dataset

def split_into_folds(self, num_folds: int) -> list[Dataset]:
def split_into_folds(self, num_folds: int) -> List[Dataset]:
"""
Creates a list of validation datasets for cross validation.
The original dataset will be used as the training dataset.
Expand Down Expand Up @@ -92,7 +92,7 @@ class SliceSampler(Sampler):
Takes slices of the dataset to minimize overhead of accessing a memory mapped array.
Can optionally skip indices to allow for cross validation with memory mapping.
"""
def __init__(self, dataset_len, batch_size, skip_indices: Optional[tuple] = None):
def __init__(self, dataset_len, batch_size, skip_indices: Optional[Tuple] = None):
self.dataset_len = dataset_len
self.batch_size = batch_size
self.start_skip = None
Expand Down
6 changes: 3 additions & 3 deletions DroneClassification/data/prepare_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -239,7 +239,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "mangrove",
"display_name": "i2sb",
"language": "python",
"name": "python3"
},
Expand All @@ -253,7 +253,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.14"
"version": "3.8.18"
},
"orig_nbformat": 4
},
Expand Down

0 comments on commit c6f4ef2

Please sign in to comment.