简体   繁体   English

如何在matterport/Mask_RCNN 示例中减少batch_size 和image_shape?

[英]How can I reduce the batch_size and the image_shape in the matterport/Mask_RCNN example?

When I run the following code, I get the following error当我运行以下代码时,出现以下错误

from mrcnn.config import Config

class KangarooConfig(Config):
    # define the name of the configuration
    NAME = "kangaroo_cfg"
    # number of classes (background + kangaroo)
    NUM_CLASSES = 1 + 1
    # number of training steps per epoch
    STEPS_PER_EPOCH = 131


from mrcnn.model import MaskRCNN

# prepare config
config = KangarooConfig()
config.display()
# define the model
model = MaskRCNN(mode='training', model_dir='./', config=config)
model.keras_model.metrics_tensors = []


# load weights (mscoco) and exclude the output layers
model.load_weights('mask_rcnn_coco.h5', by_name=True, exclude=["mrcnn_class_logits", "mrcnn_bbox_fc",  "mrcnn_bbox", "mrcnn_mask"] )
# train weights (output layers or 'heads')
model.train(train_set, test_set, learning_rate=config.LEARNING_RATE, epochs=5, layers='heads' )

Error:错误:

ResourceExhaustedError: 2 root error(s) found. ResourceExhaustedError: 发现 2 个根错误。 (0) Resource exhausted: OOM when allocating tensor with shape[400,14,14,256] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc (0) 资源耗尽:当分配形状为[400,14,14,256]的张量并通过分配器GPU_0_bfc在/job:localhost/replica:0/task:0/device:GPU:0上输入float时OOM

How can I reduce the batch_size and the image_size in this case?在这种情况下,如何减少batch_size 和image_size?

代码输出

Go to your Config.py file and change转到您的Config.py文件并更改

 IMAGE_MIN_DIM = 800 to 400
 IMAGE_MAX_DIM = 1024 to 512

and

IMAGES_PER_GPU = 2 to 1
IMAGE_RESIZE_MODE = "square" to "none"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 mask_rcnn 保存图像结果 - how can i save my result of image using mask_rcnn 如何使用 coremltools 将 matterport mask_rcnn keras(.h5) model 转换为 coreml 模型(.mlmodel) - How to convert matterport mask_rcnn keras(.h5) model to coreml model(.mlmodel) using coremltools 在 Matterport 上设置张量板 - Mask RCNN - Set up tensorboard on Matterport - Mask RCNN 从Mask_RCNN张量检索信息 - Retrieving information from a Mask_RCNN Tensor 如何从此Pytorch代码中找到Keras中使用的等效“ batch_size”? - How can I find the equivalent 'batch_size' used in Keras from this Pytorch code? 张量流中的不同图像大小与batch_size = 1 - Different image sizes in tensorflow with batch_size =1 要整形的输入是具有2 *“ batch_size”值的张量,但是请求的形状具有“ batch_size” - Input to reshape is a tensor with 2 * “batch_size” values, but the requested shape has “batch_size” Matterport-Mask RCNN 中每个时期的步骤/验证步骤 - Steps per Epoch/Validation steps in Matterport-Mask RCNN FileNotFoundError("No such file: '%s'" % fn) FileNotFoundError: No such file: (Mask_RCNN) - FileNotFoundError("No such file: '%s'" % fn) FileNotFoundError: No such file: (Mask_RCNN) 有没有一种方法可以在减少batch_size的同时减少执行时间? - Is there a way to reduce execution time while reducing batch_size?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM