Skip to content

Commit

Permalink
fix #1043
Browse files Browse the repository at this point in the history
  • Loading branch information
ppwwyyxx committed Jan 11, 2019
1 parent 0b2ab4a commit 8566797
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
9 changes: 5 additions & 4 deletions examples/FasterRCNN/dataset.py
Expand Up @@ -7,7 +7,6 @@
import json

from tensorpack.utils import logger
from tensorpack.utils.argtools import log_once
from tensorpack.utils.timer import timed_operation

from config import config as cfg
Expand Down Expand Up @@ -121,7 +120,7 @@ def _add_detection_gt(self, img, add_mask):
valid_objs = []
width = img['width']
height = img['height']
for obj in objs:
for objid, obj in objs:
if obj.get('ignore', 0) == 1:
continue
x1, y1, w, h = obj['bbox']
Expand All @@ -145,8 +144,10 @@ def _add_detection_gt(self, img, add_mask):
obj['segmentation'] = None
else:
valid_segs = [np.asarray(p).reshape(-1, 2).astype('float32') for p in segs if len(p) >= 6]
if len(valid_segs) < len(segs):
log_once("Image {} has invalid polygons!".format(img['file_name']), 'warn')
if len(valid_segs) == 0:
logger.error("Object {} in image {} has no valid polygons!".format(objid, img['file_name']))
elif len(valid_segs) < len(segs):
logger.warn("Object {} in image {} has invalid polygons!".format(objid, img['file_name']))

obj['segmentation'] = valid_segs

Expand Down
8 changes: 4 additions & 4 deletions examples/ResNet/load-resnet.py
Expand Up @@ -47,10 +47,10 @@ def build_graph(self, image, label):
logits = (LinearWrap(image)
.Conv2D('conv0', 64, 7, strides=2, activation=BNReLU, padding='VALID')
.MaxPooling('pool0', 3, strides=2, padding='SAME')
.apply(resnet_group, 'group0', bottleneck, 64, blocks[0], 1)
.apply(resnet_group, 'group1', bottleneck, 128, blocks[1], 2)
.apply(resnet_group, 'group2', bottleneck, 256, blocks[2], 2)
.apply(resnet_group, 'group3', bottleneck, 512, blocks[3], 2)
.apply2(resnet_group, 'group0', bottleneck, 64, blocks[0], 1)
.apply2(resnet_group, 'group1', bottleneck, 128, blocks[1], 2)
.apply2(resnet_group, 'group2', bottleneck, 256, blocks[2], 2)
.apply2(resnet_group, 'group3', bottleneck, 512, blocks[3], 2)
.GlobalAvgPooling('gap')
.FullyConnected('linear', 1000)())
tf.nn.softmax(logits, name='prob')
Expand Down
3 changes: 3 additions & 0 deletions tensorpack/models/linearwrap.py
Expand Up @@ -80,6 +80,9 @@ def apply2(self, func, *args, **kwargs):
Apply a function on the wrapped tensor. The tensor
will be the second argument of func.
This is because many symbolic functions
(such as tensorpack's layers) takes 'scope' as the first argument.
Returns:
LinearWrap: ``LinearWrap(func(args[0], self.tensor(), *args[1:], **kwargs))``.
"""
Expand Down

0 comments on commit 8566797

Please sign in to comment.