فهرست منبع

added Stanford Dogs dataset

Dimitri Korsch 6 سال پیش
والد
کامیت
f29c76526b
5فایلهای تغییر یافته به همراه66 افزوده شده و 2 حذف شده
  1. 2 0
      cvdatasets/annotations/__init__.py
  2. 49 0
      cvdatasets/annotations/dogs.py
  3. 2 2
      scripts/display.py
  4. 9 0
      scripts/info_files/info.yml
  5. 4 0
      scripts/utils/parser.py

+ 2 - 0
cvdatasets/annotations/__init__.py

@@ -3,6 +3,7 @@ from .nab import NAB_Annotations
 from .cars import CARS_Annotations
 from .inat import INAT19_Annotations
 from .flowers import FLOWERS_Annotations
+from .dogs import DOGS_Annotations
 from .hed import HED_Annotations
 
 from .base import BaseAnnotations
@@ -14,6 +15,7 @@ class AnnotationType(BaseChoiceType):
 	CUB200 = CUB_Annotations
 	NAB = NAB_Annotations
 	CARS = CARS_Annotations
+	DOGS = DOGS_Annotations
 	FLOWERS = FLOWERS_Annotations
 	HED = HED_Annotations
 

+ 49 - 0
cvdatasets/annotations/dogs.py

@@ -0,0 +1,49 @@
+import numpy as np
+
+from os.path import join
+
+from cvdatasets.utils import _MetaInfo
+from .base import BaseAnnotations, BBoxMixin
+
+
+class DOGS_Annotations(BaseAnnotations, BBoxMixin):
+	name="DOGS"
+
+	@property
+	def meta(self):
+		info = _MetaInfo(
+			images_folder="images",
+			images_file="images.txt",
+			labels_file="labels.txt",
+			split_file="tr_ID.txt",
+			bounding_boxes="bounding_boxes.txt",
+			bounding_box_dtype=np.dtype([(v, np.int32) for v in "xywh"]),
+			# parts_file=join("parts", "part_locs.txt"),
+			# part_names_file=join("parts", "parts.txt"),
+
+		)
+
+		info.structure = [
+			[info.images_file, "_images"],
+			[info.labels_file, "labels"],
+			[info.split_file, "_split"],
+			[info.bounding_boxes, "_bounding_boxes"],
+			# [info.parts_file, "_part_locs"],
+			# [info.part_names_file, "_part_names"],
+		]
+		return info
+
+
+	def parts(self, *args, **kwargs):
+		if self.has_parts:
+			return super(DOGS_Annotations, self).parts(*args, **kwargs)
+		return None
+
+	def _load_parts(self):
+		self.part_names = {}
+
+		# load only if present
+		if self.has_parts:
+			super(DOGS_Annotations, self)._load_parts()
+
+		self._load_bounding_boxes()

+ 2 - 2
scripts/display.py

@@ -59,8 +59,8 @@ def main(args):
 		axs[0].axis("off")
 		axs[0].set_title("Visible Parts")
 		axs[0].imshow(im)
-		# if not args.crop_to_bb:
-		# 	data.plot_bounding_box(i, axs[0])
+		if not args.crop_to_bb and not args.no_bboxes:
+			data.plot_bounding_box(i, axs[0])
 		parts.plot(im=im, ax=axs[0], ratio=data.ratio)
 
 		axs[1].axis("off")

+ 9 - 0
scripts/info_files/info.yml

@@ -65,6 +65,11 @@ DATASETS:
     annotations: "ORIGINAL"
     n_classes: 196
 
+  DOGS:         &dogs
+    folder: dogs
+    annotations: "ORIGINAL"
+    n_classes: 120
+
   FLOWERS:         &flowers
     folder: flowers
     annotations: "flowers102"
@@ -147,6 +152,10 @@ PARTS:
     <<: *cars
     <<: *parts_global
 
+  DOGS_GLOBAL:
+    <<: *dogs
+    <<: *parts_global
+
   NAB_GLOBAL:
     <<: *nabirds
     <<: *parts_global

+ 4 - 0
scripts/utils/parser.py

@@ -37,6 +37,10 @@ def parse_args():
 			help="select random subset of present parts",
 			action="store_true"),
 
+		Arg("--no_bboxes",
+			help="Do not display bounding boxes",
+			action="store_true"),
+
 		Arg("--crop_to_bb",
 			help="Crop image to the bounding box",
 			action="store_true"),