Closed MikeXlYang closed 6 years ago
Problem has been solved. Some of the images have no instances
Hey, I face the same issue. but I wonder why it takes only images with instances? Does it really make sense? For example, if I wanna train a binary class task, some images just have background, some have instances. For those simply contains background, it should also learn that type of instance-free images, isn't it? in my tasks, instances are very less than images with simply background,
@MikeXlYang I'm facing the same problem. How did you deal with images with no instances? Do you delete them directly?
Yes I simply added an if judgement before loading an image.
---Original--- From: "thomasyue"notifications@github.com Date: Wed, May 8, 2019 23:13 PM To: "matterport/Mask_RCNN"Mask_RCNN@noreply.github.com; Cc: "Mike Xilin Yang"1113670776@qq.com;"Mention"mention@noreply.github.com; Subject: Re: [matterport/Mask_RCNN] Unexpected Error while using my own dataset. (#829)
@MikeXlYang I'm facing the same problem. How did you deal with images with no instances? Do you delete them directly?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
@MikeXlYang So if the mask is empty, you won't train the image, correct? In this case, if the model is predicting a test image without instance, will it able to detect?
I'm using MICCAI 2017 EndoVis to do instance segmentation on surgical tools. The datasets includes 1800 images(25 of which have none instances and were excluded). I write my own tool.py as shown below. But when I started training the follow error occurs and the training process doesn't stop until sever iterations. The same error happened while another user using 8-channel images. But I'm only using simple 3-channel ones. I could really use some help as I'm pretty bad in tf and python. Really appreciate your help.
ERROR:root:Error processing image {'id': '7frame032', 'path': '/home/user/MaskRCNN/Mask_RCNN-master/ReArranged_origin/Left_frames/7frame032.png', 'source': 'tools'} Traceback (most recent call last): File "/home/user/.local/lib/python3.5/site-packages/mask_rcnn-2.1-py3.5.egg/mrcnn/model.py", line 1704, in data_generator use_mini_mask=config.USE_MINI_MASK) File "/home/user/.local/lib/python3.5/site-packages/mask_rcnn-2.1-py3.5.egg/mrcnn/model.py", line 1227, in load_image_gt mask = utils.resize_mask(mask, scale, padding, crop) File "/home/user/.local/lib/python3.5/site-packages/mask_rcnn-2.1-py3.5.egg/mrcnn/utils.py", line 517, in resize_mask mask = scipy.ndimage.zoom(mask, zoom=[scale, scale, 1], order=0) File "/home/user/.local/lib/python3.5/site-packages/scipy/ndimage/interpolation.py", line 573, in zoom zoom = _ni_support._normalize_sequence(zoom, input.ndim) File "/home/user/.local/lib/python3.5/site-packages/scipy/ndimage/_ni_support.py", line 65, in _normalize_sequence
And the following are my tools.py `import os import sys import json import datetime import numpy as np import skimage.io from imgaug import augmenters as iaa
Root directory of the project
ROOT_DIR = os.path.abspath("../../")
Import Mask RCNN
sys.path.append(ROOT_DIR) # To find local version of the library from mrcnn.config import Config from mrcnn import utils from mrcnn import model as modellib from mrcnn import visualize
Path to trained weights file
COCO_WEIGHTS_PATH = os.path.join(ROOT_DIR, "mask_rcnn_coco.h5")
Directory to save logs and model checkpoints, if not provided
through the command line argument --logs
DEFAULT_LOGS_DIR = os.path.join(ROOT_DIR, "logs")
Results directory
Save submission files here
RESULTS_DIR = os.path.join(ROOT_DIR, "results/tools/")
Under Linux
RESULTS_DIR = os.path.join(ROOT_DIR, r"results\tools")
To acquire val sets, I choose to segment the sequences with
constant gaps.
templenum = 0 templename = '' templename2 = '' valname = '' fullidname = '' VAL_IMAGE_IDS = [] for idcount in range(1,226): if idcount % 9 == 1: templenum = str(idcount) while len(templenum) < 3: templenum = '0' + templenum VAL_IMAGE_IDS.append('frame' + str(templenum))
WRONG_IMAGE_IDS = ['5frame092','5frame093','7frame077', '7frame078','7frame079','7frame081', '7frame086','7frame092','7frame093', '7frame094','7frame095','7frame137', '7frame138','7frame139','7frame140', '7frame141','7frame144','7frame157', '7frame158','7frame159'] ############################################################
Configurations
############################################################
class ToolsConfig(Config): """Configuration for training on the nucleus segmentation dataset."""
Give the configuration a recognizable name
class ToolsDataset(utils.Dataset):
############################################################
Training
############################################################
def train(model, dataset_dir, subset): """Train the model."""
Training dataset.
config = ToolsConfig() config.display() model = modellib.MaskRCNN(mode="training", config=config, model_dir=DEFAULT_LOGS_DIR) weights_path = COCO_WEIGHTS_PATH model.load_weights(weights_path, by_name=True, exclude=[ "mrcnn_class_logits", "mrcnn_bbox_fc", "mrcnn_bbox", "mrcnn_mask"]) datasetsdir = os.path.join(ROOT_DIR,'ReArranged_origin') train(model, datasetsdir, 'train')`