Mask_RCNN
Mask_RCNN copied to clipboard
WARNING:root:You are using the default load_mask(), maybe you need to define your own one.
class weedDataset(utils.Dataset): def load_custom(self, dataset_dir, subset): # Add classes self.add_class("object", 1, "crop") self.add_class("object", 2, "weed") assert subset in ["train", "val"] dataset_dir = os.path.join(dataset_dir, subset) if subset == "train": annotations1 = json.load(open('/content/drive/MyDrive/demo/Dataset/train/potatodemo_json.json')) elif subset == "val": annotations1 = json.load(open('/content/drive/MyDrive/demo/Dataset/val/potatoweedval_json.json'))
#annotations1 = json.load(open("/content/drive/MyDrive/demo/Dataset/train/potatodemo_json.json"))
#annotations2 = json.load(open("/content/drive/MyDrive/demo/Dataset/val/potatoweedval_json.json"))
#print(annotations1)
annotations = list(annotations1.values()) # don't need the dict keys
#annotations = list(annotations2.values())
# The VIA tool saves images in the JSON even if they don't have any
# annotations. Skip unannotated images.
annotations = [a for a in annotations if a['regions']]
# Add images
for a in annotations:
# print(a)
# Get the x, y coordinaets of points of the polygons that make up
# the outline of each object instance. There are stores in the
# shape_attributes (see json format above)
if type(a['regions']) is dict:
polygons = [r['shape_attributes'] for r in a['regions'].values()]
else:
polygons = [r['shape_attributes'] for r in a['regions']]
objects = [s['region_attributes']['names'] for s in a['regions']]
print("objects:",objects)
name_dict = {"crop": 1,"weed": 2} #,"xyz": 3}
# key = tuple(name_dict)
num_ids = [name_dict[a] for a in objects]
# num_ids = [int(n['Event']) for n in objects]
# load_mask() needs the image size to convert polygons to masks.
# Unfortunately, VIA doesn't include it in JSON, so we must read
# the image. This is only managable since the dataset is tiny.
print("numids",num_ids)
image_path = os.path.join(dataset_dir, a['filename'])
image = skimage.io.imread(image_path)
height, width = image.shape[:2]
self.add_image(
"object", ## for a single class just add the name here
image_id=a['filename'], # use file name as a unique image id
path=image_path,
width=width, height=height,
polygons=polygons,
num_ids=num_ids
)
### def load_mask
def load_mask(self, image_id): """Generate instance masks for an image. Returns: masks: A bool array of shape [height, width, instance count] with one mask per instance. class_ids: a 1D array of class IDs of the instance masks. """ # If not a Dog-Cat dataset image, delegate to parent class. image_info = self.image_info[image_id] #if image_info["source"] != "object": #return super(self.class, self).load_mask(image_id)
# Convert polygons to a bitmap mask of shape
# [height, width, instance_count]
info = self.image_info[image_id]
if info["source"] != "object":
return super(self.__class__, self).load_mask(image_id)
num_ids = info['num_ids']
mask = np.zeros([info["height"], info["width"], len(info["polygons"])],
dtype=np.uint8)
for i, p in enumerate(info["polygons"]):
# Get indexes of pixels inside the polygon and set them to 1
rr, cc = skimage.draw.polygon(p['all_points_y'], p['all_points_x'])
mask[rr, cc, i] = 1
# Return mask, and array of class IDs of each instance. Since we have
# one class ID only, we return an array of 1s
# Map class names to class IDs.
num_ids = np.array(num_ids, dtype=np.int32)
return mask, num_ids #np.ones([mask.shape[-1]], dtype=np.int32)
if 'num_ids' in p:
num_ids[i] = p['num_ids']
else:
num_ids[i] = 1
return mask.astype(np.bool), num_ids
objects: ['crop', 'weed']
numids [1, 2]
objects: ['crop', 'weed']
numids [1, 2]
objects: ['crop', 'crop', 'crop']
numids [1, 1, 1]
objects: ['crop']
numids [1]
objects: ['crop']
numids [1]
objects: ['crop', 'weed']
numids [1, 2]
objects: ['weed', 'crop']
numids [2, 1]
objects: ['crop', 'weed']
numids [1, 2]
objects: ['crop', 'weed', 'weed']
numids [1, 2, 2]
objects: ['crop', 'weed', 'crop']
numids [1, 2, 1]
objects: ['crop', 'weed']
numids [1, 2]
objects: ['crop', 'weed']
numids [1, 2]
objects: ['crop', 'weed']
numids [1, 2]
objects: ['crop', 'crop', 'weed']
numids [1, 1, 2]
objects: ['crop', 'weed']
numids [1, 2]
objects: ['crop', 'weed']
numids [1, 2]
WARNING:absl:lr
is deprecated in Keras optimizer, please use learning_rate
or use the legacy optimizer, e.g.,tf.keras.optimizers.legacy.SGD.
Starting at epoch 0. LR=0.001
Checkpoint Path: /content/drive/MyDrive/demo/logs/object20230616T1027/mask_rcnn_object_{epoch:04d}.h5 Selecting layers to train fpn_c5p5 (Conv2D) fpn_c4p4 (Conv2D) fpn_c3p3 (Conv2D) fpn_c2p2 (Conv2D) fpn_p5 (Conv2D) fpn_p2 (Conv2D) fpn_p3 (Conv2D) fpn_p4 (Conv2D) rpn_model (Functional) mrcnn_mask_conv1 (TimeDistributed) mrcnn_mask_bn1 (TimeDistributed) mrcnn_mask_conv2 (TimeDistributed) mrcnn_mask_bn2 (TimeDistributed) mrcnn_class_conv1 (TimeDistributed) mrcnn_class_bn1 (TimeDistributed) mrcnn_mask_conv3 (TimeDistributed) mrcnn_mask_bn3 (TimeDistributed) mrcnn_class_conv2 (TimeDistributed) mrcnn_class_bn2 (TimeDistributed) mrcnn_mask_conv4 (TimeDistributed) mrcnn_mask_bn4 (TimeDistributed) mrcnn_bbox_fc (TimeDistributed) mrcnn_mask_deconv (TimeDistributed) mrcnn_class_logits (TimeDistributed) mrcnn_mask (TimeDistributed) Epoch 1/10 Streaming output truncated to the last 5000 lines. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one. WARNING:root:You are using the default load_mask(), maybe you need to define your own one.
I am getting continously this while training please help
Did you solve the issue