Spaces:
Running
on
Zero
Running
on
Zero
Type annotation
Browse files- dataset.py +3 -3
dataset.py
CHANGED
|
@@ -18,7 +18,7 @@ class ImageDataset:
|
|
| 18 |
)
|
| 19 |
return ImageDataset(new_images)
|
| 20 |
|
| 21 |
-
def remove_image(self, image_id):
|
| 22 |
"""Return new instance with image removed by ID."""
|
| 23 |
new_images = [img for img in self.images if img["id"] != image_id]
|
| 24 |
# Reindex remaining images
|
|
@@ -27,7 +27,7 @@ class ImageDataset:
|
|
| 27 |
img["name"] = f"Image {i + 1}"
|
| 28 |
return ImageDataset(new_images)
|
| 29 |
|
| 30 |
-
def update_label(self, image_id, label):
|
| 31 |
"""Return new instance with updated label."""
|
| 32 |
new_images = []
|
| 33 |
for img in self.images:
|
|
@@ -37,7 +37,7 @@ class ImageDataset:
|
|
| 37 |
new_images.append(new_img)
|
| 38 |
return ImageDataset(new_images)
|
| 39 |
|
| 40 |
-
def update_all_labels(self, labels_dict):
|
| 41 |
"""Return new instance with all labels updated."""
|
| 42 |
new_images = []
|
| 43 |
for img in self.images:
|
|
|
|
| 18 |
)
|
| 19 |
return ImageDataset(new_images)
|
| 20 |
|
| 21 |
+
def remove_image(self, image_id: int):
|
| 22 |
"""Return new instance with image removed by ID."""
|
| 23 |
new_images = [img for img in self.images if img["id"] != image_id]
|
| 24 |
# Reindex remaining images
|
|
|
|
| 27 |
img["name"] = f"Image {i + 1}"
|
| 28 |
return ImageDataset(new_images)
|
| 29 |
|
| 30 |
+
def update_label(self, image_id: int, label: str):
|
| 31 |
"""Return new instance with updated label."""
|
| 32 |
new_images = []
|
| 33 |
for img in self.images:
|
|
|
|
| 37 |
new_images.append(new_img)
|
| 38 |
return ImageDataset(new_images)
|
| 39 |
|
| 40 |
+
def update_all_labels(self, labels_dict: dict):
|
| 41 |
"""Return new instance with all labels updated."""
|
| 42 |
new_images = []
|
| 43 |
for img in self.images:
|