MCPcopy
hub / github.com/matterport/Mask_RCNN / prepare

Method prepare

utils.py:286–317  ·  view source on GitHub ↗

Prepares the Dataset class for use. TODO: class map is not supported yet. When done, it should handle mapping classes from different datasets to the same class ID.

(self, class_map=None)

Source from the content-addressed store, hash-verified

284 return ""
285
286 def prepare(self, class_map=None):
287 """Prepares the Dataset class for use.
288
289 TODO: class map is not supported yet. When done, it should handle mapping
290 classes from different datasets to the same class ID.
291 """
292
293 def clean_name(name):
294 """Returns a shorter version of object names for cleaner display."""
295 return ",".join(name.split(",")[:1])
296
297 # Build (or rebuild) everything else from the info dicts.
298 self.num_classes = len(self.class_info)
299 self.class_ids = np.arange(self.num_classes)
300 self.class_names = [clean_name(c["name"]) for c in self.class_info]
301 self.num_images = len(self.image_info)
302 self._image_ids = np.arange(self.num_images)
303
304 self.class_from_source_map = {"{}.{}".format(info['source'], info['id']): id
305 for info, id in zip(self.class_info, self.class_ids)}
306
307 # Map sources to class_ids they support
308 self.sources = list(set([i['source'] for i in self.class_info]))
309 self.source_class_ids = {}
310 # Loop over datasets
311 for source in self.sources:
312 self.source_class_ids[source] = []
313 # Find classes that belong to this dataset
314 for i, info in enumerate(self.class_info):
315 # Include BG class in all datasets
316 if i == 0 or source == info['source']:
317 self.source_class_ids[source].append(i)
318
319 def map_source_class_id(self, source_class_id):
320 """Takes a source class ID and returns the int class ID assigned to it.

Callers 2

coco.pyFile · 0.80
trainFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected