Commit 0050d6e7 authored by Yuxin Wu's avatar Yuxin Wu

update docs

parent 264b1e4e
......@@ -12,7 +12,6 @@ from tensorpack.utils.rect import FloatBox
from tensorpack.utils.timer import timed_operation
from tensorpack.utils.argtools import log_once
from pycocotools.coco import COCO
from config import config as cfg
......@@ -63,6 +62,7 @@ class COCODetection(object):
basedir, 'annotations/instances_{}.json'.format(name))
assert os.path.isfile(annotation_file), annotation_file
from pycocotools.coco import COCO
self.coco = COCO(annotation_file)
# initialize the meta
......
......@@ -7,8 +7,6 @@ import cv2
from tensorpack.dataflow import RNGDataFlow
from tensorpack.dataflow.imgaug import transform
import pycocotools.mask as cocomask
class DataFromListOfDict(RNGDataFlow):
def __init__(self, lst, keys, shuffle=False):
......@@ -95,6 +93,8 @@ def segmentation_to_mask(polys, height, width):
a binary matrix of (height, width)
"""
polys = [p.flatten().tolist() for p in polys]
import pycocotools.mask as cocomask
rles = cocomask.frPyObjects(polys, height, width)
rle = cocomask.merge(rles)
return cocomask.decode(rle)
......
......@@ -64,7 +64,7 @@ _C.DATA.BASEDIR = '/path/to/your/COCO/DIR'
_C.DATA.TRAIN = ['train2014', 'valminusminival2014'] # i.e., trainval35k
_C.DATA.VAL = 'minival2014' # For now, only support evaluation on single dataset
_C.DATA.NUM_CATEGORY = 80 # 80 categories.
_C.DATA.CLASS_NAMES = [] # NUM_CLASS strings. Needs to be populated later by data loader
_C.DATA.CLASS_NAMES = [] # NUM_CLASS (NUM_CATEGORY+1) strings, to be populated later by data loader. The first is BG.
# basemodel ----------------------
_C.BACKBONE.WEIGHTS = '' # /path/to/weights.npz
......
......@@ -264,9 +264,9 @@ def get_train_dataflow():
To train on your own data, change this to your loader.
Produce "imgs" as a list of dict, in the dict the following keys are needed for training:
height, width: integer
file_name: str
boxes: kx4 floats
class: k integers
file_name: str, full path to the image
boxes: numpy array of kx4 floats
class: numpy array of k integers
is_crowd: k booleans. Use k False if you don't know what it means.
segmentation: k lists of numpy arrays (one for each box).
Each list of numpy array corresponds to the mask for one instance.
......
......@@ -239,7 +239,7 @@ def fastrcnn_2fc_head(feature, num_classes):
def fastrcnn_Xconv1fc_head(feature, num_classes, num_convs, norm=None):
"""
Args:
feature (any shape):
feature (NCHW):
num_classes(int): num_category + 1
num_convs (int): number of conv layers
norm (str or None): either None or 'GN'
......
......@@ -12,6 +12,7 @@ from config import config as cfg
def draw_annotation(img, boxes, klass, is_crowd=None):
"""Will not modify img"""
labels = []
assert len(boxes) == len(klass)
if is_crowd is not None:
......
......@@ -178,7 +178,7 @@ def get_checkpoint_path(model_path):
elif model_path.endswith('.index'):
new_path = model_path.split('.index')[0]
if new_path != model_path:
logger.warn(
logger.info(
"Checkpoint path {} is auto-corrected to {}.".format(model_path, new_path))
model_path = new_path
assert tf.gfile.Exists(model_path) or tf.gfile.Exists(model_path + '.index'), model_path
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment