Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dataset slicing and fix remove annotations #1131

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions icevision/core/record_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ def _autofix(self) -> Dict[str, bool]:

def _remove_annotation(self, i):
self.label_ids.pop(i)
self.labels.pop(i)

def _aggregate_objects(self) -> Dict[str, List[dict]]:
return {**super()._aggregate_objects(), "labels": self.label_ids}
Expand Down
15 changes: 9 additions & 6 deletions icevision/data/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@ def __len__(self):
return len(self.records)

def __getitem__(self, i):
record = self.records[i].load()
if self.tfm is not None:
record = self.tfm(record)
if isinstance(i, slice):
return self.__class__(self.records[i], self.tfm)
else:
# HACK FIXME
record.set_img(np.array(record.img))
return record
record = self.records[i].load()
if self.tfm is not None:
record = self.tfm(record)
else:
# HACK FIXME
record.set_img(np.array(record.img))
return record

def __repr__(self):
return f"<{self.__class__.__name__} with {len(self.records)} items>"
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ inference =

all =
fastai >=2.5.2,<2.6
pytorch-lightning >=1.4.5
pytorch-lightning >=1.4.5,<1.7.0
wandb >=0.10.7

dev =
Expand Down