![]() ![]() zeros (, info, len ( info ) ], dtype = np. load_mask ( image_id ) # Convert polygons to a bitmap mask of shape # info = self. image_info if image_info != "tumor" : return super ( self. "" " # If not a farm_cow dataset image, delegate to parent class. class_ids : a 1 D array of class IDs of the instance masks. Returns : masks : A bool array of shape with one mask per instance. add_image ( "tumor", image_id = a, # use file name as a unique image id path = image_path, width = width, height = height, polygons = polygons ) def load_mask ( self, image_id ) : "" "Generate instance masks for an image. imread ( image_path ) height, width = image. join ( dataset_dir, a ) image = skimage. This is only managable since the dataset is tiny. # Unfortunately, VIA doesn't include it in JSON, so we must read # the image. values ( ) ] else : polygons = for r in a ] # load_mask ( ) needs the image size to convert polygons to masks. if type ( a ) is dict : polygons = for r in a. These are stores in the # shape_attributes ( see json format above ) # The if condition is needed to support VIA versions 1. annotations = ] # Add images for a in annotations : # Get the x, y coordinaets of points of the polygons that make up # the outline of each object instance. values ( ) ) # don 't need the dict keys# The VIA tool saves images in the JSON even if they don' t have any # annotations. join ( DATASET_DIR, subset, 'annotations_' + subset + '.json' ) ) ) annotations = list ( annotations. join ( dataset_dir, subset ) annotations = json. add_class ( "tumor", 1, "tumor" ) # Train or validation dataset ? assert subset in dataset_dir = os. ![]() subset : Subset to load : train or val "" " # Add classes. dataset_dir : Root directory of the dataset. Dataset ) : def load_brain_scan ( self, dataset_dir, subset ) : "" "Load a subset of the FarmCow dataset.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |