问题描述
我是 Python 和 Tensorflow 的新手
运行 Mask RCNN 代码来自
这是我的 train.py 配置部分,如下所示
导入操作系统导入系统导入json导入日期时间将 numpy 导入为 np导入 skimage.draw导入 cv2从 mrcnn.visualize 导入 display_instances导入 matplotlib.pyplot 作为 plt# 项目根目录ROOT_DIR = ""# 导入掩码 RCNNsys.path.append(ROOT_DIR) # 查找本地版本的库从mrcnn.config 导入配置从mrcnn导入模型作为modellib,utils# 训练权重文件的路径COCO_WEIGHTS_PATH = os.path.join(ROOT_DIR, "mask_rcnn_coco.h5")# 保存日志和模型检查点的目录,如果没有提供# 通过命令行参数 --logsDEFAULT_LOGS_DIR = os.path.join(ROOT_DIR,日志")类自定义配置(配置):"""玩具数据集训练配置.派生自基础 Config 类并覆盖一些值."""# 给配置一个可识别的名称名称 = "BH"# 我们使用具有 12GB 内存的 GPU,可以容纳两个图像.# 如果您使用较小的 GPU,请向下调整.图像_PER_GPU = 1# 类的数量(包括背景)NUM_CLASSES = 1 + 1 # 背景 + 玩具# 每个时期的训练步骤数STEPS_PER_EPOCH = 100# 使用 < 跳过检测90% 的信心DETECTION_MIN_CONFIDENCE = 0.9
我已经等了半个小时,似乎无法进入下一步.请给一些建议.
它不是卡住",而是在训练中.Epoch 1/10 表示当前处于第一个 epoch,一个 epoch 有 100 步,每个 epoch 的速度可以根据代码中的不同细节而有所不同.例如
- 您在使用 GPU 吗?如果没有,那么 mask-rcnn 训练将非常缓慢.
- 您的输入图像尺寸是多少?如果太大,则网络训练速度会很慢(注意:任意大的输入图像可以小到 300x300 像素)
您应该知道,即使在 GPU 上,通常一个 epoch 也可能需要数小时来训练,如果您使用的是 CPU,那么该时间可能会翻两番.
总而言之,请耐心等待.它的训练.
您是深度学习/计算机视觉以及 Python 和 TF 的新手吗?
I'm new to Python and Tensorflow
Running Mask RCNN code from this tutorial and got stuck at
"Converting sparse IndexedSlices to a dense Tensor of unknown shape. "
Here's my configuration part of train.py shown as following
import os
import sys
import json
import datetime
import numpy as np
import skimage.draw
import cv2
from mrcnn.visualize import display_instances
import matplotlib.pyplot as plt
# Root directory of the project
ROOT_DIR = ""
# Import Mask RCNN
sys.path.append(ROOT_DIR) # To find local version of the library
from mrcnn.config import Config
from mrcnn import model as modellib, utils
# 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")
class CustomConfig(Config):
"""Configuration for training on the toy dataset.
Derives from the base Config class and overrides some values.
"""
# Give the configuration a recognizable name
NAME = "BH"
# We use a GPU with 12GB memory, which can fit two images.
# Adjust down if you use a smaller GPU.
IMAGES_PER_GPU = 1
# Number of classes (including background)
NUM_CLASSES = 1 + 1 # Background + toy
# Number of training steps per epoch
STEPS_PER_EPOCH = 100
# Skip detections with < 90% confidence
DETECTION_MIN_CONFIDENCE = 0.9
I've waited for half an hour and seem like it can't get to the next step. Please give some suggestions.
its not "stuck", its in training. Epoch 1/10 means its currently on the first epoch and there are 100 steps in an epoch, the speed of each epoch can vary according to different specifics in the code. For example
- Are you using a GPU? If no then mask-rcnn training will be extremely slow.
- What is your input image size? If its too large then the network will train slowly (Note: an arbitrarily large input image can be as small as 300x300 pixels)
You should know that even on GPU, often an epoch can take hours to train, if you're on CPU then that time can quadruple.
All in all, be patient. Its training.
Are you new to deep learning / computer vision as well, along with python and TF?
这篇关于运行 Mask RCNN 代码并停留在“将稀疏索引切片转换为未知形状的密集张量"上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!