Coder Social home page Coder Social logo

taehoonlee / tensornets Goto Github PK

View Code? Open in Web Editor NEW
1.0K 52.0 185.0 2.19 MB

High level network definitions with pre-trained weights in TensorFlow

License: MIT License

Python 100.00%
tensorflow model zoo deep-learning object-detection yolo yolov2 yolov3 faster-rcnn resnet

tensornets's Introduction

TensorNets Build Status

High level network definitions with pre-trained weights in TensorFlow (tested with 2.1.0 >= TF >= 1.4.0).

Guiding principles

  • Applicability. Many people already have their own ML workflows, and want to put a new model on their workflows. TensorNets can be easily plugged together because it is designed as simple functional interfaces without custom classes.
  • Manageability. Models are written in tf.contrib.layers, which is lightweight like PyTorch and Keras, and allows for ease of accessibility to every weight and end-point. Also, it is easy to deploy and expand a collection of pre-processing and pre-trained weights.
  • Readability. With recent TensorFlow APIs, more factoring and less indenting can be possible. For example, all the inception variants are implemented as about 500 lines of code in TensorNets while 2000+ lines in official TensorFlow models.
  • Reproducibility. You can always reproduce the original results with simple APIs including feature extractions. Furthermore, you don't need to care about a version of TensorFlow beacuse compatibilities with various releases of TensorFlow have been checked with Travis.

Installation

You can install TensorNets from PyPI (pip install tensornets) or directly from GitHub (pip install git+https://github.com/taehoonlee/tensornets.git).

A quick example

Each network (see full list) is not a custom class but a function that takes and returns tf.Tensor as its input and output. Here is an example of ResNet50:

import tensorflow as tf
# import tensorflow.compat.v1 as tf  # for TF 2
import tensornets as nets
# tf.disable_v2_behavior()  # for TF 2

inputs = tf.placeholder(tf.float32, [None, 224, 224, 3])
model = nets.ResNet50(inputs)

assert isinstance(model, tf.Tensor)

You can load an example image by using utils.load_img returning a np.ndarray as the NHWC format:

img = nets.utils.load_img('cat.png', target_size=256, crop_size=224)
assert img.shape == (1, 224, 224, 3)

Once your network is created, you can run with regular TensorFlow APIs ๐Ÿ˜Š because all the networks in TensorNets always return tf.Tensor. Using pre-trained weights and pre-processing are as easy as pretrained() and preprocess() to reproduce the original results:

with tf.Session() as sess:
    img = model.preprocess(img)  # equivalent to img = nets.preprocess(model, img)
    sess.run(model.pretrained())  # equivalent to nets.pretrained(model)
    preds = sess.run(model, {inputs: img})

You can see the most probable classes:

print(nets.utils.decode_predictions(preds, top=2)[0])
[(u'n02124075', u'Egyptian_cat', 0.28067636), (u'n02127052', u'lynx', 0.16826575)]

You can also easily obtain values of intermediate layers with middles() and outputs():

with tf.Session() as sess:
    img = model.preprocess(img)
    sess.run(model.pretrained())
    middles = sess.run(model.middles(), {inputs: img})
    outputs = sess.run(model.outputs(), {inputs: img})

model.print_middles()
assert middles[0].shape == (1, 56, 56, 256)
assert middles[-1].shape == (1, 7, 7, 2048)

model.print_outputs()
assert sum(sum((outputs[-1] - preds) ** 2)) < 1e-8

With load() and save(), your weight values can be restorable:

with tf.Session() as sess:
    model.init()
    # ... your training ...
    model.save('test.npz')

with tf.Session() as sess:
    model.load('test.npz')
    # ... your deployment ...

TensorNets enables us to deploy well-known architectures and benchmark those results faster โšก๏ธ. For more information, you can check out the lists of utilities, examples, and architectures.

Object detection example

Each object detection model can be coupled with any network in TensorNets (see performance) and takes two arguments: a placeholder and a function acting as a stem layer. Here is an example of YOLOv2 for PASCAL VOC:

import tensorflow as tf
import tensornets as nets

inputs = tf.placeholder(tf.float32, [None, 416, 416, 3])
model = nets.YOLOv2(inputs, nets.Darknet19)

img = nets.utils.load_img('cat.png')

with tf.Session() as sess:
    sess.run(model.pretrained())
    preds = sess.run(model, {inputs: model.preprocess(img)})
    boxes = model.get_boxes(preds, img.shape[1:3])

Like other models, a detection model also returns tf.Tensor as its output. You can see the bounding box predictions (x1, y1, x2, y2, score) by using model.get_boxes(model_output, original_img_shape) and visualize the results:

from tensornets.datasets import voc
print("%s: %s" % (voc.classnames[7], boxes[7][0]))  # 7 is cat

import numpy as np
import matplotlib.pyplot as plt
box = boxes[7][0]
plt.imshow(img[0].astype(np.uint8))
plt.gca().add_patch(plt.Rectangle(
    (box[0], box[1]), box[2] - box[0], box[3] - box[1],
    fill=False, edgecolor='r', linewidth=2))
plt.show()

More detection examples such as FasterRCNN on VOC2007 are here ๐Ÿ˜Ž. Note that:

  • APIs of detection models are slightly different:

    • YOLOv3: sess.run(model.preds, {inputs: img}),
    • YOLOv2: sess.run(model, {inputs: img}),
    • FasterRCNN: sess.run(model, {inputs: img, model.scales: scale}),
  • FasterRCNN requires roi_pooling:

    • git clone https://github.com/deepsense-io/roi-pooling && cd roi-pooling && vi roi_pooling/Makefile and edit according to here,
    • python setup.py install.

Utilities

Besides pretrained() and preprocess(), the output tf.Tensor provides the following useful methods:

  • logits: returns the tf.Tensor logits (the values before the softmax),
  • middles() (=get_middles()): returns a list of all the representative tf.Tensor end-points,
  • outputs() (=get_outputs()): returns a list of all the tf.Tensor end-points,
  • weights() (=get_weights()): returns a list of all the tf.Tensor weight matrices,
  • summary() (=print_summary()): prints the numbers of layers, weight matrices, and parameters,
  • print_middles(): prints all the representative end-points,
  • print_outputs(): prints all the end-points,
  • print_weights(): prints all the weight matrices.
Example outputs of print methods are:
>>> model.print_middles()
Scope: resnet50
conv2/block1/out:0 (?, 56, 56, 256)
conv2/block2/out:0 (?, 56, 56, 256)
conv2/block3/out:0 (?, 56, 56, 256)
conv3/block1/out:0 (?, 28, 28, 512)
conv3/block2/out:0 (?, 28, 28, 512)
conv3/block3/out:0 (?, 28, 28, 512)
conv3/block4/out:0 (?, 28, 28, 512)
conv4/block1/out:0 (?, 14, 14, 1024)
...

>>> model.print_outputs()
Scope: resnet50
conv1/pad:0 (?, 230, 230, 3)
conv1/conv/BiasAdd:0 (?, 112, 112, 64)
conv1/bn/batchnorm/add_1:0 (?, 112, 112, 64)
conv1/relu:0 (?, 112, 112, 64)
pool1/pad:0 (?, 114, 114, 64)
pool1/MaxPool:0 (?, 56, 56, 64)
conv2/block1/0/conv/BiasAdd:0 (?, 56, 56, 256)
conv2/block1/0/bn/batchnorm/add_1:0 (?, 56, 56, 256)
conv2/block1/1/conv/BiasAdd:0 (?, 56, 56, 64)
conv2/block1/1/bn/batchnorm/add_1:0 (?, 56, 56, 64)
conv2/block1/1/relu:0 (?, 56, 56, 64)
...

>>> model.print_weights()
Scope: resnet50
conv1/conv/weights:0 (7, 7, 3, 64)
conv1/conv/biases:0 (64,)
conv1/bn/beta:0 (64,)
conv1/bn/gamma:0 (64,)
conv1/bn/moving_mean:0 (64,)
conv1/bn/moving_variance:0 (64,)
conv2/block1/0/conv/weights:0 (1, 1, 64, 256)
conv2/block1/0/conv/biases:0 (256,)
conv2/block1/0/bn/beta:0 (256,)
conv2/block1/0/bn/gamma:0 (256,)
...

>>> model.summary()
Scope: resnet50
Total layers: 54
Total weights: 320
Total parameters: 25,636,712

Examples

  • Comparison of different networks:
inputs = tf.placeholder(tf.float32, [None, 224, 224, 3])
models = [
    nets.MobileNet75(inputs),
    nets.MobileNet100(inputs),
    nets.SqueezeNet(inputs),
]

img = utils.load_img('cat.png', target_size=256, crop_size=224)
imgs = nets.preprocess(models, img)

with tf.Session() as sess:
    nets.pretrained(models)
    for (model, img) in zip(models, imgs):
        preds = sess.run(model, {inputs: img})
        print(utils.decode_predictions(preds, top=2)[0])
  • Transfer learning:
inputs = tf.placeholder(tf.float32, [None, 224, 224, 3])
outputs = tf.placeholder(tf.float32, [None, 50])
model = nets.DenseNet169(inputs, is_training=True, classes=50)

loss = tf.losses.softmax_cross_entropy(outputs, model.logits)
train = tf.train.AdamOptimizer(learning_rate=1e-5).minimize(loss)

with tf.Session() as sess:
    nets.pretrained(model)
    for (x, y) in your_NumPy_data:  # the NHWC and one-hot format
        sess.run(train, {inputs: x, outputs: y})
  • Using multi-GPU:
inputs = tf.placeholder(tf.float32, [None, 224, 224, 3])
models = []

with tf.device('gpu:0'):
    models.append(nets.ResNeXt50(inputs))

with tf.device('gpu:1'):
    models.append(nets.DenseNet201(inputs))

from tensornets.preprocess import fb_preprocess
img = utils.load_img('cat.png', target_size=256, crop_size=224)
img = fb_preprocess(img)

with tf.Session() as sess:
    nets.pretrained(models)
    preds = sess.run(models, {inputs: img})
    for pred in preds:
        print(utils.decode_predictions(pred, top=2)[0])

Performance

Image classification

  • The top-k accuracies were obtained with TensorNets on ImageNet validation set and may slightly differ from the original ones.
    • Input: input size fed into models
    • Top-1: single center crop, top-1 accuracy
    • Top-5: single center crop, top-5 accuracy
    • MAC: rounded the number of float operations by using tf.profiler
    • Size: rounded the number of parameters (w/ fully-connected layers)
    • Stem: rounded the number of parameters (w/o fully-connected layers)
  • The computation times were measured on NVIDIA Tesla P100 (3584 cores, 16 GB global memory) with cuDNN 6.0 and CUDA 8.0.
    • Speed: milliseconds for inferences of 100 images
  • The summary plot is generated by this script.
Input Top-1 Top-5 MAC Size Stem Speed References
ResNet50 224 74.874 92.018 51.0M 25.6M 23.6M 195.4 [paper] [tf-slim] [torch-fb]
[caffe] [keras]
ResNet101 224 76.420 92.786 88.9M 44.7M 42.7M 311.7 [paper] [tf-slim] [torch-fb]
[caffe]
ResNet152 224 76.604 93.118 120.1M 60.4M 58.4M 439.1 [paper] [tf-slim] [torch-fb]
[caffe]
ResNet50v2 299 75.960 93.034 51.0M 25.6M 23.6M 209.7 [paper] [tf-slim] [torch-fb]
ResNet101v2 299 77.234 93.816 88.9M 44.7M 42.6M 326.2 [paper] [tf-slim] [torch-fb]
ResNet152v2 299 78.032 94.162 120.1M 60.4M 58.3M 455.2 [paper] [tf-slim] [torch-fb]
ResNet200v2 224 78.286 94.152 129.0M 64.9M 62.9M 618.3 [paper] [tf-slim] [torch-fb]
ResNeXt50c32 224 77.740 93.810 49.9M 25.1M 23.0M 267.4 [paper] [torch-fb]
ResNeXt101c32 224 78.730 94.294 88.1M 44.3M 42.3M 427.9 [paper] [torch-fb]
ResNeXt101c64 224 79.494 94.592 0.0M 83.7M 81.6M 877.8 [paper] [torch-fb]
WideResNet50 224 78.018 93.934 137.6M 69.0M 66.9M 358.1 [paper] [torch]
Inception1 224 66.840 87.676 14.0M 7.0M 6.0M 165.1 [paper] [tf-slim] [caffe-zoo]
Inception2 224 74.680 92.156 22.3M 11.2M 10.2M 134.3 [paper] [tf-slim]
Inception3 299 77.946 93.758 47.6M 23.9M 21.8M 314.6 [paper] [tf-slim] [keras]
Inception4 299 80.120 94.978 85.2M 42.7M 41.2M 582.1 [paper] [tf-slim]
InceptionResNet2 299 80.256 95.252 111.5M 55.9M 54.3M 656.8 [paper] [tf-slim]
NASNetAlarge 331 82.498 96.004 186.2M 93.5M 89.5M 2081 [paper] [tf-slim]
NASNetAmobile 224 74.366 91.854 15.3M 7.7M 6.7M 165.8 [paper] [tf-slim]
PNASNetlarge 331 82.634 96.050 171.8M 86.2M 81.9M 1978 [paper] [tf-slim]
VGG16 224 71.268 90.050 276.7M 138.4M 14.7M 348.4 [paper] [keras]
VGG19 224 71.256 89.988 287.3M 143.7M 20.0M 399.8 [paper] [keras]
DenseNet121 224 74.972 92.258 15.8M 8.1M 7.0M 202.9 [paper] [torch]
DenseNet169 224 76.176 93.176 28.0M 14.3M 12.6M 219.1 [paper] [torch]
DenseNet201 224 77.320 93.620 39.6M 20.2M 18.3M 272.0 [paper] [torch]
MobileNet25 224 51.582 75.792 0.9M 0.5M 0.2M 34.46 [paper] [tf-slim]
MobileNet50 224 64.292 85.624 2.6M 1.3M 0.8M 52.46 [paper] [tf-slim]
MobileNet75 224 68.412 88.242 5.1M 2.6M 1.8M 70.11 [paper] [tf-slim]
MobileNet100 224 70.424 89.504 8.4M 4.3M 3.2M 83.41 [paper] [tf-slim]
MobileNet35v2 224 60.086 82.432 3.3M 1.7M 0.4M 57.04 [paper] [tf-slim]
MobileNet50v2 224 65.194 86.062 3.9M 2.0M 0.7M 64.35 [paper] [tf-slim]
MobileNet75v2 224 69.532 89.176 5.2M 2.7M 1.4M 88.68 [paper] [tf-slim]
MobileNet100v2 224 71.336 90.142 6.9M 3.5M 2.3M 93.82 [paper] [tf-slim]
MobileNet130v2 224 74.680 92.122 10.7M 5.4M 3.8M 130.4 [paper] [tf-slim]
MobileNet140v2 224 75.230 92.422 12.1M 6.2M 4.4M 132.9 [paper] [tf-slim]
75v3large 224 73.754 91.618 7.9M 4.0M 2.7M 79.73 [paper] [tf-slim]
100v3large 224 75.790 92.840 27.3M 5.5M 4.2M 94.71 [paper] [tf-slim]
100v3largemini 224 72.706 90.930 7.8M 3.9M 2.7M 70.57 [paper] [tf-slim]
75v3small 224 66.138 86.534 4.1M 2.1M 1.0M 37.78 [paper] [tf-slim]
100v3small 224 68.318 87.942 5.1M 2.6M 1.5M 42.00 [paper] [tf-slim]
100v3smallmini 224 63.440 84.646 4.1M 2.1M 1.0M 29.65 [paper] [tf-slim]
EfficientNetB0 224 77.012 93.338 26.2M 5.3M 4.0M 147.1 [paper] [tf-tpu]
EfficientNetB1 240 79.040 94.284 15.4M 7.9M 6.6M 217.3 [paper] [tf-tpu]
EfficientNetB2 260 80.064 94.862 18.1M 9.2M 7.8M 296.4 [paper] [tf-tpu]
EfficientNetB3 300 81.384 95.586 24.2M 12.3M 10.8M 482.7 [paper] [tf-tpu]
EfficientNetB4 380 82.588 96.094 38.4M 19.5M 17.7M 959.5 [paper] [tf-tpu]
EfficientNetB5 456 83.496 96.590 60.4M 30.6M 28.5M 1872 [paper] [tf-tpu]
EfficientNetB6 528 83.772 96.762 85.5M 43.3M 41.0M 3503 [paper] [tf-tpu]
EfficientNetB7 600 84.088 96.740 131.9M 66.7M 64.1M 6149 [paper] [tf-tpu]
SqueezeNet 224 54.434 78.040 2.5M 1.2M 0.7M 71.43 [paper] [caffe]

summary

Object detection

  • The object detection models can be coupled with any network but mAPs could be measured only for the models with pre-trained weights. Note that:
    • YOLOv3VOC was trained by taehoonlee with this recipe modified as max_batches=70000, steps=40000,60000,
    • YOLOv2VOC is equivalent to YOLOv2(inputs, Darknet19),
    • TinyYOLOv2VOC: TinyYOLOv2(inputs, TinyDarknet19),
    • FasterRCNN_ZF_VOC: FasterRCNN(inputs, ZF),
    • FasterRCNN_VGG16_VOC: FasterRCNN(inputs, VGG16, stem_out='conv5/3').
  • The mAPs were obtained with TensorNets and may slightly differ from the original ones. The test input sizes were the numbers reported as the best in the papers:
    • YOLOv3, YOLOv2: 416x416
    • FasterRCNN: min_shorter_side=600, max_longer_side=1000
  • The computation times were measured on NVIDIA Tesla P100 (3584 cores, 16 GB global memory) with cuDNN 6.0 and CUDA 8.0.
    • Size: rounded the number of parameters
    • Speed: milliseconds only for network inferences of a 416x416 or 608x608 single image
    • FPS: 1000 / speed
PASCAL VOC2007 test mAP Size Speed FPS References
YOLOv3VOC (416) 0.7423 62M 24.09 41.51 [paper] [darknet] [darkflow]
YOLOv2VOC (416) 0.7320 51M 14.75 67.80 [paper] [darknet] [darkflow]
TinyYOLOv2VOC (416) 0.5303 16M 6.534 153.0 [paper] [darknet] [darkflow]
FasterRCNN_ZF_VOC 0.4466 59M 241.4 3.325 [paper] [caffe] [roi-pooling]
FasterRCNN_VGG16_VOC 0.6872 137M 300.7 4.143 [paper] [caffe] [roi-pooling]
MS COCO val2014 mAP Size Speed FPS References
YOLOv3COCO (608) 0.6016 62M 60.66 16.49 [paper] [darknet] [darkflow]
YOLOv3COCO (416) 0.6028 62M 40.23 24.85 [paper] [darknet] [darkflow]
YOLOv2COCO (608) 0.5189 51M 45.88 21.80 [paper] [darknet] [darkflow]
YOLOv2COCO (416) 0.4922 51M 21.66 46.17 [paper] [darknet] [darkflow]

News ๐Ÿ“ฐ

  • The six variants of MobileNetv3 are released, 12 Mar 2020.
  • The eight variants of EfficientNet are released, 28 Jan 2020.
  • It is available to use TensorNets on TF 2, 23 Jan 2020.
  • MS COCO utils are released, 9 Jul 2018.
  • PNASNetlarge is released, 12 May 2018.
  • The six variants of MobileNetv2 are released, 5 May 2018.
  • YOLOv3 for COCO and VOC are released, 4 April 2018.
  • Generic object detection models for YOLOv2 and FasterRCNN are released, 26 March 2018.

Future work ๐Ÿ”ฅ

tensornets's People

Contributors

jafetmorales avatar jclee81 avatar nicomunting avatar oliver-pola avatar taehoonlee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tensornets's Issues

README's "A quick example" get error.

"from tensornets import utils
img = utils.load_img('cat.png', target_size=256, crop_size=224)
assert img.shape == (1, 224, 224, 3)"

This script get error.


AttributeError Traceback (most recent call last)
in ()
1 from tensornets import utils
----> 2 img = utils.load_img('cat.png', target_size=256, crop_size=224)
3 assert img.shape == (1, 224, 224, 3)

~/.conda/envs/tensor/lib/python3.6/site-packages/tensornets/utils.py in load_img(path, grayscale, target_size, crop_size, interp)
176 if isinstance(target_size, int):
177 hw_tuple = tuple([x * target_size // min(img.shape[:2])
--> 178 for x in img.shape[1::-1]])
179 else:
180 hw_tuple = (target_size[1], target_size[0])

AttributeError: 'NoneType' object has no attribute 'shape'

Validation loss exploding, potentially due to setting is_training = False

Hi! Thanks a lot for this repo, I think it's very well written and extremely easy to use!

I am training a simple MNIST multi-class classifier using pretrained resnet50. I am using a placeholder 'is_train' to set the 'is_training' argument in the resnet50 model to True (during training) and False (during validation). However, when I set it's value to False during validation, my validation loss is exploding. This is not happening if I set it to True during validation.

Please find the code to replicate this issue below.

import numpy as np
import tensorflow as tf
import tensornets as tfnets
from tensorflow.examples.tutorials.mnist import input_data
np.random.seed(0)

graph = tf.Graph()
with graph.as_default():
    mnist = input_data.read_data_sets("mnist_data/", one_hot=False)

    x = tf.placeholder(tf.float32, [None, 256, 256, 3])
    y = tf.placeholder(tf.int32, [None])
    is_train = tf.placeholder(tf.bool)
    optimizer = tf.train.AdamOptimizer()

    model = tfnets.ResNet50(x, is_training = is_train, classes = 10)
    logits = model.get_outputs()[-2]
    probs = tf.nn.softmax(logits)
    loss = tf.reduce_mean(tf.nn.sparse_softmax_cross_entropy_with_logits(labels = y, logits = logits))
    grads = optimizer.compute_gradients(loss)
    train_op = optimizer.apply_gradients(grads)

    config = tf.ConfigProto()
    config.gpu_options.allow_growth = True
    config.allow_soft_placement = True
    with tf.Session(config=config) as sess:
        sess.run(tf.global_variables_initializer())
        sess.run(model.pretrained())

        print('Training ...')
        batch_size = 32
        for iteration in range(20):
            _x, _y = mnist.train.next_batch(batch_size)
            _x = np.resize(np.stack((np.reshape(_x, (-1, 28, 28)),)*3, axis = -1), (batch_size, 256, 256, 3))
            _, lossval = sess.run([train_op, loss], feed_dict = {x:_x, y:_y, is_train:True})
            print(iteration, lossval)

        print('Validation ...')
        for iteration in range(5):
            _x, _y = mnist.validation.next_batch(batch_size)
            _x = np.resize(np.stack((np.reshape(_x, (-1, 28, 28)),)*3, axis = -1), (batch_size, 256, 256, 3))
            lossval = sess.run(loss, feed_dict = {x:_x, y:_y, is_train:False})
            print(iteration, lossval)

The output I am getting when I set 'is_train' to False while calculating validation loss is as follows:

Training ...
0 2.5664392
1 2.5185232
2 2.6779196
3 2.904881
4 2.5281467
5 2.3716216
6 2.6480408
7 2.4264488
8 2.5613265
9 2.6664178
10 2.407669
11 2.588695
12 2.4091241
13 2.6468048
14 2.6137376
15 2.3654165
16 2.3985069
17 2.302301
18 2.3154862
19 2.643575
Validation ...
0 3006.0938
1 3228.6968
2 3172.6226
3 2331.4446
4 2426.8574

However, when I set 'is_train' to True while calculating validation loss, the output is as follows:

Training ...
0 2.6028776
1 2.4225206
2 2.7544856
3 2.638253
4 2.4008565
5 2.642138
6 2.3750484
7 2.840887
8 2.3587594
9 2.6521862
10 2.450266
11 2.3560605
12 2.3225245
13 2.4954278
14 2.3524
15 2.3139462
16 2.2738576
17 2.4993274
18 2.3943353
19 2.7758856
Validation ...
0 2.2924833
1 2.396636
2 2.4049609
3 2.3891609
4 2.3445334

It would be great if you could let me know what's going wrong here. I am using tensorflow 1.13 and python 3.6. Thanks!

Model load issue 2

Another issue, this time with python2

Python 2.7.13 |Anaconda 4.3.1 (64-bit)| (default, Dec 20 2016, 23:09:15) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import tensorflow as tf
>>> import tensornets as nets
>>> import numpy as np
>>> 
>>> print(tf.__version__)
1.2.1
>>> print(np.__version__)
1.13.1
>>> 
>>> inputs = tf.placeholder(tf.float32, [None, 224, 224, 3])
>>> outputs = tf.placeholder(tf.float32, [None, 50])
>>> model = nets.ResNet152v2(inputs, is_training=True, classes=50)
>>> 
>>> loss = tf.losses.softmax_cross_entropy(outputs, model)
>>> train = tf.train.AdamOptimizer(learning_rate=1e-5).minimize(loss)
>>> 
>>> with tf.Session() as sess:
...     nets.pretrained(model)
... 
2017-11-15 21:42:48.330744: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-11-15 21:42:48.330814: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-11-15 21:42:48.330941: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-11-15 21:42:48.595931: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:893] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2017-11-15 21:42:48.596442: I tensorflow/core/common_runtime/gpu/gpu_device.cc:940] Found device 0 with properties: 
name: GeForce GTX 1080 Ti
major: 6 minor: 1 memoryClockRate (GHz) 1.582
pciBusID 0000:01:00.0
Total memory: 10.91GiB
Free memory: 9.73GiB
2017-11-15 21:42:48.741859: W tensorflow/stream_executor/cuda/cuda_driver.cc:523] A non-primary context 0x121ad770 exists before initializing the StreamExecutor. We haven't verified StreamExecutor works with that.
2017-11-15 21:42:48.742280: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:893] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2017-11-15 21:42:48.742780: I tensorflow/core/common_runtime/gpu/gpu_device.cc:940] Found device 1 with properties: 
name: GeForce GTX 1080 Ti
major: 6 minor: 1 memoryClockRate (GHz) 1.582
pciBusID 0000:02:00.0
Total memory: 10.91GiB
Free memory: 10.75GiB
2017-11-15 21:42:48.743591: I tensorflow/core/common_runtime/gpu/gpu_device.cc:961] DMA: 0 1 
2017-11-15 21:42:48.743609: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 0:   Y Y 
2017-11-15 21:42:48.743619: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 1:   Y Y 
2017-11-15 21:42:48.743699: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:01:00.0)
2017-11-15 21:42:48.743713: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Creating TensorFlow device (/gpu:1) -> (device: 1, name: GeForce GTX 1080 Ti, pci bus id: 0000:02:00.0)
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/shared/miha/py_homebrew/tensornets/pretrained.py", line 49, in pretrained
    __load_dict__[model_name](scope)
  File "/shared/miha/py_homebrew/tensornets/pretrained.py", line 171, in load_resnet152v2
    return load_weights(scopes, weights_path)
  File "/shared/miha/py_homebrew/tensornets/utils.py", line 175, in load_weights
    assert len(weights) == len(values), 'The sizes of symbolic and ' \
AssertionError: The sizes of symbolic and actual weights do not match.
>>> 

Error on loading pre-trained model

I am trying to work on transfer learning using Mobilenet Pretrained model

model = nets.MobileNet35v2(inputs, is_training=True, classes=2)
with tf.Session() as sess:
nets.pretrained(model)

But this gives the following error

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-9-ba2d4690d272> in <module>
      8 
      9 with tf.Session() as sess:
---> 10     nets.pretrained(model)
     11 
     12     for i in range(0,len(epochs)):

~/.conda/envs/tf-gpu/lib/python3.6/site-packages/tensornets/pretrained.py in assign(scopes)
     56         model_name = parse_scopes(scope)[0]
     57         try:
---> 58             __load_dict__[model_name](scope)
     59         except KeyError:
     60             try:

~/.conda/envs/tf-gpu/lib/python3.6/site-packages/tensornets/pretrained.py in load_mobilenet35v2(scopes, return_fn)
    550         file_hash='cf758f7f8024d39365e553ec924bb395')
    551     values = parse_weights(weights_path)
--> 552     return return_fn(scopes, values)
    553 
    554 

~/.conda/envs/tf-gpu/lib/python3.6/site-packages/tensornets/pretrained.py in _assign(scopes, values)
    108 
    109     for scope in scopes:
--> 110         sess.run(pretrained_initializer(scope, values))
    111 
    112 

~/.conda/envs/tf-gpu/lib/python3.6/site-packages/tensornets/utils.py in pretrained_initializer(scope, values)
    324                       'Never mind if you are trying to load stem layers only.')
    325 
--> 326     if scope.dtype == tf.float16:
    327         ops = [weights[0].assign(np.asarray(values[0], dtype=np.float16))]
    328         for (w, v) in zip(weights[1:-2], values[1:-2]):

AttributeError: 'str' object has no attribute 'dtype'

Can't install the tensornets on Mint

Hi, I try to install the tensornets on Mint os by pip install tensornets
Here is the ERROR:
`Installing collected packages: tensornets
Running setup.py install for tensornets ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-install-e0ktv6qy/tensornets/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-record-uv6ejby6/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.5
creating build/lib.linux-x86_64-3.5/tensornets
copying tensornets/zf.py -> build/lib.linux-x86_64-3.5/tensornets
copying tensornets/utils.py -> build/lib.linux-x86_64-3.5/tensornets
copying tensornets/init.py -> build/lib.linux-x86_64-3.5/tensornets
copying tensornets/layers.py -> build/lib.linux-x86_64-3.5/tensornets
copying tensornets/middles.py -> build/lib.linux-x86_64-3.5/tensornets
copying tensornets/inceptions.py -> build/lib.linux-x86_64-3.5/tensornets
copying tensornets/mobilenets.py -> build/lib.linux-x86_64-3.5/tensornets
copying tensornets/detections.py -> build/lib.linux-x86_64-3.5/tensornets
copying tensornets/resnets.py -> build/lib.linux-x86_64-3.5/tensornets
copying tensornets/darknets.py -> build/lib.linux-x86_64-3.5/tensornets
copying tensornets/vggs.py -> build/lib.linux-x86_64-3.5/tensornets
copying tensornets/capsulenets.py -> build/lib.linux-x86_64-3.5/tensornets
copying tensornets/nasnets.py -> build/lib.linux-x86_64-3.5/tensornets
copying tensornets/densenets.py -> build/lib.linux-x86_64-3.5/tensornets
copying tensornets/pretrained.py -> build/lib.linux-x86_64-3.5/tensornets
copying tensornets/squeezenets.py -> build/lib.linux-x86_64-3.5/tensornets
copying tensornets/preprocess.py -> build/lib.linux-x86_64-3.5/tensornets
copying tensornets/ops.py -> build/lib.linux-x86_64-3.5/tensornets
creating build/lib.linux-x86_64-3.5/tensornets/datasets
copying tensornets/datasets/init.py -> build/lib.linux-x86_64-3.5/tensornets/datasets
copying tensornets/datasets/imagenet.py -> build/lib.linux-x86_64-3.5/tensornets/datasets
copying tensornets/datasets/voc.py -> build/lib.linux-x86_64-3.5/tensornets/datasets
creating build/lib.linux-x86_64-3.5/tensornets/references
copying tensornets/references/init.py -> build/lib.linux-x86_64-3.5/tensornets/references
copying tensornets/references/rpn_utils.py -> build/lib.linux-x86_64-3.5/tensornets/references
copying tensornets/references/yolo_utils.py -> build/lib.linux-x86_64-3.5/tensornets/references
copying tensornets/references/rcnns.py -> build/lib.linux-x86_64-3.5/tensornets/references
copying tensornets/references/yolos.py -> build/lib.linux-x86_64-3.5/tensornets/references
creating build/lib.linux-x86_64-3.5/tensornets/references/darkflow_utils
copying tensornets/references/darkflow_utils/init.py -> build/lib.linux-x86_64-3.5/tensornets/references/darkflow_utils
copying tensornets/references/darkflow_utils/box.py -> build/lib.linux-x86_64-3.5/tensornets/references/darkflow_utils
running egg_info
writing top-level names to tensornets.egg-info/top_level.txt
writing dependency_links to tensornets.egg-info/dependency_links.txt
writing tensornets.egg-info/PKG-INFO
reading manifest file 'tensornets.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'tensornets.egg-info/SOURCES.txt'
copying tensornets/datasets/voc.names -> build/lib.linux-x86_64-3.5/tensornets/datasets
copying tensornets/references/coco.names -> build/lib.linux-x86_64-3.5/tensornets/references
copying tensornets/references/voc.names -> build/lib.linux-x86_64-3.5/tensornets/references
copying tensornets/references/darkflow_utils/init.pyc -> build/lib.linux-x86_64-3.5/tensornets/references/darkflow_utils
copying tensornets/references/darkflow_utils/box.pyc -> build/lib.linux-x86_64-3.5/tensornets/references/darkflow_utils
copying tensornets/references/darkflow_utils/get_boxes.c -> build/lib.linux-x86_64-3.5/tensornets/references/darkflow_utils
copying tensornets/references/darkflow_utils/get_boxes.pyx -> build/lib.linux-x86_64-3.5/tensornets/references/darkflow_utils
copying tensornets/references/darkflow_utils/get_boxes.so -> build/lib.linux-x86_64-3.5/tensornets/references/darkflow_utils
copying tensornets/references/darkflow_utils/nms.c -> build/lib.linux-x86_64-3.5/tensornets/references/darkflow_utils
copying tensornets/references/darkflow_utils/nms.pxd -> build/lib.linux-x86_64-3.5/tensornets/references/darkflow_utils
copying tensornets/references/darkflow_utils/nms.pyx -> build/lib.linux-x86_64-3.5/tensornets/references/darkflow_utils
copying tensornets/references/darkflow_utils/nms.so -> build/lib.linux-x86_64-3.5/tensornets/references/darkflow_utils
running build_ext
building 'tensornets.references.darkflow_utils.nms' extension
creating build/temp.linux-x86_64-3.5
creating build/temp.linux-x86_64-3.5/tensornets
creating build/temp.linux-x86_64-3.5/tensornets/references
creating build/temp.linux-x86_64-3.5/tensornets/references/darkflow_utils
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/local/lib/python3.5/dist-packages/numpy/core/include -I/usr/include/python3.5m -c tensornets/references/darkflow_utils/nms.c -o build/temp.linux-x86_64-3.5/tensornets/references/darkflow_utils/nms.o
tensornets/references/darkflow_utils/nms.c:26:20: fatal error: Python.h: ๆฒกๆœ‰้‚ฃไธชๆ–‡ไปถๆˆ–็›ฎๅฝ•
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------

Command "/usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-install-e0ktv6qy/tensornets/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-record-uv6ejby6/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-e0ktv6qy/tensornets/
I have installedtensorflow-gpu==1.8.0`

Notes for logits and softmax_cross_entropy

All the models in TensorNets return a softmax tf.Tensor, while the models in tensorflow/models (also backbone of tensorflow/hub) do a logits tf.Tensor (the values before softmax). That is because most regular TensorFlow loss APIs take a logits as an argument. In results,

  • Incorrect: tf.losses.softmax_cross_entropy(onehot_labels=outputs, logits=model),
  • Correct: tf.nn.softmax_cross_entropy_with_logits_v2(labels=outputs, logits=model.logits),
  • Correct and recommended: tf.losses.softmax_cross_entropy(onehot_labels=outputs, logits=model.logits),

where model is any model function in TensorNets (e.g., model = nets.MobileNet50(inputs)) and model.logits is equivalent to model.get_outputs()[-2].

The following is a comparison of the three losses mentioned above and TL; DR.

import numpy as np
import tensorflow as tf
import tensornets as nets

# Define a model
inputs = tf.placeholder(tf.float32, [None, 224, 224, 3])
outputs = tf.placeholder(tf.float32, [None, 1000])
model = nets.MobileNet50(inputs)
# `model.logits`: available since TensorNets 0.4.1
logits = model.logits  #  alternatively: `model.get_outputs()[-2]`

# `model`: the values after softmax
assert 'probs' in model.name
# `logits`: the values before softmax
assert 'logits' in logits.name

# Load feeds
img = nets.utils.load_img('cat.png', target_size=256, crop_size=224)
label = np.zeros((1, 1000)).astype(np.float32)
label[0, 588] = 1.

# Initialize the model
sess = tf.Session()
sess.run(model.pretrained())

# Get results
# 1. invalid usage: `softmax_cross_entropy`
#    with predicted softmax values
invalid = tf.losses.softmax_cross_entropy(
    onehot_labels=outputs, logits=model)
# 2. valid usage: `softmax_cross_entropy_with_logits_v2`
#    with predicted logits values
valid1 = tf.reduce_sum(
    tf.nn.softmax_cross_entropy_with_logits_v2(
        labels=outputs, logits=logits))
# 3. (recommended) valid usage: `softmax_cross_entropy`
#    with predicted logits values
valid2 = tf.losses.softmax_cross_entropy(
    onehot_labels=outputs, logits=logits)

preds, invalid, valid1, valid2 = sess.run(
    [model, invalid, valid1, valid2],
    {inputs: model.preprocess(img),
     outputs: label})

sess.close()

# Check the results with desired outputs
# cross entropy loss: -\sum_i p_i \log{\hat{p_i}}
desired = -np.sum(label * np.log(preds))
np.testing.assert_allclose(valid1, desired)
np.testing.assert_allclose(valid2, desired)
try:
    np.testing.assert_allclose(invalid, desired)
except AssertionError as e:
    print(e)

State of TensorRT / XLA support?

Does anyone know if these pre-trained models can be converted to TensorRT engine executables? Or JIT'd by XLA for NVIDIA GPUs?

Extreme memory usage and bug with FP16 and darkflow_utils

When using YOLOv2 COCO or VOC on tensornets (TF 1.7, CPU, Win 10) the memory usage with the input as tf.float32 is massive (3GB +) which is more than twice what darkflow uses for the same model. Not quite sure why.

When trying to use tf.float16 with YOLOv2, memory usage is significantly reduced (could be due to a bug that so little memory is used actually...), but there seems to be a problem with the Cython utils ported from darkflow handling the FP16 output data.

I get the following error:

Traceback (most recent call last):
File "blah\src\test.py", line 15, in
boxes = model.get_boxes(preds, img.shape[1:3])
File "C:\Users\abags\AppData\Local\Programs\Python\Python36\lib\site-packages\tensornets\references\yolos.py", line 189, in _get_boxes
return get_v2_boxes(opts('yolov2'), *args, **kwargs)
File "C:\Users\abags\AppData\Local\Programs\Python\Python36\lib\site-packages\tensornets\references\yolo_utils.py", line 94, in get_v2_boxes
results = yolov2_box(opts, outs[0].copy())
File "tensornets\references\darkflow_utils\get_boxes.pyx", line 108, in tensornets.references.darkflow_utils.get_boxes.yolov2_box
ValueError: Does not understand character buffer dtype format string ('e')

Access representative endpoints

Currently, there are only get_outputs() which returns all the endpoints (too verbose). However, in practice, many users want to access representative endpoints only (e.g., conv5b in GoogLeNet).

import tensorflow as tf
import tensornets as nets
inputs = tf.placeholder(tf.float32, [None, 224, 224, 3])
model = nets.ResNet50(inputs)
model.get_outputs()  # returns a list of length 161

The new API requests are:

model.get_feature()  # returns the bottleneck feature
model.get_features()  # returns a list of some endpoints

YOLOv3 odd detection behaviour vs YOLOv2

Here's the same image put through YOLOv2COCO and then YOLOv3COCO respectively (threshold set at 0.4 and input resolution at 416x416 for both):

YOLOv2
YOLOv3

YOLOv3 does pick up the smaller people (as one would expect) - but for some reason it seems to predicting a much smaller bounding box than it should. I've done some experimenting and similar behavior is exhibited on quite a few images (sometimes the proper box appears and a smaller, inner one also appears - in this case, though, only the smaller one is appearing).

It's possible that this is just due to a poor prediction on the model's part, but my guess is that it isn't and due to some problem with the NMS function (almost as if it's doing non-minimal-suppression...if that's a thing ๐Ÿ˜„ ) or other post processing step.

Unable to pip install tensornets on production

For some reason, tensornets fails to install when doing pip install -r requirements.txt on production.

Step #1 - "builder": ModuleNotFoundError: No module named 'numpy'
Step #1 - "builder": import numpy
Step #1 - "builder": File "/env/src/tensornets/setup.py", line 1, in <module>
Step #1 - "builder": File "<string>", line 1, in <module>
Step #1 - "builder": Traceback (most recent call last):
Step #1 - "builder": Complete output from command python setup.py egg_info:
Step #1 - "builder": Cloning https://github.com/taehoonlee/tensornets.git to /env/src/tensornets
Step #1 - "builder": Obtaining tensornets from git+https://github.com/taehoonlee/tensornets.git#egg=tensornets (from -r requirements.txt (line 12))
Step #1 - "builder": Saved /tmp/tmpkyWvcV/wheel/tensorflow-1.15.0rc2-cp37-cp37m-manylinux2010_x86_64.whl
Step #1 - "builder": Downloading https://files.pythonhosted.org/packages/0a/a9/a5ffe715d3475fed0a79be8e13ef638abbd1c013fdbe8f43892f06336b82/tensorflow-1.15.0rc2-cp37-cp37m-manylinux2010_x86_64.whl (412.3MB)
Step #1 - "builder": Collecting tensorflow==1.15.0rc2 (from -r requirements.txt (line 11))
Step #1 - "builder": Saved /tmp/tmpkyWvcV/wheel/Pillow-6.2.0-cp37-cp37m-manylinux1_x86_64.whl
Step #1 - "builder": Downloading https://files.pythonhosted.org/packages/34/b7/fb24ad352b747340ec1975c84c30cca37bb93a0079e037d1f0930afd65ad/Pillow-6.2.0-cp37-cp37m-manylinux1_x86_64.whl (2.1MB)
Step #1 - "builder": Collecting Pillow==6.2.0 (from -r requirements.txt (line 10))
Step #1 - "builder": Saved /tmp/tmpkyWvcV/wheel/numpy-1.17.3-cp37-cp37m-manylinux1_x86_64.whl
Step #1 - "builder": Downloading https://files.pythonhosted.org/packages/00/4a/e34fce8f18c0e052c2b49f1b3713469d855f7662d58ae2b82a88341e865b/numpy-1.17.3-cp37-cp37m-manylinux1_x86_64.whl (20.0MB)
Step #1 - "builder": Collecting numpy==1.17.3 (from -r requirements.txt (line 9))
Step #1 - "builder": Saved /tmp/tmpkyWvcV/wheel/Cython-0.29.13-cp37-cp37m-manylinux1_x86_64.whl
Step #1 - "builder": Downloading https://files.pythonhosted.org/packages/f1/d3/03a01bcf424eb86d3e9d818e2082ced2d512001af89183fca6f550c32bc2/Cython-0.29.13-cp37-cp37m-manylinux1_x86_64.whl (2.1MB)
Step #1 - "builder": Collecting Cython==0.29.13 (from -r requirements.txt (line 8))
Step #1 - "builder": Downloading https://files.pythonhosted.org/packages/5c/1c/6997288da181277a0c29bc39a5f9143ff20b8c99f2a7d059cfb55163e165/psycopg2-2.8.3.tar.gz (377kB)
Step #1 - "builder": Collecting psycopg2==2.8.3 (from -r requirements.txt (line 5))
Step #1 - "builder": Saved /tmp/tmpkyWvcV/wheel/django_extensions-2.2.3-py2.py3-none-any.whl
Step #1 - "builder": Downloading https://files.pythonhosted.org/packages/43/42/d2aa7c39739b81b949aa0c2e8aab62f8b0b1ea034aac862b54ef7063b49c/django_extensions-2.2.3-py2.py3-none-any.whl (223kB)
Step #1 - "builder": Collecting django-extensions==2.2.3 (from -r requirements.txt (line 4))
Step #1 - "builder": Saved /tmp/tmpkyWvcV/wheel/django_environ-0.4.5-py2.py3-none-any.whl
Step #1 - "builder": Downloading https://files.pythonhosted.org/packages/9f/32/76295a1a5d00bf556c495216581c6997e7fa5f533b2229e0a9d6cbaa95ae/django_environ-0.4.5-py2.py3-none-any.whl
Step #1 - "builder": Collecting django-environ==0.4.5 (from -r requirements.txt (line 3))
Step #1 - "builder": Saved /tmp/tmpkyWvcV/wheel/Django-2.2.6-py3-none-any.whl
Step #1 - "builder": Downloading https://files.pythonhosted.org/packages/b2/79/df0ffea7bf1e02c073c2633702c90f4384645c40a1dd09a308e02ef0c817/Django-2.2.6-py3-none-any.whl (7.5MB)
Step #1 - "builder": Collecting Django==2.2.6 (from -r requirements.txt (line 2))
Step #1 - "builder": INFO `pip_download_wheels` stdout:
Step #1 - "builder": INFO pip_download_wheels /env/bin/python3.7 -m pip wheel -w /tmp/tmpkyWvcV/wheel -r requirements.txt --disable-pip-version-check
Step #1 - "builder": INFO starting: pip_download_wheels
Step #1 - "builder": INFO pip_install_wheel took 0 seconds
Step #1 - "builder":
Step #1 - "builder": You should consider upgrading via the 'pip install --upgrade pip' command.
Step #1 - "builder": You are using pip version 19.0.3, however version 19.3.1 is available.
Step #1 - "builder": INFO `pip_install_wheel` had stderr output:
Step #1 - "builder":
Step #1 - "builder": Successfully installed wheel-0.33.6
Step #1 - "builder": Installing collected packages: wheel
Step #1 - "builder": Downloading https://files.pythonhosted.org/packages/00/83/b4a77d044e78ad1a45610eb88f745be2fd2c6d658f9798a15e384b7d57c9/wheel-0.33.6-py2.py3-none-any.whl
Step #1 - "builder": Collecting wheel
Step #1 - "builder": INFO `pip_install_wheel` stdout:
Step #1 - "builder": INFO pip_install_wheel pip install wheel
Step #1 - "builder": INFO starting: pip_install_wheel
Step #1 - "builder":

For some reason, tensorflow is not able to find numpy. I have tried installing using the distribution package before installing tensorflow, but the same happened. Any idea?

loading multiple image at the same time

to process multiple image in one shot i did like this

listim=[
'c:/graph/1.jpg','c:/graph/2.jpg','c:/graph/3.jpg'
]

img = utils.load_img(listim, target_size=256, crop_size=224)
imgs = nets.preprocess(models, img)

got TypeError: bad argument type for built-in operation on the utils.load_img(

how to proceed if multiple image to detect?
i was trying the network comparison and so i thought it could be possible to load multiple image as it is possible to load multiple networks in the for (model, img) in zip(models, imgs):

How to download the pretrained weights?

I wanna test yolo2 or yolov3 combined with mobilenetv2, as following codes, how to download the models?

import tensorflow as tf
import tensornets as nets

inputs = tf.placeholder(tf.float32, [None, 416, 416, 3])
model = nets.YOLOv2(inputs, nets.mobilenets.MobileNet75v2)

img = nets.utils.load_img('cat.jpg')

with tf.Session() as sess:
    sess.run(model.pretrained())

    preds = sess.run(model, {inputs: model.preprocess(img)})
    boxes = model.get_boxes(preds, img.shape[1:3])

    print(boxes)

Error When pip

When I installed TensorNets from PyPI (pip install tensornets) , what happened as:
Building wheels for collected packages: tensornets
Running setup.py bdist_wheel for tensornets ... error
Complete output from command e:\python\anaconda_setup\python.exe -u -c "import setuptools, tokenize;file='C:\Users\hp\AppData\Local\Temp\pip-install-u8ygwt_s\tensornets\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" bdist_wheel -d C:\Users\hp\AppData\Local\Temp\pip-wheel-9cd_yi__ --python-tag cp36:
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
creating build\lib.win-amd64-3.6\tensornets
copying tensornets\capsulenets.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\darknets.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\densenets.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\detections.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\inceptions.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\layers.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\middles.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\mobilenets.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\nasnets.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\ops.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\preprocess.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\pretrained.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\resnets.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\squeezenets.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\unet.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\utils.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\vggs.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\wavenets.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\zf.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets_init_.py -> build\lib.win-amd64-3.6\tensornets
creating build\lib.win-amd64-3.6\tensornets\datasets
copying tensornets\datasets\coco.py -> build\lib.win-amd64-3.6\tensornets\datasets
copying tensornets\datasets\imagenet.py -> build\lib.win-amd64-3.6\tensornets\datasets
copying tensornets\datasets\voc.py -> build\lib.win-amd64-3.6\tensornets\datasets
copying tensornets\datasets_init_.py -> build\lib.win-amd64-3.6\tensornets\datasets
creating build\lib.win-amd64-3.6\tensornets\references
copying tensornets\references\rcnns.py -> build\lib.win-amd64-3.6\tensornets\references
copying tensornets\references\rpn_utils.py -> build\lib.win-amd64-3.6\tensornets\references
copying tensornets\references\yolos.py -> build\lib.win-amd64-3.6\tensornets\references
copying tensornets\references\yolo_utils.py -> build\lib.win-amd64-3.6\tensornets\references
copying tensornets\references_init_.py -> build\lib.win-amd64-3.6\tensornets\references
creating build\lib.win-amd64-3.6\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils\box.py -> build\lib.win-amd64-3.6\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils_init_.py -> build\lib.win-amd64-3.6\tensornets\references\darkflow_utils
running egg_info
writing tensornets.egg-info\PKG-INFO
writing dependency_links to tensornets.egg-info\dependency_links.txt
writing top-level names to tensornets.egg-info\top_level.txt
reading manifest file 'tensornets.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'tensornets.egg-info\SOURCES.txt'
copying tensornets\references\darkflow_utils\get_boxes.c -> build\lib.win-amd64-3.6\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils\nms.c -> build\lib.win-amd64-3.6\tensornets\references\darkflow_utils
copying tensornets\datasets\coco.names -> build\lib.win-amd64-3.6\tensornets\datasets
copying tensornets\datasets\voc.names -> build\lib.win-amd64-3.6\tensornets\datasets
copying tensornets\references\coco.names -> build\lib.win-amd64-3.6\tensornets\references
copying tensornets\references\voc.names -> build\lib.win-amd64-3.6\tensornets\references
copying tensornets\references\darkflow_utils_init_.pyc -> build\lib.win-amd64-3.6\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils\box.pyc -> build\lib.win-amd64-3.6\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils\get_boxes.pyx -> build\lib.win-amd64-3.6\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils\get_boxes.so -> build\lib.win-amd64-3.6\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils\nms.pxd -> build\lib.win-amd64-3.6\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils\nms.pyx -> build\lib.win-amd64-3.6\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils\nms.so -> build\lib.win-amd64-3.6\tensornets\references\darkflow_utils
running build_ext
building 'tensornets.references.darkflow_utils.nms' extension
creating build\temp.win-amd64-3.6
creating build\temp.win-amd64-3.6\Release
creating build\temp.win-amd64-3.6\Release\tensornets
creating build\temp.win-amd64-3.6\Release\tensornets\references
creating build\temp.win-amd64-3.6\Release\tensornets\references\darkflow_utils
D:\MSVSC\VC\Tools\MSVC\14.15.26726\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ie:\python\anaconda_setup\lib\site-packages\numpy\core\include -Ie:\python\anaconda_setup\include -Ie:\python\anaconda_setup\include -ID:\MSVSC\VC\Tools\MSVC\14.15.26726\ATLMFC\include -ID:\MSVSC\VC\Tools\MSVC\14.15.26726\include "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\cppwinrt" /Tctensornets/references/darkflow_utils/nms.c /Fobuild\temp.win-amd64-3.6\Release\tensornets/references/darkflow_utils/nms.obj
nms.c
e:\python\anaconda_setup\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(12) : Warning Msg: Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
tensornets/references/darkflow_utils/nms.c(2437): warning C4244: โ€œ=โ€: ไปŽโ€œdoubleโ€่ฝฌๆขๅˆฐโ€œfloatโ€๏ผŒๅฏ่ƒฝไธขๅคฑๆ•ฐๆฎ
tensornets/references/darkflow_utils/nms.c(2446): warning C4244: โ€œ=โ€: ไปŽโ€œdoubleโ€่ฝฌๆขๅˆฐโ€œfloatโ€๏ผŒๅฏ่ƒฝไธขๅคฑๆ•ฐๆฎ
tensornets/references/darkflow_utils/nms.c(2496): warning C4244: โ€œ=โ€: ไปŽโ€œdoubleโ€่ฝฌๆขๅˆฐโ€œfloatโ€๏ผŒๅฏ่ƒฝไธขๅคฑๆ•ฐๆฎ
tensornets/references/darkflow_utils/nms.c(22776): warning C4244: โ€œๅˆๅง‹ๅŒ–โ€: ไปŽโ€œdoubleโ€่ฝฌๆขๅˆฐโ€œfloatโ€๏ผŒๅฏ่ƒฝไธขๅคฑๆ•ฐๆฎ
tensornets/references/darkflow_utils/nms.c(22782): warning C4244: โ€œๅˆๅง‹ๅŒ–โ€: ไปŽโ€œdoubleโ€่ฝฌๆขๅˆฐโ€œfloatโ€๏ผŒๅฏ่ƒฝไธขๅคฑๆ•ฐๆฎ
D:\MSVSC\VC\Tools\MSVC\14.15.26726\bin\HostX86\x64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:e:\python\anaconda_setup\libs /LIBPATH:e:\python\anaconda_setup\PCbuild\amd64 /LIBPATH:D:\MSVSC\VC\Tools\MSVC\14.15.26726\ATLMFC\lib\x64 /LIBPATH:D:\MSVSC\VC\Tools\MSVC\14.15.26726\lib\x64 "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\um\x64" m.lib /EXPORT:PyInit_nms build\temp.win-amd64-3.6\Release\tensornets/references/darkflow_utils/nms.obj /OUT:build\lib.win-amd64-3.6\tensornets\references\darkflow_utils\nms.cp36-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.6\Release\tensornets/references/darkflow_utils\nms.cp36-win_amd64.lib
LINK : fatal error LNK1181: ๆ— ๆณ•ๆ‰“ๅผ€่พ“ๅ…ฅๆ–‡ไปถโ€œm.libโ€
error: command 'D:\MSVSC\VC\Tools\MSVC\14.15.26726\bin\HostX86\x64\link.exe' failed with exit status 1181


Failed building wheel for tensornets
Running setup.py clean for tensornets
Failed to build tensornets
Installing collected packages: tensornets
Running setup.py install for tensornets ... error
Complete output from command e:\python\anaconda_setup\python.exe -u -c "import setuptools, tokenize;file='C:\Users\hp\AppData\Local\Temp\pip-install-u8ygwt_s\tensornets\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\hp\AppData\Local\Temp\pip-record-al4vrtuo\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
creating build\lib.win-amd64-3.6\tensornets
copying tensornets\capsulenets.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\darknets.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\densenets.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\detections.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\inceptions.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\layers.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\middles.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\mobilenets.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\nasnets.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\ops.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\preprocess.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\pretrained.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\resnets.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\squeezenets.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\unet.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\utils.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\vggs.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\wavenets.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets\zf.py -> build\lib.win-amd64-3.6\tensornets
copying tensornets_init_.py -> build\lib.win-amd64-3.6\tensornets
creating build\lib.win-amd64-3.6\tensornets\datasets
copying tensornets\datasets\coco.py -> build\lib.win-amd64-3.6\tensornets\datasets
copying tensornets\datasets\imagenet.py -> build\lib.win-amd64-3.6\tensornets\datasets
copying tensornets\datasets\voc.py -> build\lib.win-amd64-3.6\tensornets\datasets
copying tensornets\datasets_init_.py -> build\lib.win-amd64-3.6\tensornets\datasets
creating build\lib.win-amd64-3.6\tensornets\references
copying tensornets\references\rcnns.py -> build\lib.win-amd64-3.6\tensornets\references
copying tensornets\references\rpn_utils.py -> build\lib.win-amd64-3.6\tensornets\references
copying tensornets\references\yolos.py -> build\lib.win-amd64-3.6\tensornets\references
copying tensornets\references\yolo_utils.py -> build\lib.win-amd64-3.6\tensornets\references
copying tensornets\references_init_.py -> build\lib.win-amd64-3.6\tensornets\references
creating build\lib.win-amd64-3.6\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils\box.py -> build\lib.win-amd64-3.6\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils_init_.py -> build\lib.win-amd64-3.6\tensornets\references\darkflow_utils
running egg_info
writing tensornets.egg-info\PKG-INFO
writing dependency_links to tensornets.egg-info\dependency_links.txt
writing top-level names to tensornets.egg-info\top_level.txt
reading manifest file 'tensornets.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'tensornets.egg-info\SOURCES.txt'
copying tensornets\references\darkflow_utils\get_boxes.c -> build\lib.win-amd64-3.6\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils\nms.c -> build\lib.win-amd64-3.6\tensornets\references\darkflow_utils
copying tensornets\datasets\coco.names -> build\lib.win-amd64-3.6\tensornets\datasets
copying tensornets\datasets\voc.names -> build\lib.win-amd64-3.6\tensornets\datasets
copying tensornets\references\coco.names -> build\lib.win-amd64-3.6\tensornets\references
copying tensornets\references\voc.names -> build\lib.win-amd64-3.6\tensornets\references
copying tensornets\references\darkflow_utils_init_.pyc -> build\lib.win-amd64-3.6\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils\box.pyc -> build\lib.win-amd64-3.6\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils\get_boxes.pyx -> build\lib.win-amd64-3.6\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils\get_boxes.so -> build\lib.win-amd64-3.6\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils\nms.pxd -> build\lib.win-amd64-3.6\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils\nms.pyx -> build\lib.win-amd64-3.6\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils\nms.so -> build\lib.win-amd64-3.6\tensornets\references\darkflow_utils
running build_ext
building 'tensornets.references.darkflow_utils.nms' extension
creating build\temp.win-amd64-3.6
creating build\temp.win-amd64-3.6\Release
creating build\temp.win-amd64-3.6\Release\tensornets
creating build\temp.win-amd64-3.6\Release\tensornets\references
creating build\temp.win-amd64-3.6\Release\tensornets\references\darkflow_utils
D:\MSVSC\VC\Tools\MSVC\14.15.26726\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ie:\python\anaconda_setup\lib\site-packages\numpy\core\include -Ie:\python\anaconda_setup\include -Ie:\python\anaconda_setup\include -ID:\MSVSC\VC\Tools\MSVC\14.15.26726\ATLMFC\include -ID:\MSVSC\VC\Tools\MSVC\14.15.26726\include "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\cppwinrt" /Tctensornets/references/darkflow_utils/nms.c /Fobuild\temp.win-amd64-3.6\Release\tensornets/references/darkflow_utils/nms.obj
nms.c
e:\python\anaconda_setup\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(12) : Warning Msg: Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
tensornets/references/darkflow_utils/nms.c(2437): warning C4244: โ€œ=โ€: ไปŽโ€œdoubleโ€่ฝฌๆขๅˆฐโ€œfloatโ€๏ผŒๅฏ่ƒฝไธขๅคฑๆ•ฐๆฎ
tensornets/references/darkflow_utils/nms.c(2446): warning C4244: โ€œ=โ€: ไปŽโ€œdoubleโ€่ฝฌๆขๅˆฐโ€œfloatโ€๏ผŒๅฏ่ƒฝไธขๅคฑๆ•ฐๆฎ
tensornets/references/darkflow_utils/nms.c(2496): warning C4244: โ€œ=โ€: ไปŽโ€œdoubleโ€่ฝฌๆขๅˆฐโ€œfloatโ€๏ผŒๅฏ่ƒฝไธขๅคฑๆ•ฐๆฎ
tensornets/references/darkflow_utils/nms.c(22776): warning C4244: โ€œๅˆๅง‹ๅŒ–โ€: ไปŽโ€œdoubleโ€่ฝฌๆขๅˆฐโ€œfloatโ€๏ผŒๅฏ่ƒฝไธขๅคฑๆ•ฐๆฎ
tensornets/references/darkflow_utils/nms.c(22782): warning C4244: โ€œๅˆๅง‹ๅŒ–โ€: ไปŽโ€œdoubleโ€่ฝฌๆขๅˆฐโ€œfloatโ€๏ผŒๅฏ่ƒฝไธขๅคฑๆ•ฐๆฎ
D:\MSVSC\VC\Tools\MSVC\14.15.26726\bin\HostX86\x64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:e:\python\anaconda_setup\libs /LIBPATH:e:\python\anaconda_setup\PCbuild\amd64 /LIBPATH:D:\MSVSC\VC\Tools\MSVC\14.15.26726\ATLMFC\lib\x64 /LIBPATH:D:\MSVSC\VC\Tools\MSVC\14.15.26726\lib\x64 "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\um\x64" m.lib /EXPORT:PyInit_nms build\temp.win-amd64-3.6\Release\tensornets/references/darkflow_utils/nms.obj /OUT:build\lib.win-amd64-3.6\tensornets\references\darkflow_utils\nms.cp36-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.6\Release\tensornets/references/darkflow_utils\nms.cp36-win_amd64.lib
LINK : fatal error LNK1181: ๆ— ๆณ•ๆ‰“ๅผ€่พ“ๅ…ฅๆ–‡ไปถโ€œm.libโ€
error: command 'D:\MSVSC\VC\Tools\MSVC\14.15.26726\bin\HostX86\x64\link.exe' failed with exit status 1181

----------------------------------------

Command "e:\python\anaconda_setup\python.exe -u -c "import setuptools, tokenize;file='C:\Users\hp\AppData\Local\Temp\pip-install-u8ygwt_s\tensornets\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\hp\AppData\Local\Temp\pip-record-al4vrtuo\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\hp\AppData\Local\Temp\pip-install-u8ygwt_s\tensornets\

My system is windows10 and my python is 3.6, tensorflow is 1.12.0 which is based on cpu.
Can anyone help me? Please!

can't load the weights

my code can run without any error in one device. when i copy the code to the another device, it crashed.
here is the error:

File "/media/profyuan/ๆ–ฐๅŠ ๅท2/JD_Fashion_AI/JD_Fashion_AI_original/train.py", line 204, in
main()
File "/media/profyuan/ๆ–ฐๅŠ ๅท2/JD_Fashion_AI/JD_Fashion_AI_original/train.py", line 200, in main
run_training()
File "/media/profyuan/ๆ–ฐๅŠ ๅท2/JD_Fashion_AI/JD_Fashion_AI_original/train.py", line 152, in run_training
sess.run(model.pretrained())
File "/usr/local/lib/python2.7/dist-packages/tensornets/pretrained.py", line 94, in _direct
return fun(scope, return_fn=pretrained_initializer)
File "/usr/local/lib/python2.7/dist-packages/tensornets/pretrained.py", line 186, in load_resnet101
return return_fn(scopes, values)
File "/usr/local/lib/python2.7/dist-packages/tensornets/utils.py", line 292, in pretrained_initializer
assert len(weights) == len(values), 'The sizes of symbolic and '
AssertionError: The sizes of symbolic and actual weights do not match.

here is my pip list:

absl-py 0.2.1
adium-theme-ubuntu 0.3.4
astor 0.6.2
backports-abc 0.5
backports.shutil-get-terminal-size 1.0.0
backports.weakref 1.0.post1
bleach 1.5.0
configparser 3.5.0
cycler 0.9.0
Cython 0.28.2
decorator 4.0.6
easydict 1.7
entrypoints 0.2.3
enum34 1.1.6
funcsigs 1.0.2
functools32 3.2.3.post2
futures 3.2.0
gast 0.2.0
grpcio 1.12.0
h5py 2.7.1
html5lib 0.9999999
ipykernel 4.8.2
ipython 5.7.0
ipython-genutils 0.2.0
ipywidgets 7.2.1
Jinja2 2.10
jsonschema 2.6.0
jupyter 1.0.0
jupyter-client 5.2.3
jupyter-console 5.2.0
jupyter-core 4.4.0
Keras 2.1.6
Markdown 2.6.11
MarkupSafe 1.0
matplotlib 1.5.1
mistune 0.8.3
mock 2.0.0
nbconvert 5.3.1
nbformat 4.4.0
nose 1.3.7
notebook 5.5.0
numpy 1.14.3
opencv-python 3.4.0.12
pandocfilters 1.4.2
pathlib2 2.3.2
pbr 4.0.2
pexpect 4.5.0
pickleshare 0.7.4
Pillow 5.1.0
pip 10.0.1
prompt-toolkit 1.0.15
protobuf 3.5.2.post1
ptyprocess 0.5.2
Pygments 2.2.0
pyparsing 2.0.3
Pyste 0.9.10
python-dateutil 2.4.2
pytz 2014.10
PyYAML 3.12
pyzmq 17.0.0
qtconsole 4.3.1
scandir 1.7
scikit-image 0.10.1
scikit-learn 0.19.1
scipy 0.17.0
Send2Trash 1.5.0
setuptools 20.7.0
simplegeneric 0.8.1
singledispatch 3.4.0.3
six 1.10.0
sklearn 0.0
tensorboard 1.8.0
tensorflow 1.8.0
tensorflow-gpu 1.4.0
tensorflow-tensorboard 0.4.0
tensornets 0.3.3
termcolor 1.1.0
terminado 0.8.1
testpath 0.3.1
tornado 5.0.2
traitlets 4.3.2
unity-lens-photos 1.0
virtualenv 15.0.1
wcwidth 0.1.7
Werkzeug 0.14.1
wheel 0.29.0
widgetsnbextension 3.2.1

The parameter settings for MobileNet V2.

Hi,
I would like to ask about the parameter settings of training MobileNet V2 from scratch with ImageNet, such as the initial learning rate, the optimizer, the loss function, as well as the training epochs.

Thank you so much.

Unable to do evaluation with multi GPU.

Though training is successful in multi-gpu cases, eval step fails with the following error:

InvalidArgumentError (see above for traceback): Number of ways to split should evenly divide the split dimension, but got split_dim 0 (size = 1) and num_split 2
[[Node: split_inputs/split = Split[T=DT_FLOAT, num_split=2, _device="/job:localhost/replica:0/task:0/device:CPU:0"](split_inputs/split/split_dim, IteratorGetNext)]]

My program is estimator based, training using train_and_evaluate method. Also using replicate_model_fn to run across multi GPUs

Dropout

Hello!

Thank you for sharing this library, it's great work!

I would like to know whether it's possible to use dropout with the pretrained models, I'm obtaining severe overfitting in my models.

Thanks in advance.

Regards,
Amelia.

Notes for different padding behaviors when `stride=2, padding='SAME'`

The 2x down-sampling is one of the important operations in reference models. But, a convolution or a pooling with stride=2, padding='SAME' may result in different outputs over different deep learning libraries (e.g., TensorFlow, CNTK, Theano, Caffe, Torch, ...) due to their different padding behaviors.

For example (TensorNets syntax; but can be regarded as pseudo codes for other libraries),

x = tf.placeholder(tf.float32, shape=[None, 224, 224, 3])
x = conv(x, 64, 7, stride=2, padding='SAME')

produces a [None, 112, 112, 64] map. This example can be performed as either one of the following cases:

Case 1 (asymmetric)

  • Left-top: kernel_size // 2 - 1, bottom-right: kernel_size // 2
  • The example is working implicitly as:
x = pad(x, [[0, 0], [2, 3], [2, 3], [0, 0]])  # 224 -> 229
x = conv(x, 64, 7, stride=2, padding='VALID')  # 229 -> 112

Case 2 (symmetric)

  • All the corners: kernel_size // 2
  • The example is working implicitly as:
x = pad(x, [[0, 0], [3, 3], [3, 3], [0, 0]])  # 224 -> 230
x = conv(x, 64, 7, stride=2, padding='VALID')  # 230 -> 112 with slicing the the rightmost 1 pixel

As TensorNets translates the original repositories written in various libraries, TensorNets must consider the two padding behaviors to reproduce the original results exactly.

Results

I compared the performance differences of the two padding schemes with the 11 ResNet variants. Precisely, the two for the ResNets are:

# Case 1 (asymmetric)
x = conv2d(x, 64, 7, stride=2, padding='SAME')  # symmetric for ResNet50,101,152v2
...
x = max_pool2d(x, 3, stride=2, padding='SAME')
...

# Case 2 (symmetric)
x = pad(x, [[0, 0], [3, 3], [3, 3], [0, 0]])
x = conv2d(x, 64, 7, stride=2, padding='VALID')
...
x = pad(x, [[0, 0], [1, 1], [1, 1], [0, 0]])
x = max_pool2d(x, 3, stride=2, padding='VALID')
...

The results are summarized as follows:

Top-1 Top-5 10-5 Top-1 Top-5 10-5
Case 1 (asymmetric) Case 2 (symmetric)
ResNet50 25.436 8.098 6.950 25.126 7.982 6.842
ResNet101 24.250 7.402 6.210 23.580 7.214 6.092
ResNet152 23.860 7.098 6.068 23.396 6.882 5.908
ResNet50v2 24.040 6.966 5.896 24.526 7.252 6.012
ResNet101v2 22.766 6.184 5.158 23.116 6.488 5.230
ResNet152v2 21.968 5.838 4.900 22.236 6.080 4.960
ResNet200v2 22.286 6.056 4.902 21.714 5.848 4.830
ResNeXt50c32 22.806 6.460 5.492 22.260 6.190 5.410
ResNeXt101c32 21.660 6.068 4.996 21.270 5.706 4.842
ResNeXt101c64 20.924 5.566 4.666 20.506 5.408 4.564
WideResNet50 22.516 6.344 5.248 21.982 6.066 5.116

All except ResNet50,101,152v2 showed better performances in symmetric padding than asymmetric padding. This is because only TensorFlow (as far as I know) uses asymmetric padding, and only ResNet50,101,152v2 are trained with TensorFlow. Note that

  • ResNet50,101,152 are translated from Caffe,
  • ResNet50,101,152v2 are from TensorFlow,
  • ResNet200v2 is from Torch,
  • ResNeXt50c32,ResNeXt101c32,64 are from PyTorch,
  • WideResNet50 is from Torch.

Caffe uses definitely symmetric padding, and I can infer that (Py)Torch also does so (I'm not familiar with Torch). Thus, in order to reproduce the original results, I revised the current symmetric paddings for the pool1 in the ResNets as asymmetric paddings only in case of ResNet50,101,152v2. As the conv1 of ResNet50,101,152v2 transforms 299 to 150, the SAME padding is equivalent to the symmetric so the conv1/pad didn't be touched. Please see the commit :)

YOLOv3: Buffer has wrong number of dimensions

Sorry for all the issues opened recently ๐Ÿ˜„ No worries if you don't have time to look at this one.

Running with: Ubuntu 17.10, Python 2.7, Tensorflow-GPU 1.7.0, Nvidia K80

The following code:

import tensorflow as tf
import tensornets as nets

inputs = tf.placeholder(tf.float32, [None, 416, 416, 3])
model = nets.YOLOv3VOC(inputs)

img = nets.utils.load_img('cat.png')

with tf.Session() as sess:
    sess.run(model.pretrained())
    preds = sess.run(model, {inputs: model.preprocess(img)})
    boxes = model.get_boxes(preds, img.shape[1:3])

Produces this error:

ValueErrorTraceback (most recent call last)
in ()
10 sess.run(model.pretrained())
11 preds = sess.run(model, {inputs: model.preprocess(img)})
---> 12 boxes = model.get_boxes(preds, img.shape[1:3])

/usr/local/lib/python2.7/dist-packages/tensornets/references/yolos.pyc in _get_boxes(*args, **kwargs)
177 def yolov3voc(x, is_training=False, scope=None, reuse=None):
178 def _get_boxes(*args, **kwargs):
--> 179 return get_v3_boxes(opts('yolov3voc'), *args, **kwargs)
180 x = yolov3(x, [1, 2, 8, 8, 4, 3], 75, is_training, scope, reuse)
181 x.get_boxes = _get_boxes

/usr/local/lib/python2.7/dist-packages/tensornets/references/yolo_utils.pyc in get_v3_boxes(opts, outs, source_size, threshold)
77 opts['anchor_idx'] = 6 - 3 * i
78 o = np.array(outs[i][0], dtype=np.float32)
---> 79 results = yolov3_box(opts, o)
80 for b in results:
81 idx, box = parse_box(b, threshold, w, h)

/usr/local/lib/python2.7/dist-packages/tensornets/references/darkflow_utils/get_boxes.pyx in tensornets.references.darkflow_utils.get_boxes.yolov3_box()
53 @cython.boundscheck(False) # turn off bounds-checking for entire function
54 @cython.wraparound(False) # turn off negative index wrapping for entire function
---> 55 def yolov3_box(meta,np.ndarray[float,ndim=3] net_out_in):
56 cdef:
57 np.intp_t H, W, _, C, B, row, col, box_loop, class_loop

ValueError: Buffer has wrong number of dimensions (expected 3, got 2)

Any ideas? Same thing happens if I run with YOLOv3COCO

detection scripts error

hi with windows got this error when trying your detection script
is there something missing.
installed with pip
AssertionError: get_boxes requires darkflow

Add FP16 supports

TensorNets lacks of FP16 supports. For example, the following should work:

inputs = tf.placeholder(tf.float16, [None, 224, 224, 3])
model = nets.ResNet50(inputs)

Error when running pip install tensornets

This is the output when running pip install tensornets

Collecting tensornets
  Downloading https://files.pythonhosted.org/packages/b9/b7/dd956d687d5a45ccac1275dba1f522f6dedeaab43e5e540c2627fa4d6f9c/tensornets-0.3.4.tar.gz (576kB)
Building wheels for collected packages: tensornets
  Running setup.py bdist_wheel for tensornets: started
  Running setup.py bdist_wheel for tensornets: finished with status 'error'
  Complete output from command c:\users\jmorales\appdata\local\programs\python\python35\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\jmorales\\AppData\\Local\\Temp\\pip-install-emz1qnku\\tensornets\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\jmorales\AppData\Local\Temp\pip-wheel-7vgpy5t9 --python-tag cp35:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.5
  creating build\lib.win-amd64-3.5\tensornets
  copying tensornets\capsulenets.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\darknets.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\densenets.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\detections.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\inceptions.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\layers.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\middles.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\mobilenets.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\nasnets.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\ops.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\preprocess.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\pretrained.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\resnets.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\squeezenets.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\utils.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\vggs.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\zf.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\__init__.py -> build\lib.win-amd64-3.5\tensornets
  creating build\lib.win-amd64-3.5\tensornets\datasets
  copying tensornets\datasets\imagenet.py -> build\lib.win-amd64-3.5\tensornets\datasets
  copying tensornets\datasets\voc.py -> build\lib.win-amd64-3.5\tensornets\datasets
  copying tensornets\datasets\__init__.py -> build\lib.win-amd64-3.5\tensornets\datasets
  creating build\lib.win-amd64-3.5\tensornets\references
  copying tensornets\references\rcnns.py -> build\lib.win-amd64-3.5\tensornets\references
  copying tensornets\references\rpn_utils.py -> build\lib.win-amd64-3.5\tensornets\references
  copying tensornets\references\yolos.py -> build\lib.win-amd64-3.5\tensornets\references
  copying tensornets\references\yolo_utils.py -> build\lib.win-amd64-3.5\tensornets\references
  copying tensornets\references\__init__.py -> build\lib.win-amd64-3.5\tensornets\references
  creating build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
  copying tensornets\references\darkflow_utils\box.py -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
  copying tensornets\references\darkflow_utils\__init__.py -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
  running egg_info
  writing tensornets.egg-info\PKG-INFO
  writing top-level names to tensornets.egg-info\top_level.txt
  writing dependency_links to tensornets.egg-info\dependency_links.txt
  reading manifest file 'tensornets.egg-info\SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  writing manifest file 'tensornets.egg-info\SOURCES.txt'
  copying tensornets\references\darkflow_utils\get_boxes.c -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
  copying tensornets\references\darkflow_utils\nms.c -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
  copying tensornets\datasets\voc.names -> build\lib.win-amd64-3.5\tensornets\datasets
  copying tensornets\references\coco.names -> build\lib.win-amd64-3.5\tensornets\references
  copying tensornets\references\voc.names -> build\lib.win-amd64-3.5\tensornets\references
  copying tensornets\references\darkflow_utils\__init__.pyc -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
  copying tensornets\references\darkflow_utils\box.pyc -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
  copying tensornets\references\darkflow_utils\get_boxes.pyx -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
  copying tensornets\references\darkflow_utils\get_boxes.so -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
  copying tensornets\references\darkflow_utils\nms.pxd -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
  copying tensornets\references\darkflow_utils\nms.pyx -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
  copying tensornets\references\darkflow_utils\nms.so -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
  running build_ext
  building 'tensornets.references.darkflow_utils.nms' extension
  creating build\temp.win-amd64-3.5
  creating build\temp.win-amd64-3.5\Release
  creating build\temp.win-amd64-3.5\Release\tensornets
  creating build\temp.win-amd64-3.5\Release\tensornets\references
  creating build\temp.win-amd64-3.5\Release\tensornets\references\darkflow_utils
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\jmorales\appdata\local\programs\python\python35\lib\site-packages\numpy\core\include -Ic:\users\jmorales\appdata\local\programs\python\python35\include -Ic:\users\jmorales\appdata\local\programs\python\python35\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tctensornets/references/darkflow_utils/nms.c /Fobuild\temp.win-amd64-3.5\Release\tensornets/references/darkflow_utils/nms.obj
  nms.c
  c:\users\jmorales\appdata\local\programs\python\python35\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(12) : Warning Msg: Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
  tensornets/references/darkflow_utils/nms.c(2380): warning C4244: '=': conversion from 'double' to 'float', possible loss of data
  tensornets/references/darkflow_utils/nms.c(2389): warning C4244: '=': conversion from 'double' to 'float', possible loss of data
  tensornets/references/darkflow_utils/nms.c(2439): warning C4244: '=': conversion from 'double' to 'float', possible loss of data
  tensornets/references/darkflow_utils/nms.c(22288): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
  tensornets/references/darkflow_utils/nms.c(22294): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:c:\users\jmorales\appdata\local\programs\python\python35\libs /LIBPATH:c:\users\jmorales\appdata\local\programs\python\python35\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64" m.lib /EXPORT:PyInit_nms build\temp.win-amd64-3.5\Release\tensornets/references/darkflow_utils/nms.obj /OUT:build\lib.win-amd64-3.5\tensornets\references\darkflow_utils\nms.cp35-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.5\Release\tensornets/references/darkflow_utils\nms.cp35-win_amd64.lib
  LINK : fatal error LNK1181: cannot open input file 'm.lib'
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1181

  ----------------------------------------
  Failed building wheel for tensornets
  Running setup.py clean for tensornets
Failed to build tensornets
Installing collected packages: tensornets
  Running setup.py install for tensornets: started
    Running setup.py install for tensornets: finished with status 'error'
    Complete output from command c:\users\jmorales\appdata\local\programs\python\python35\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\jmorales\\AppData\\Local\\Temp\\pip-install-emz1qnku\\tensornets\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\jmorales\AppData\Local\Temp\pip-record-gqdxhlji\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.5
    creating build\lib.win-amd64-3.5\tensornets
    copying tensornets\capsulenets.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\darknets.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\densenets.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\detections.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\inceptions.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\layers.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\middles.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\mobilenets.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\nasnets.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\ops.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\preprocess.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\pretrained.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\resnets.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\squeezenets.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\utils.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\vggs.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\zf.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\__init__.py -> build\lib.win-amd64-3.5\tensornets
    creating build\lib.win-amd64-3.5\tensornets\datasets
    copying tensornets\datasets\imagenet.py -> build\lib.win-amd64-3.5\tensornets\datasets
    copying tensornets\datasets\voc.py -> build\lib.win-amd64-3.5\tensornets\datasets
    copying tensornets\datasets\__init__.py -> build\lib.win-amd64-3.5\tensornets\datasets
    creating build\lib.win-amd64-3.5\tensornets\references
    copying tensornets\references\rcnns.py -> build\lib.win-amd64-3.5\tensornets\references
    copying tensornets\references\rpn_utils.py -> build\lib.win-amd64-3.5\tensornets\references
    copying tensornets\references\yolos.py -> build\lib.win-amd64-3.5\tensornets\references
    copying tensornets\references\yolo_utils.py -> build\lib.win-amd64-3.5\tensornets\references
    copying tensornets\references\__init__.py -> build\lib.win-amd64-3.5\tensornets\references
    creating build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
    copying tensornets\references\darkflow_utils\box.py -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
    copying tensornets\references\darkflow_utils\__init__.py -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
    running egg_info
    writing tensornets.egg-info\PKG-INFO
    writing top-level names to tensornets.egg-info\top_level.txt
    writing dependency_links to tensornets.egg-info\dependency_links.txt
    reading manifest file 'tensornets.egg-info\SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'tensornets.egg-info\SOURCES.txt'
    copying tensornets\references\darkflow_utils\get_boxes.c -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
    copying tensornets\references\darkflow_utils\nms.c -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
    copying tensornets\datasets\voc.names -> build\lib.win-amd64-3.5\tensornets\datasets
    copying tensornets\references\coco.names -> build\lib.win-amd64-3.5\tensornets\references
    copying tensornets\references\voc.names -> build\lib.win-amd64-3.5\tensornets\references
    copying tensornets\references\darkflow_utils\__init__.pyc -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
    copying tensornets\references\darkflow_utils\box.pyc -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
    copying tensornets\references\darkflow_utils\get_boxes.pyx -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
    copying tensornets\references\darkflow_utils\get_boxes.so -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
    copying tensornets\references\darkflow_utils\nms.pxd -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
    copying tensornets\references\darkflow_utils\nms.pyx -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
    copying tensornets\references\darkflow_utils\nms.so -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
    running build_ext
    building 'tensornets.references.darkflow_utils.nms' extension
    creating build\temp.win-amd64-3.5
    creating build\temp.win-amd64-3.5\Release
    creating build\temp.win-amd64-3.5\Release\tensornets
    creating build\temp.win-amd64-3.5\Release\tensornets\references
    creating build\temp.win-amd64-3.5\Release\tensornets\references\darkflow_utils
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\jmorales\appdata\local\programs\python\python35\lib\site-packages\numpy\core\include -Ic:\users\jmorales\appdata\local\programs\python\python35\include -Ic:\users\jmorales\appdata\local\programs\python\python35\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tctensornets/references/darkflow_utils/nms.c /Fobuild\temp.win-amd64-3.5\Release\tensornets/references/darkflow_utils/nms.obj
    nms.c
    c:\users\jmorales\appdata\local\programs\python\python35\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(12) : Warning Msg: Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
    tensornets/references/darkflow_utils/nms.c(2380): warning C4244: '=': conversion from 'double' to 'float', possible loss of data
    tensornets/references/darkflow_utils/nms.c(2389): warning C4244: '=': conversion from 'double' to 'float', possible loss of data
    tensornets/references/darkflow_utils/nms.c(2439): warning C4244: '=': conversion from 'double' to 'float', possible loss of data
    tensornets/references/darkflow_utils/nms.c(22288): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
    tensornets/references/darkflow_utils/nms.c(22294): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:c:\users\jmorales\appdata\local\programs\python\python35\libs /LIBPATH:c:\users\jmorales\appdata\local\programs\python\python35\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.10240.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64" m.lib /EXPORT:PyInit_nms build\temp.win-amd64-3.5\Release\tensornets/references/darkflow_utils/nms.obj /OUT:build\lib.win-amd64-3.5\tensornets\references\darkflow_utils\nms.cp35-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.5\Release\tensornets/references/darkflow_utils\nms.cp35-win_amd64.lib
    LINK : fatal error LNK1181: cannot open input file 'm.lib'
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1181

    ----------------------------------------
Command "c:\users\jmorales\appdata\local\programs\python\python35\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\jmorales\\AppData\\Local\\Temp\\pip-install-emz1qnku\\tensornets\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\jmorales\AppData\Local\Temp\pip-record-gqdxhlji\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\jmorales\AppData\Local\Temp\pip-install-emz1qnku\tensornets\

This is my setup:

Python version: 3.5
OS: Windows 10 Home
System Type: 64-bit Operating System, x64-based processor
Processor: AMD A10-8700P Radeon R6

Vgg16: Problems of Loading Pretrained Weights without fcs

@taehoonlee I tried to use sess.run(net.pretrained()) for vgg16, but it failed because of shape mismatch (I did not use the default input size). I read the source code and I am confused by line 320 in tensornets/utils.py,
image
is the code at line 321 designed for tackling the shape mismatch of fcs? If yes, I think it has a problem on vgg16 because it has three fc and this code seems to be only suitable for networks with 1 fc.

Two easy questions

Hello;

I am planning to compare the performance of a few segmentation models and I found the repo when I was looking for the easiest way to implement transfer learning from classifications to segmentation models. The work you have done until now is outstanding and for sure is helping a lot of us.

I am just about to try tensornets but before I would like to ask a couple of questions in order to try to ease my own tasks.

  • To implement skip connections, to formulate alternative loss functions and in general the usual machinery for segmentation models, I can have access to any level/layer/weight with get_middles() and get()_outputs of classification networks, right?

  • Is easy to integrate tensornets with estimators?

Thank you for you work!!

Various questions

First off, thanks very much for all your work on this - a really clean and understandable implementation of YOLO ๐Ÿ˜„ I have a few questions (probably very basic) about getting started with training and inference with tensornets - in specific to the YOLOv2 model:

  1. I am wanting to train YOLOv2 on the Open Images dataset. How can the tensornets implementation of YOLOv2 be used with a custom number of classes (545 in my case)?
  2. After training, how would one save the weights to a file and load them back in later for inference?
  3. Can layers be frozen during training (i.e. only train the last 4 layers) similar to what one can do in darknet with stopbackward=1?
  4. Is there support for training the YOLOv2 model with a TPU? If not, is there a somewhat straightforward path to adding that functionality?
  5. Can YOLOv2 be trained and used for inference with FP16 precision to speed things up - and can the existing pretrained weights be converted to FP16 so as to not necessitate training from scratch?

Thanks very much!

custom weights for tensornet model

Hi, is it possible to load custom weights in tensornets models? Say I have some different classes than the ones in coco dataset for a yolov3 model and I'd like to load them using tensornets. Is that doable?

Thanks in advance!

Notes for the updates of the performance table

Recently, I have updated the performance table to follow the recent report format. I reviewed 10 recent papers as follows, and found that error rates and 10-crop testing are no longer used for evaluation after about 2017.

measure 10-crop
ResNeXt (CVPR 2017) err O
DenseNet (CVPR 2017) err O
PolyNet (CVPR 2017) err O
DPN (NIPS 2017) err -
SENet (CVPR 2018) err -
MobileNetV2 (CVPR 2018) acc -
NASNet (CVPR 2018) acc -
PNASNet (ECCV 2018) acc -
AmoebaNet (AAAI 2019) acc -
EfficientNet (ICML 2019) acc -

For the above reason, the recent commit replaces the top-k error rates with accuracies and removes the 10-5 column (the top-5 score with 10 crops).

Why don't install "pybluez" in anaconda3 in windows10 system

pip install pybluez
Collecting pybluez
Using cached https://files.pythonhosted.org/packages/c1/98/3149481d508bee174335be6725880f00d297afebe75c15e917af8f6fe169/PyBluez-0.22.zip
Complete output from command python setup.py egg_info:
Could not find the Windows Platform SDK

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in C:\Users\User\AppData\Local\Temp\pip-install-yb8lba9t\pybluez\

ho to solve this question ?
please help me!!!

about some doubt

First thanks your repo. but i want to ask you some doubt of mine.

  1. In follow image, we can see 'scope' in function __stack unuse;
    default
  2. What is this circled in follow image.
    default

Tensornets not working with threading.Threads

Hi ! I was using tensornets with threading.Threads. It shows error with some tensorflow shapes. Please look after this and provide me with the solution.

Te code is

import threading
import tensorflow as tf
import tensornets as nets
import cv2
import numpy as np
import time
import os

import argparse

class MyThread(threading.Thread):

def run(self):

    # os.popen("start cmd /k python detection.py")

    print("------------------------------{} started!----------------------------------------".format(self.getName()))              # "Thread-x started!"


    inputs = tf.placeholder(tf.float32, [None, 416, 416, 3])
    model = nets.YOLOv3COCO(inputs, nets.Darknet19)
    #model = nets.YOLOv2(inputs, nets.Darknet19)

    #frame=cv2.imread("D://pyworks//yolo//truck.jpg",1)

    cap = cv2.VideoCapture('rtsp://root:[email protected]:554/axis-media/media.amp')

    classes={'0':'person','1':'bicycle','2':'car','3':'bike','5':'bus','7':'truck'}
    list_of_classes=[0,1,2,3,5,7]
    print("Done")

    config = tf.ConfigProto()
    config.intra_op_parallelism_threads = 44
    config.inter_op_parallelism_threads = 44
    # tf.session(config=config)
    
    with tf.Session(config=config) as sess:

        print("---------------------------{} session running-----------------------".format(self.getName()))
        sess.run(model.pretrained())
    # Create a VideoCapture object and read from input file
        # cap = cv2.VideoCapture('C://Users//essi//Downloads//vehicle.mp4')
        
        # Check if camera opened successfully
        if (cap.isOpened()== False):
            print("Error opening video  file")

        co=0
        # Read until video is completed
        while(cap.isOpened()):

        # Capture frame-by-frame
            ret, frame = cap.read()
            if ret == True:
                
                co=co+1
                print(co)
                img=cv2.resize(frame,(416,416))
                    
                if (co%1==0):

                    imge=np.array(img).reshape(-1,416,416,3)
                    start_time=time.time()
                    preds = sess.run(model.preds, {inputs: model.preprocess(imge)})
                    # preds= nets.preprocess(model,imge)

                    print("--- %s seconds ---" % (time.time() - start_time))
                    boxes = model.get_boxes(preds, imge.shape[1:3])
                    cv2.namedWindow('video feed',cv2.WINDOW_NORMAL)

                    cv2.resizeWindow('video feed', 700,500)
                    #print("--- %s seconds ---" % (time.time() - start_time))
                    boxes1=np.array(boxes)
                    for j in list_of_classes:
                        count =0

                        if str(j) in classes:
                            lab=classes[str(j)]
                        if len(boxes1) !=0:
                            for i in range(len(boxes1[j])):
                                box=boxes1[j][i]

                                if boxes1[j][i][4]>=.40:

                                    count += 1

                                    cv2.rectangle(img,(box[0],box[1]),(box[2],box[3]),(0,255,0),1)
                                    cv2.putText(img, lab, (box[0],box[1]), cv2.FONT_HERSHEY_SIMPLEX, .5, (0, 0, 255), lineType=cv2.LINE_AA)
                        print(lab,": ",count)
            # Display the resulting frame
                cv2.imshow('video feed', img)

            # Press Q on keyboard to  exit
                if cv2.waitKey(40) & 0xFF == ord('q'):
                    break
        
    # Break the loop
    #   else:
    #     break
    
    # When everything done, release
    # the video capture object
    cap.release()
    
    # Closes all the frames
    cv2.destroyAllWindows()

    
    
    print("------------------------------{} finished!----------------------------------------".format(self.getName()))             # "Thread-x finished!"

def main():

parser = argparse.ArgumentParser()
parser.add_argument('-t', help='help')
args = parser.parse_args()
args=vars(args)
print(args)

for x in range(int(args['t'])):                                     # Four times...
    mythread = MyThread(name = "Thread-{}".format(x+1))  # ...Instantiate a thread and pass a unique ID to it
    mythread.start()            

if name == 'main':main()

AND IT SHOWS THE OUTPUT AS

------------------------------Thread-1 started!----------------------------------------
WARNING: Logging before flag parsing goes to stderr.
------------------------------Thread-2 started!----------------------------------------
W0910 10:55:52.911941 5408 deprecation_wrapper.py:119] From .\threadwc.py:21: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.

W0910 10:55:52.911941 5184 deprecation_wrapper.py:119] From .\threadwc.py:21: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.

W0910 10:55:53.041654 5408 deprecation_wrapper.py:119] From C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensornets\utils.py:238: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.

W0910 10:55:53.041654 5184 deprecation_wrapper.py:119] From C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensornets\utils.py:238: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.

W0910 10:55:53.647777 5408 deprecation_wrapper.py:119] From C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensornets\utils.py:279: The name tf.get_variable_scope is deprecated. Please use tf.compat.v1.get_variable_scope instead.

Done
2019-09-10 10:55:58.563571: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
---------------------------Thread-2 session running-----------------------
Done
---------------------------Thread-1 session running-----------------------
C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensornets\utils.py:319: UserWarning: The sizes of symbolic and actual weights do not match. Never mind if you are trying to load stem layers only.
warnings.warn('The sizes of symbolic and actual weights do not match. '
Exception in thread Thread-2:
Traceback (most recent call last):
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 1864, in _create_c_op
c_op = c_api.TF_FinishOperation(op_desc)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Shapes must be equal rank, but are 4 and 1 for 'Assign_291' (op: 'Assign') with input shapes: [1,1,512,256], [255].

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File ".\threadwc.py", line 41, in run
sess.run(model.pretrained())
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensornets\pretrained.py", line 99, in _direct
return fun(scope, return_fn=pretrained_initializer)
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensornets\pretrained.py", line 695, in load_ref_yolo_v3_coco
return return_fn(scopes, values)
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensornets\utils.py", line 333, in pretrained_initializer
ops = [w.assign(v) for (w, v) in zip(weights[:-2], values[:-2])]
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensornets\utils.py", line 333, in
ops = [w.assign(v) for (w, v) in zip(weights[:-2], values[:-2])]
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\ops\variables.py", line 1952, in assign
name=name)
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\ops\state_ops.py", line 227, in assign
validate_shape=validate_shape)
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\ops\gen_state_ops.py", line 69, in assign
use_locking=use_locking, name=name)
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 788, in _apply_op_helper
op_def=op_def)
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\util\deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 3616, in create_op
op_def=op_def)
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 2027, in init
control_input_ops)
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 1867, in _create_c_op
raise ValueError(str(e))
ValueError: Shapes must be equal rank, but are 4 and 1 for 'Assign_291' (op: 'Assign') with input shapes: [1,1,512,256], [255].

Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 1864, in _create_c_op
c_op = c_api.TF_FinishOperation(op_desc)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Shapes must be equal rank, but are 4 and 1 for 'Assign_291' (op: 'Assign') with input shapes: [1,1,512,256], [255].

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File ".\threadwc.py", line 41, in run
sess.run(model.pretrained())
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensornets\pretrained.py", line 99, in _direct
return fun(scope, return_fn=pretrained_initializer)
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensornets\pretrained.py", line 695, in load_ref_yolo_v3_coco
return return_fn(scopes, values)
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensornets\utils.py", line 333, in pretrained_initializer
ops = [w.assign(v) for (w, v) in zip(weights[:-2], values[:-2])]
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensornets\utils.py", line 333, in
ops = [w.assign(v) for (w, v) in zip(weights[:-2], values[:-2])]
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\ops\variables.py", line 1952, in assign
name=name)
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\ops\state_ops.py", line 227, in assign
validate_shape=validate_shape)
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\ops\gen_state_ops.py", line 69, in assign
use_locking=use_locking, name=name)
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 788, in _apply_op_helper
op_def=op_def)
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\util\deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 3616, in create_op
op_def=op_def)
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 2027, in init
control_input_ops)
File "C:\Users\essi\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 1867, in _create_c_op
raise ValueError(str(e))
ValueError: Shapes must be equal rank, but are 4 and 1 for 'Assign_291' (op: 'Assign') with input shapes: [1,1,512,256], [255].

threadwc - Copy.txt

Load pretrained weights when multiple models exist

When multiple models exist, pretrained() from the second doesn't work.

import tensorflow as tf
import tensornets as nets

inputs = tf.placeholder(tf.float32, [None, 224, 224, 3])
model1 = nets.ResNet50(inputs, scope='abc')
model2 = nets.Inception2(inputs, scope='def')
model3 = nets.DenseNet121(inputs, scope='ghi')

with tf.Session() as sess:
    sess.run(model1.pretrained())  # O
    try:
        sess.run(model2.pretrained())  # X
    except:
        print('X')
    try:
        sess.run(model3.pretrained())  # X
    except:
        print('X')

Windows 10, anaconda environment build error occurred.

Hello, i having difficulties about install tensornets.

my environment is explaned bellow.

OS: windows 10
Virtual environment: anaconda
Python version: 3.5
tensorflow version: 1.9
PIP version: 18.1

I was activating my tensorflow virtual environment on anaconda then input command like this

pip install tensornets.

whole prompt return string is here

Collecting tensornets
  Using cached https://files.pythonhosted.org/packages/28/77/8f3e6717a3e51d2f26c5d1e6b82599b01a5941dbcc98b39a4dd542502965/tensornets-0.3.5.tar.gz
Building wheels for collected packages: tensornets
  Running setup.py bdist_wheel for tensornets ... error
  Complete output from command c:\users\bearm\anaconda3\envs\py35tf\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\bearm\\AppData\\Local\\Temp\\pip-install-36vc4dxz\\tensornets\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\bearm\AppData\Local\Temp\pip-wheel-tnqbxh0x --python-tag cp35:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.5
  creating build\lib.win-amd64-3.5\tensornets
  copying tensornets\capsulenets.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\darknets.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\densenets.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\detections.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\inceptions.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\layers.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\middles.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\mobilenets.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\nasnets.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\ops.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\preprocess.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\pretrained.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\resnets.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\squeezenets.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\unet.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\utils.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\vggs.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\wavenets.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\zf.py -> build\lib.win-amd64-3.5\tensornets
  copying tensornets\__init__.py -> build\lib.win-amd64-3.5\tensornets
  creating build\lib.win-amd64-3.5\tensornets\datasets
  copying tensornets\datasets\coco.py -> build\lib.win-amd64-3.5\tensornets\datasets
  copying tensornets\datasets\imagenet.py -> build\lib.win-amd64-3.5\tensornets\datasets
  copying tensornets\datasets\voc.py -> build\lib.win-amd64-3.5\tensornets\datasets
  copying tensornets\datasets\__init__.py -> build\lib.win-amd64-3.5\tensornets\datasets
  creating build\lib.win-amd64-3.5\tensornets\references
  copying tensornets\references\rcnns.py -> build\lib.win-amd64-3.5\tensornets\references
  copying tensornets\references\rpn_utils.py -> build\lib.win-amd64-3.5\tensornets\references
  copying tensornets\references\yolos.py -> build\lib.win-amd64-3.5\tensornets\references
  copying tensornets\references\yolo_utils.py -> build\lib.win-amd64-3.5\tensornets\references
  copying tensornets\references\__init__.py -> build\lib.win-amd64-3.5\tensornets\references
  creating build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
  copying tensornets\references\darkflow_utils\box.py -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
  copying tensornets\references\darkflow_utils\__init__.py -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
  running egg_info
  writing dependency_links to tensornets.egg-info\dependency_links.txt
  writing tensornets.egg-info\PKG-INFO
  writing top-level names to tensornets.egg-info\top_level.txt
  reading manifest file 'tensornets.egg-info\SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  writing manifest file 'tensornets.egg-info\SOURCES.txt'
  copying tensornets\references\darkflow_utils\get_boxes.c -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
  copying tensornets\references\darkflow_utils\nms.c -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
  copying tensornets\datasets\coco.names -> build\lib.win-amd64-3.5\tensornets\datasets
  copying tensornets\datasets\voc.names -> build\lib.win-amd64-3.5\tensornets\datasets
  copying tensornets\references\coco.names -> build\lib.win-amd64-3.5\tensornets\references
  copying tensornets\references\voc.names -> build\lib.win-amd64-3.5\tensornets\references
  copying tensornets\references\darkflow_utils\__init__.pyc -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
  copying tensornets\references\darkflow_utils\box.pyc -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
  copying tensornets\references\darkflow_utils\get_boxes.pyx -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
  copying tensornets\references\darkflow_utils\get_boxes.so -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
  copying tensornets\references\darkflow_utils\nms.pxd -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
  copying tensornets\references\darkflow_utils\nms.pyx -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
  copying tensornets\references\darkflow_utils\nms.so -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
  running build_ext
  building 'tensornets.references.darkflow_utils.nms' extension
  creating build\temp.win-amd64-3.5
  creating build\temp.win-amd64-3.5\Release
  creating build\temp.win-amd64-3.5\Release\tensornets
  creating build\temp.win-amd64-3.5\Release\tensornets\references
  creating build\temp.win-amd64-3.5\Release\tensornets\references\darkflow_utils
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\bearm\anaconda3\envs\py35tf\lib\site-packages\numpy\core\include -Ic:\users\bearm\anaconda3\envs\py35tf\include -Ic:\users\bearm\anaconda3\envs\py35tf\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\winrt" /Tctensornets/references/darkflow_utils/nms.c /Fobuild\temp.win-amd64-3.5\Release\tensornets/references/darkflow_utils/nms.obj
  nms.c
  c:\users\bearm\anaconda3\envs\py35tf\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(12) : Warning Msg: Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
  tensornets/references/darkflow_utils/nms.c(2437): warning C4244: '=': conversion from 'double' to 'float', possible loss of data
  tensornets/references/darkflow_utils/nms.c(2446): warning C4244: '=': conversion from 'double' to 'float', possible loss of data
  tensornets/references/darkflow_utils/nms.c(2496): warning C4244: '=': conversion from 'double' to 'float', possible loss of data
  tensornets/references/darkflow_utils/nms.c(22776): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
  tensornets/references/darkflow_utils/nms.c(22782): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:c:\users\bearm\anaconda3\envs\py35tf\libs /LIBPATH:c:\users\bearm\anaconda3\envs\py35tf\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.14393.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.14393.0\um\x64" m.lib /EXPORT:PyInit_nms build\temp.win-amd64-3.5\Release\tensornets/references/darkflow_utils/nms.obj /OUT:build\lib.win-amd64-3.5\tensornets\references\darkflow_utils\nms.cp35-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.5\Release\tensornets/references/darkflow_utils\nms.cp35-win_amd64.lib
  LINK : fatal error LNK1181: cannot open input file 'm.lib'
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1181

  ----------------------------------------
  Failed building wheel for tensornets
  Running setup.py clean for tensornets
Failed to build tensornets
Installing collected packages: tensornets
  Running setup.py install for tensornets ... error
    Complete output from command c:\users\bearm\anaconda3\envs\py35tf\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\bearm\\AppData\\Local\\Temp\\pip-install-36vc4dxz\\tensornets\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\bearm\AppData\Local\Temp\pip-record-f7zzi1az\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.5
    creating build\lib.win-amd64-3.5\tensornets
    copying tensornets\capsulenets.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\darknets.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\densenets.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\detections.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\inceptions.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\layers.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\middles.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\mobilenets.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\nasnets.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\ops.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\preprocess.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\pretrained.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\resnets.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\squeezenets.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\unet.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\utils.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\vggs.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\wavenets.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\zf.py -> build\lib.win-amd64-3.5\tensornets
    copying tensornets\__init__.py -> build\lib.win-amd64-3.5\tensornets
    creating build\lib.win-amd64-3.5\tensornets\datasets
    copying tensornets\datasets\coco.py -> build\lib.win-amd64-3.5\tensornets\datasets
    copying tensornets\datasets\imagenet.py -> build\lib.win-amd64-3.5\tensornets\datasets
    copying tensornets\datasets\voc.py -> build\lib.win-amd64-3.5\tensornets\datasets
    copying tensornets\datasets\__init__.py -> build\lib.win-amd64-3.5\tensornets\datasets
    creating build\lib.win-amd64-3.5\tensornets\references
    copying tensornets\references\rcnns.py -> build\lib.win-amd64-3.5\tensornets\references
    copying tensornets\references\rpn_utils.py -> build\lib.win-amd64-3.5\tensornets\references
    copying tensornets\references\yolos.py -> build\lib.win-amd64-3.5\tensornets\references
    copying tensornets\references\yolo_utils.py -> build\lib.win-amd64-3.5\tensornets\references
    copying tensornets\references\__init__.py -> build\lib.win-amd64-3.5\tensornets\references
    creating build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
    copying tensornets\references\darkflow_utils\box.py -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
    copying tensornets\references\darkflow_utils\__init__.py -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
    running egg_info
    writing tensornets.egg-info\PKG-INFO
    writing dependency_links to tensornets.egg-info\dependency_links.txt
    writing top-level names to tensornets.egg-info\top_level.txt
    reading manifest file 'tensornets.egg-info\SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'tensornets.egg-info\SOURCES.txt'
    copying tensornets\references\darkflow_utils\get_boxes.c -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
    copying tensornets\references\darkflow_utils\nms.c -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
    copying tensornets\datasets\coco.names -> build\lib.win-amd64-3.5\tensornets\datasets
    copying tensornets\datasets\voc.names -> build\lib.win-amd64-3.5\tensornets\datasets
    copying tensornets\references\coco.names -> build\lib.win-amd64-3.5\tensornets\references
    copying tensornets\references\voc.names -> build\lib.win-amd64-3.5\tensornets\references
    copying tensornets\references\darkflow_utils\__init__.pyc -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
    copying tensornets\references\darkflow_utils\box.pyc -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
    copying tensornets\references\darkflow_utils\get_boxes.pyx -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
    copying tensornets\references\darkflow_utils\get_boxes.so -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
    copying tensornets\references\darkflow_utils\nms.pxd -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
    copying tensornets\references\darkflow_utils\nms.pyx -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
    copying tensornets\references\darkflow_utils\nms.so -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
    running build_ext
    building 'tensornets.references.darkflow_utils.nms' extension
    creating build\temp.win-amd64-3.5
    creating build\temp.win-amd64-3.5\Release
    creating build\temp.win-amd64-3.5\Release\tensornets
    creating build\temp.win-amd64-3.5\Release\tensornets\references
    creating build\temp.win-amd64-3.5\Release\tensornets\references\darkflow_utils
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic:\users\bearm\anaconda3\envs\py35tf\lib\site-packages\numpy\core\include -Ic:\users\bearm\anaconda3\envs\py35tf\include -Ic:\users\bearm\anaconda3\envs\py35tf\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.14393.0\winrt" /Tctensornets/references/darkflow_utils/nms.c /Fobuild\temp.win-amd64-3.5\Release\tensornets/references/darkflow_utils/nms.obj
    nms.c
    c:\users\bearm\anaconda3\envs\py35tf\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(12) : Warning Msg: Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
    tensornets/references/darkflow_utils/nms.c(2437): warning C4244: '=': conversion from 'double' to 'float', possible loss of data
    tensornets/references/darkflow_utils/nms.c(2446): warning C4244: '=': conversion from 'double' to 'float', possible loss of data
    tensornets/references/darkflow_utils/nms.c(2496): warning C4244: '=': conversion from 'double' to 'float', possible loss of data
    tensornets/references/darkflow_utils/nms.c(22776): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
    tensornets/references/darkflow_utils/nms.c(22782): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:c:\users\bearm\anaconda3\envs\py35tf\libs /LIBPATH:c:\users\bearm\anaconda3\envs\py35tf\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.14393.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.14393.0\um\x64" m.lib /EXPORT:PyInit_nms build\temp.win-amd64-3.5\Release\tensornets/references/darkflow_utils/nms.obj /OUT:build\lib.win-amd64-3.5\tensornets\references\darkflow_utils\nms.cp35-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.5\Release\tensornets/references/darkflow_utils\nms.cp35-win_amd64.lib
    LINK : fatal error LNK1181: cannot open input file 'm.lib'
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1181

    ----------------------------------------
Command "c:\users\bearm\anaconda3\envs\py35tf\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\bearm\\AppData\\Local\\Temp\\pip-install-36vc4dxz\\tensornets\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\bearm\AppData\Local\Temp\pip-record-f7zzi1az\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\bearm\AppData\Local\Temp\pip-install-36vc4dxz\tensornets\

middle of the return strings, there are link error that
LINK : fatal error LNK1181: cannot open input file 'm.lib'
Is this error message my own environmental error or error in installation code ??

ImportError: No module named 'voc'

How to reproduce

import tensorflow as tf
import tensornets as nets

inputs = tf.placeholder(tf.float32, [None, 416, 416, 3])
model = nets.YOLOv2(inputs, nets.Darknet19)

img = nets.utils.load_img('cat.png')

with tf.Session() as sess:
    sess.run(model.pretrained())
    preds = sess.run(model, {inputs: model.preprocess(img)})
    boxes = model.get_boxes(preds, img.shape[1:3])

from tensornets.datasets import voc
print("%s: %s" % (voc.classnames[7], boxes[7][0]))  # 7 is cat

Error trace

Traceback (most recent call last):
  File "main.py", line 14, in <module>
    from tensornets.datasets import voc
  File "/usr/local/lib/python3.5/dist-packages/tensornets/datasets/__init__.py", line 1, in <module>
    import voc
ImportError: No module named 'voc'

Possible fix

Commenting out the first (and only) line in /usr/local/lib/python3.5/dist-packages/tensornets/datasets/__init__.py fixes the issue. A real fix would probably deal with absolute and relative imports though.

Environment details

python3.5
tensorflow (1.6.0)
tensorflow-gpu (1.6.0)
tensorflow-tensorboard (0.4.0rc3)
tensornets (0.3.1)
darkflow (1.0.0)

Notes for variable_scope, name_scope, and weight sharing

TensorNets provides a seamless integration with regular TensorFlow APIs. You can define any models under tf.variable_scope and tf.name_scope to couple the model with your established scripts. This document shows basic examples for tf.variable_scope, tf.name_scope, and weight sharing. First, import two libraries:

import tensorflow as tf
import tensornets as nets

Let's get started with basic TensorFlow APIs. You can manage a prefix of variable names with tf.variable_scope and tf.name_scope. The difference is that tf.Variable will be affected by only tf.name_scope, while tf.Tensor by both tf.variable_scope and tf.name_scope. Also, the second tf.get_variable('w', [1]) will try to create the same variable if tf.variable_scope(reuse=None), or return the pointer of the existing variable otherwise (reuse=True, reuse=tf.AUTO_REUSE). Here is an example:

with tf.name_scope('foo'):
  with tf.variable_scope('goo'):
    with tf.name_scope('hoo'):

      # `tf.Variable` will be affected by only `tf.name_scope`.
      w = tf.get_variable('w', [1])
      assert w.name == 'goo/w:0'

      # `tf.Tensor` will be affected by both `tf.variable_scope` and `tf.name_scope`.
      s = tf.constant(-1.0)
      y = s * w
      assert s.name == 'foo/goo/hoo/Const:0'
      assert y.name == 'foo/goo/hoo/mul:0'

      # `tf.get_variable` will try to create the same variable again
      # if `tf.variable_scope(reuse=None)` (default).
      try:
        w2 = tf.get_variable('w', [1])
      except ValueError as e:
        print(e)  # Variable goo/w already exists, disallowed.

The principle is easily extended to TensorNets. The weights returned by get_weights are tf.Variable, and the outputs from get_outputs and get_middles are tf.Tensor. Thus, the weights will be affected by only tf.name_scope, while the outputs and the middles by both tf.variable_scope and tf.name_scope. Surely, the model function call can't be performed without reuse=True or reuse=tf.AUTO_REUSE because the function will try to create the same variable again.

with tf.name_scope('xoo'):
  with tf.variable_scope('yoo'):
    with tf.name_scope('zoo'):

      # The weights returned by `get_weights` are `tf.Variable`,
      # and the outputs from `get_outputs` and `get_middles` are `tf.Tensor`
      x1 = tf.placeholder(tf.float32, [None, 224, 224, 3], name='x1')
      model1 = nets.ResNet50(x1)

      # `tf.Variable` will be affected by only `tf.name_scope`.
      assert model1.get_weights()[-1].name == 'yoo/resnet50/logits/biases:0'

      # `tf.Tensor` will be affected by both `tf.variable_scope` and `tf.name_scope`.
      assert model1.name == 'xoo/yoo/zoo/resnet50/probs:0'
      assert model1.get_outputs()[-1].name == 'xoo/yoo/zoo/resnet50/probs:0'
      assert model1.get_middles()[-1].name == 'xoo/yoo/zoo/resnet50/conv5/block3/out:0'

      # `tf.get_variable` will try to create the same variable again
      # if `tf.variable_scope(reuse=None)` (default).
      try:
        x2 = tf.placeholder(tf.float32, [None, 224, 224, 3], name='x2')
        model2 = nets.ResNet50(x2)
      except ValueError as e:
        print(e)  # Variable yoo/resnet50/conv1/conv/weights already exists, disallowed.

And we can easily implement the concept of weight sharing by using tf.variable_scope(reuse=tf.AUTO_REUSE). An example is as follows:

with tf.variable_scope('boo', reuse=tf.AUTO_REUSE):
  w1 = tf.get_variable('w', [1])
  w2 = tf.get_variable('w', [1])
  assert w1 == w2
  assert w1.name == 'boo/w:0'
  s = tf.constant(-1.0)
  y1 = s * w1
  y2 = s * w2
  assert y1 != y2
  assert y1.name == 'boo/mul:0'
  assert y2.name == 'boo/mul_1:0'

TensorNets can be also easily integrated with tf.variable_scope:

with tf.variable_scope('koo', reuse=tf.AUTO_REUSE):
  x1 = tf.placeholder(tf.float32, [None, 224, 224, 3], name='x1')
  x2 = tf.placeholder(tf.float32, [None, 224, 224, 3], name='x2')
  model1 = nets.ResNet50(x1)
  model2 = nets.ResNet50(x2)
  for (a, b) in zip(model1.get_weights(), model2.get_weights()):
    assert a == b
  assert model1.get_weights()[-1].name == 'koo/resnet50/logits/biases:0'
  assert model1 != model2
  assert model1.name == 'koo/resnet50/probs:0'
  assert model2.name == 'koo/resnet50_1/probs:0'

Summary

I'd like to say that there are two patterns to implement weight sharing:

  1. with tf.variable_scope:
with tf.variable_scope('koo', reuse=tf.AUTO_REUSE):
    model1 = nets.ResNet50(x1)
    model2 = nets.ResNet50(x2)
  1. without variable_scope:
model1 = nets.ResNet50(x1, reuse=tf.AUTO_REUSE)
model2 = nets.ResNet50(x2, reuse=tf.AUTO_REUSE)
  1. (equivalent to 2):
import functools
resnet = functools.partial(nets.ResNet50, reuse=tf.AUTO_REUSE)
model1 = resnet(x1)
model2 = resnet(x2)

And I recommend the following pattern used in deploying multiple clones in tf.slim:

with tf.name_scope('clone0'):
    model1 = nets.ResNet50(x1, reuse=tf.AUTO_REUSE)
with tf.name_scope('clone1'):
    model2 = nets.ResNet50(x2, reuse=tf.AUTO_REUSE)

for (a, b) in zip(model1.get_weights(), model2.get_weights()):
    assert a == b

assert model1.name == 'clone0/resnet50/probs:0'
assert model2.name == 'clone1/resnet50/probs:0'

Without tf.name_scope, tf.Tensor will be automatically named with a postfix-style (resnet50, resnet50_1, ...). I think that it may be difficult to manage tensor names in such cases.

tensorflow 1.3

when I use nets.pretrained(model), error happends

if scope.dtype == tf.float16:
AttributeError: 'str' object has no attribute 'dtype'

tensornets on windows 10

Hello, facing difficulties to install tensornets.

my environment is explained bellow.

OS: windows 10, windows 7
anaconda
Python version: 3.5, 3.6
tensorflow version: 1.9, 1.10
PIP version: 18.1, 10.0.1, 19.x

pip install tensornets and pip install git+https://github.com/taehoonlee/tensornets.git

Collecting git+https://github.com/taehoonlee/tensornets.git
Cloning https://github.com/taehoonlee/tensornets.git to c:\users\admin\appdata\local\temp\pip-req-build-pslh3n1z
Building wheels for collected packages: tensornets
Building wheel for tensornets (setup.py) ... error
Complete output from command c:\programdata\anaconda3\python.exe -u -c "import setuptools, tokenize;file='C:\Users\admin\AppData\Local\Temp\pip-req-build-pslh3n1z\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" bdist_wheel -d C:\Users\admin\AppData\Local\Temp\pip-wheel-kz3ibhta --python-tag cp35:
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.5
creating build\lib.win-amd64-3.5\tensornets
copying tensornets\capsulenets.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\darknets.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\densenets.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\detections.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\inceptions.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\layers.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\middles.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\mobilenets.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\nasnets.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\ops.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\preprocess.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\pretrained.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\resnets.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\squeezenets.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\utils.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\vggs.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\wavenets.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\zf.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets_init_.py -> build\lib.win-amd64-3.5\tensornets
creating build\lib.win-amd64-3.5\tensornets\datasets
copying tensornets\datasets\coco.py -> build\lib.win-amd64-3.5\tensornets\datasets
copying tensornets\datasets\imagenet.py -> build\lib.win-amd64-3.5\tensornets\datasets
copying tensornets\datasets\voc.py -> build\lib.win-amd64-3.5\tensornets\datasets
copying tensornets\datasets_init_.py -> build\lib.win-amd64-3.5\tensornets\datasets
creating build\lib.win-amd64-3.5\tensornets\references
copying tensornets\references\rcnns.py -> build\lib.win-amd64-3.5\tensornets\references
copying tensornets\references\rpn_utils.py -> build\lib.win-amd64-3.5\tensornets\references
copying tensornets\references\yolos.py -> build\lib.win-amd64-3.5\tensornets\references
copying tensornets\references\yolo_utils.py -> build\lib.win-amd64-3.5\tensornets\references
copying tensornets\references_init_.py -> build\lib.win-amd64-3.5\tensornets\references
creating build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils\box.py -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils_init_.py -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
running egg_info
creating tensornets.egg-info
writing top-level names to tensornets.egg-info\top_level.txt
writing tensornets.egg-info\PKG-INFO
writing dependency_links to tensornets.egg-info\dependency_links.txt
writing manifest file 'tensornets.egg-info\SOURCES.txt'
reading manifest file 'tensornets.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'tensornets.egg-info\SOURCES.txt'
copying tensornets\references\darkflow_utils\get_boxes.c -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils\nms.c -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
copying tensornets\datasets\coco.names -> build\lib.win-amd64-3.5\tensornets\datasets
copying tensornets\datasets\voc.names -> build\lib.win-amd64-3.5\tensornets\datasets
copying tensornets\references\coco.names -> build\lib.win-amd64-3.5\tensornets\references
copying tensornets\references\voc.names -> build\lib.win-amd64-3.5\tensornets\references
copying tensornets\references\darkflow_utils\get_boxes.pyx -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils\nms.pxd -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils\nms.pyx -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
running build_ext
building 'tensornets.references.darkflow_utils.nms' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools


Failed building wheel for tensornets
Running setup.py clean for tensornets
Failed to build tensornets
Installing collected packages: tensornets
Running setup.py install for tensornets ... error
Complete output from command c:\programdata\anaconda3\python.exe -u -c "import setuptools, tokenize;file='C:\Users\admin\AppData\Local\Temp\pip-req-build-pslh3n1z\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\admin\AppData\Local\Temp\pip-record-tgoomb1b\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.5
creating build\lib.win-amd64-3.5\tensornets
copying tensornets\capsulenets.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\darknets.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\densenets.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\detections.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\inceptions.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\layers.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\middles.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\mobilenets.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\nasnets.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\ops.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\preprocess.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\pretrained.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\resnets.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\squeezenets.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\utils.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\vggs.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\wavenets.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets\zf.py -> build\lib.win-amd64-3.5\tensornets
copying tensornets_init_.py -> build\lib.win-amd64-3.5\tensornets
creating build\lib.win-amd64-3.5\tensornets\datasets
copying tensornets\datasets\coco.py -> build\lib.win-amd64-3.5\tensornets\datasets
copying tensornets\datasets\imagenet.py -> build\lib.win-amd64-3.5\tensornets\datasets
copying tensornets\datasets\voc.py -> build\lib.win-amd64-3.5\tensornets\datasets
copying tensornets\datasets_init_.py -> build\lib.win-amd64-3.5\tensornets\datasets
creating build\lib.win-amd64-3.5\tensornets\references
copying tensornets\references\rcnns.py -> build\lib.win-amd64-3.5\tensornets\references
copying tensornets\references\rpn_utils.py -> build\lib.win-amd64-3.5\tensornets\references
copying tensornets\references\yolos.py -> build\lib.win-amd64-3.5\tensornets\references
copying tensornets\references\yolo_utils.py -> build\lib.win-amd64-3.5\tensornets\references
copying tensornets\references_init_.py -> build\lib.win-amd64-3.5\tensornets\references
creating build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils\box.py -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils_init_.py -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
running egg_info
writing dependency_links to tensornets.egg-info\dependency_links.txt
writing tensornets.egg-info\PKG-INFO
writing top-level names to tensornets.egg-info\top_level.txt
reading manifest file 'tensornets.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'tensornets.egg-info\SOURCES.txt'
copying tensornets\references\darkflow_utils\get_boxes.c -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils\nms.c -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
copying tensornets\datasets\coco.names -> build\lib.win-amd64-3.5\tensornets\datasets
copying tensornets\datasets\voc.names -> build\lib.win-amd64-3.5\tensornets\datasets
copying tensornets\references\coco.names -> build\lib.win-amd64-3.5\tensornets\references
copying tensornets\references\voc.names -> build\lib.win-amd64-3.5\tensornets\references
copying tensornets\references\darkflow_utils\get_boxes.pyx -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils\nms.pxd -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
copying tensornets\references\darkflow_utils\nms.pyx -> build\lib.win-amd64-3.5\tensornets\references\darkflow_utils
running build_ext
building 'tensornets.references.darkflow_utils.nms' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

----------------------------------------

Command "c:\programdata\anaconda3\python.exe -u -c "import setuptools, tokenize;file='C:\Users\admin\AppData\Local\Temp\pip-req-build-pslh3n1z\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\admin\AppData\Local\Temp\pip-record-tgoomb1b\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\admin\AppData\Local\Temp\pip-req-build-pslh3n1z\

Kindly help

Anaconda python 2.7

Command "C:\Users\User\Anaconda2\python.exe -u -c "import setuptools, tokenize;file='c:\users\user\appdata\local\temp\pip-install-jarbs8\pybluez\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record c:\users\user\appdata\local\temp\pip-record-rosdw0\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\user\appdata\local\temp\pip-install-jarbs8\pybluez\

Comparison of different networks: failed with error

used your code as it is to compare multiple nets and get this one
tried with the version your provided hours ago on windows


TypeError Traceback (most recent call last)
in ()
10
11 with tf.Session() as sess:
---> 12 nets.pretrained(models)
13 for (model, img) in zip(models, imgs):
14 preds = sess.run(model, {inputs: img})

c:\anaconda3\lib\site-packages\tensornets\pretrained.py in assign(scopes)
56 model_name = parse_scopes(scope)[0]
57 try:
---> 58 load_dictmodel_name
59 except KeyError:
60 try:

c:\anaconda3\lib\site-packages\tensornets\pretrained.py in load_mobilenet75(scopes, return_fn)
511 cache_subdir='models',
512 file_hash='d4557a46a44eebfeaf08c82ae33765ed')
--> 513 values = parse_weights(weights_path)
514 return return_fn(scopes, values)
515

c:\anaconda3\lib\site-packages\tensornets\utils.py in parse_weights(weights_path, move_rules)
291 if later_tf_version:
292 for (i, name) in enumerate(data['names']):
--> 293 if '/beta' in data['names'][i-1] and '/gamma' in name:
294 values[i], values[i-1] = values[i-1], values[i]
295

TypeError: a bytes-like object is required, not 'str'

Model load issue

Hello,

I was trying to test your code and got stuck on loading models. See full log:

Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul  2 2016, 17:53:06) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> import tensornets as nets
>>> import numpy as np
>>> 
>>> print(tf.__version__)
1.3.0
>>> print(np.__version__)
1.13.3
>>> 
>>> inputs = tf.placeholder(tf.float32, [None, 224, 224, 3])
>>> outputs = tf.placeholder(tf.float32, [None, 50])
>>> model = nets.Inception4(inputs, is_training=True, classes=50)
>>> 
>>> loss = tf.losses.softmax_cross_entropy(outputs, model)
>>> train = tf.train.AdamOptimizer(learning_rate=1e-5).minimize(loss)
>>> 
>>> with tf.Session() as sess:
...     nets.pretrained(model)
... 
2017-11-15 21:14:22.616901: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-11-15 21:14:22.616976: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-11-15 21:14:22.617005: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-11-15 21:14:22.767544: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:893] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2017-11-15 21:14:22.767871: I tensorflow/core/common_runtime/gpu/gpu_device.cc:955] Found device 0 with properties: 
name: GeForce GTX 1080 Ti
major: 6 minor: 1 memoryClockRate (GHz) 1.582
pciBusID 0000:01:00.0
Total memory: 10.91GiB
Free memory: 355.38MiB
2017-11-15 21:14:22.900139: W tensorflow/stream_executor/cuda/cuda_driver.cc:523] A non-primary context 0xbea1700 exists before initializing the StreamExecutor. We haven't verified StreamExecutor works with that.
2017-11-15 21:14:22.900342: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:893] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2017-11-15 21:14:22.900694: I tensorflow/core/common_runtime/gpu/gpu_device.cc:955] Found device 1 with properties: 
name: GeForce GTX 1080 Ti
major: 6 minor: 1 memoryClockRate (GHz) 1.582
pciBusID 0000:02:00.0
Total memory: 10.91GiB
Free memory: 400.44MiB
2017-11-15 21:14:22.900850: I tensorflow/core/common_runtime/gpu/gpu_device.cc:976] DMA: 0 1 
2017-11-15 21:14:22.900869: I tensorflow/core/common_runtime/gpu/gpu_device.cc:986] 0:   Y Y 
2017-11-15 21:14:22.900881: I tensorflow/core/common_runtime/gpu/gpu_device.cc:986] 1:   Y Y 
2017-11-15 21:14:22.900899: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1045] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:01:00.0)
2017-11-15 21:14:22.900914: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1045] Creating TensorFlow device (/gpu:1) -> (device: 1, name: GeForce GTX 1080 Ti, pci bus id: 0000:02:00.0)
Traceback (most recent call last):
  File "/shared/miha/programs/miniconda3/lib/python3.5/site-packages/numpy/lib/format.py", line 640, in read_array
    array = pickle.load(fp, **pickle_kwargs)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb1 in position 0: ordinal not in range(128)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/shared/miha/py_homebrew/tensornets/pretrained.py", line 49, in pretrained
    __load_dict__[model_name](scope)
  File "/shared/miha/py_homebrew/tensornets/pretrained.py", line 101, in load_inception4
    return load_weights(scopes, weights_path)
  File "/shared/miha/py_homebrew/tensornets/utils.py", line 166, in load_weights
    values = data['values']
  File "/shared/miha/programs/miniconda3/lib/python3.5/site-packages/numpy/lib/npyio.py", line 233, in __getitem__
    pickle_kwargs=self.pickle_kwargs)
  File "/shared/miha/programs/miniconda3/lib/python3.5/site-packages/numpy/lib/format.py", line 646, in read_array
    "to numpy.load" % (err,))
UnicodeError: Unpickling a python object failed: UnicodeDecodeError('ascii', b'\xb1\xe0\xd7\xad\xdbf\x93\xae\xdcS\x90\xbe\x1d\x8f!?\x81\xdd^\xbf\x9a`\x9f=di\xae\xae \x07\x95.\xec\xcc\xc4\xbd\xa93\xaa\xae\x9d\xac\xef\xbd\xf1H<<\xa4,K?mz\xd8=RP\xcb.\xae\xad\xe1=ML\xa5.\x1e\x91\xff\xaeL\x11\xd4\xbe\xe2\xaa\xa0\xae\xd2\xeb\xa7\xbe\x84;\xb2>(\x1c\x02\xaf\x11\n\x00\xael\\\x88>\xea-Z\xbd@\'\x0f\xbdQ\x02\xb5\xae\x81n\xa5\xbe\xa5\xddU\xab"\xf8\x00/Z1\x92=v\xab\xb3.\x85\x06\xb2\xae|i\xf1\xbc\x93\xb5I?\x9c\x8b\x86\xbf\x873>=\xb9\xb9\x94\xaeQ!\x10\xaf\x00t>\xbe\xba\x80\x1c.\xa6F\x8e>\xa5\xb6\x01>\x15.S?\x01\xad]\xbe\x93\xe5\xe6.\xe3\xa2\xa2\xbe\xc2\xc7\x9c.,\xec\x10\xaf\xa5\x07\xd4=\x1e\x07\xba\xae\x8bW\x92>\x0e3h\xbe\xf3w\n\xaf\xd2s\'\xaf\x1e\xbf\x92\xbd\xa8\x82\xb8\xbd#\x12\xc6\xbc\xb9\xa2\xa1\xae\xad"t=\xae\x82G/\xb1L\xb3.\x19\xa8|\xbd<\x8f\xbb.\xaaE\x89\xae\xaco\x9c>i\x1b\x9c>\xde\x8c\x17\xbf\xa1k\x7f\xbd\xea\x13\xaa\xaet\x95^\xaf\xd0\x04\x04\xbex\xc2\x12\xafr\x08b\xbey\xe6\xb7\xbd\x1b\'\x17?\xe8\x823=p\x9e\x91.\x1byW>"\xf4\xe7\xae\xd8b\x8a\xad?]&>H\xf7\x94.\x7f\x0f\xa7>C+V\xbeP\x1f\xf2\xae+\xa1\xe3\xae\x0cC;\xbe\xa6\xe2\x95=\xac7C=\x05K\xb7\xae(\xcf\x90>\xf0(x\xae\xd0\xe3\xec\xad\xb7\xde\xe8\xbd|\x9cH\xae\xa2\x97\xae\xae\xb0e\xc9\xbe)\xb0\x9b\xbe\\\x16+>PG\xaa>\xe7\x87\xf4\xaej\x10\x98.(\\\x80>\'\x98\xab\xaeO\xcfl\xbe\x91\xf9\x87>\x03\xb68?\xe3q\xc6>\xf8P\xeb.\x92\xaa\x85>\x91\x82\x90\xaeNY\xd0\xac\x01\x8d\xcd>\xc0\x0c\xc5.\x0c<\xfb=\xaa\xa2\xe1\xbe\xb7B\x9f\xae\x95`\x8b\xae\xf5r\x13?\xc6*\n\xbf\x84\xb8M>\x8cg\x97\xae\xb6^\r\xbd\xbe\xaf\x1d\xad\xeen\xfd+\xdaT:>\xed\x17\xbc.\x1c>\xd1\xae$\x87\x9c;\'\xf6\xd6\xbe\xc5x\x05>W\x95\x14\xbe\x1a\x86\xa5\xae\x87"\x0f\xaf7Z\xfc>\xc7@\n.\x02\xcdr>\xb5\xf7o>\x1c\x13i?\xec8\x05\xbf\nM\xcc\xad\xebV\x05\xbf\x19\xfd\x0b\xae\x98\xd3\xbf\xab\x03\x04\x85=\xd9\x98\xa6\xae\x88\x8b\xe1\xbeB\x8a\xa4\xbe\xdb\xd0\xef\xae]\xa8A\xaf\x80\xad\x1e\xbeX;\x02\xbf\x0e$\x8f>^\x1a\xfd\xad\xdd\x7fm;7\x19F/\x1d\x19\xf7.v\xcd\xa2<\xbed\xe4.\xb0;\xcb\xae;}\xe1>L,P\xbeL{\xa7=\xf4\x83\xab\xbei\xe0\xc9\xae\xb4\xb5V\xaf\xde]\x89>^\x16\x15\xaf \xac\xcf\xbed\xa7\xff\xbe\x08N)?\xfd^\xfd=n\xc3\xa7.\x06\xf7\x07>\x9c\xccs\xaeU=\xc0+\xb8\x027\xbexv\xa3.\xd63J\xbe\xf0\x96\xbe;*\xc5\xe8\xae\x02X\xed\xae|E\xb4\xbek\xfa\x89\xbe\x8c\\\x98>\xc5\x97\xac\xae\x7f\\\'<\xc9Dp\xae\x0e\xa0\xbf\xad\x8f\x99\x9a\xbcF(\x12.?\x0c\x07\xaf\x0b\x17\xa2\xbeR4-\xbeJ\x99\x1d?\xb6\xa2D>\xc3K\xee\xae\xcf\x0f\xca.z%+>kz\x91\xaeX\x01\xb9\xbd\n\xd3\x80>#\xd6\xf0>\xcd8\x82>\x94k\x14/\x90\xd7\x12>\xd6\x01v\xaeQU\x04\xaf\x9e\xaa\x04?\x91\xf6\x98\xae\x1f#\r?\\\x98\x1b\xbf\x95\x8c\xa3\xad\x10`\xa6.\xed\x9e\xda>fr\x81\xbf\xa1\xeb\x1b?\x99(\x88\xae\x884\x0f\xbe(\xbc]\xadP\xe7\xf2.~\x12\xce=\xa4\xde\xb6.\x1b\x0e\xdd\xae*\xaf\x83\xbaX\xe6\xb5\xbe\x8cjH?\xcfs\x0e\xbe\x0c\x1a\xbd\xae2a\x90\xad\x8a\xbb\xc0>\xc9\x82-.\xebj:>\x85\xda\x94=\xeca&?\xd4\xa2\x81\xbe\xc4\xaa\xfa\xac\xf0o\xa8\xbe\x8e\x85\x0e\xaeL{\x87\xacR\xeb\xca\xbeA\n\x9f\xaeY[\xe2\xbe\xbek\\\xbe\x0e\xb7\xc2\xaeS\x13\t\xaf\xc0\xbc\xd5\xbd\x9a\xdeh\xbf$\x1e+?e\x00e\xaeQ\x1d=<\xb6\xf9)/c*\xb1.\xe7Io\xbd~\x94\xc2.!\xe3[.(\x98\x91>\'\x93\xe7\xbc\xd5\xa1\xad>\x82H$\xbe1k\xbc\xae%+\xfd\xad\xbe\x14\x8b>\xc0\x1a\x18\xaf\xee;<\xbe\xf4X\x82\xbe\x1e\\\xce>\x955 \xbcH\x17\xb3.\x9c\x0f\x8b==*j\xae\x02`x\xab\xbc\xdd\xe9\xbeuS\x92\xae\xe5J\xda\xbeP\x1f\xd6=\xb2\xb0\xdf\xae\xa6 \xf8\xae\x11\x85l\xbe\x9e\x8d%\xbf\xda\xdc\x1b?^\xe4\x94\xaeg\xc7\x04>\xe2w\x8e\xae_Y\r/\xe8\xe1\xc0\xbd?\xa8\xbf.\xde\x05\x88\xaek`\xc6\xbe\xaekB?\x93\xcb\\\xbf\xbc|\xce>T\xf2$.\xcc\x12y-\x96\xa4\xce\xbdn"\xb5\xae\x01\x15\x00\xbe\xb7\xf1Z>\xeeW=>\x01\xae\xa5>L\xa2\xc5.gW\x8e>\xa8\xc3\x05/\xc3\x0c\x8d-b0<\xbe\xce\xab\xb8\xae\xa2\xff\x0b\xbfR^\x02=\xaa\xe4\xe8\xaep\xaa\xfe.Y\xa8\x13?Y\xa7I>\x00t\x00\xbf?\xcd\xac\xae\xe0\xff\xad>\xe7\xf4\xee.\xbcZ\xec.+\xee\x10>\xe2\xe2\x9e.\xfd\xfa\x8f\xaew|\x0c\xbdy\xb3e?\xad\xb5\x82\xbf\xb4\xd7\xce\xbd\xa91\xaf\xae\x94t\xea\xae4\xc6:\xbem\xc3\x99-J*\x8f>\xf1\xaft>\x96f\x12>ZE\x02\xbf\xf5\xad\xb6.\x9a1\xe5\xbe\xe7\x1c\xe5.\x89\x11\xfd\xadt\xc2\x82>\x94\xcd\xb4\xae\xfbCq\xbdDd\x17\xbe\t\xaa\xdf\xaea\x9f\x04\xafx\xedH\xbe-\x9e;>D~\xd9\xbe\xea(\xaf\xae\xc7bK\xbed6\x16/N\xd8\xaa.S\x98"\xbdd\xc9\xa8.\xba8\xf0.I\x9b\xdd>S\xe2\xb7>\x90\xf4\xfe\xbe\x15\xc1\xd4\xbe\x87\x98\xbd\xae\'\x11@\xafv\xd3:\xbe\xbc \x10\xaf \xd6\xbd\xbe/>\xee\xbe\xd5\xa3\t>\x05\xcd.>6\x95\x8d.Pd\xd2=\x01\x0e\x9e.\x93\r\xf4-\xb3\x02a>\xdc\x0c\xad\xae:\xd5\x01>\xae]\x12\xbeV}\xf8\xae}\x99\xe9\xae\x1c\xb4\xca\xbeY\xb7\x80>\x02\x8bp\xbe%\x15\xb4\xae\xc7yO\xbe\xac\xfe\x83\xad\xc9\xdbl\xad_\xe4\xb7\xbc\xcd\xab\x8b.\x1d\x99\xd3\xae|\x0e\x07\xbf(\xe2\x8b\xbe=\xb1\xe1<\x9bi"?q\xb2l.\xf8\xa8\x1a\xad\xbfo\x8f\xbdx=\xb0\xae\xee^2\xbeR\xe4\x06?\x0b`)=\xb4\xc62?\xe9\xc8\xcd.\x01\xf7\xbe>\x84-\xed.Z\x01\xe2\xae\x10\x96E?\xb5Q\x99\xaeXl\xfd\xbd\xba\x1b\xa8>\xdex\x9a\xae1\x86\xad.\'fR?\xff!H\xbe\x86\x05\x94\xbe\x15\x9b\xb3\xaeB\xd2B?\xe0\xfe\x8f+Fz\xe0,_T\x98>\x03\x88\x95.\xe9\xf8\xc3\xae}\x0cI\xbd\xb0M\xd1\xbe\xabXX\xbb\x03\xd0o\xbe#I\xa2\xae-\x94\x0f\xaf\xff\xdaZ=\xa8\x06\x98\xad\x14@\xaf>\xf1\x94\x14?\x05\xc1\x8c=\x9fyE\xbfA\xff\xc7.\xcc\x84H\xbf\x9fs\xfe.q\xec\x01\xaf\xf8I\'?\x11_\xa9\xae\x0cH\xd6\xbe@FV?h\xf9\xc5\xae\x85\x19\x0f\xaf>\x8e\x93\xbe\x82{.\xbe\x9f\xe2\x94\xbe\x07\x14\x7f.\x8c\xc2\x9d\xbeO\x1cC/a\xb6\x1f\xad\x04\xf5\x97=|\xad\x94.\x8f4\x93\xae\xa4s\x0c?\xb0\xa8(\xbe\x8c\xd9D<\x95\xa0\x1b\xbf\x1b\xe0\xbb\xae\xf6\xc7R\xaf\xea\x0bd=N\x88\x16\xaf+\xff\xff\xbe^\x93^\xbf\xb2&\xb3=\xc3\x8b\xc4>\x9a\xf7\xa9.\x1ev\x00=U5\x88\xae\xd3"c*\x12I,>?\xdao\xae\xcd\x02G\xbe\xdb\x10\x08?\x12\x1b\xcc\xae>{\xea\xae2\xd7\x10\xbfg\xb0t\xbbn\x8b\xdb\xbd\xcd\xe9\xd3\xae\xbfZ\x07\xbft?Y\xae\xc9*\x1a\xadR\x80\x15>\xcd\xa4\xcb.u \x06\xaf\x17\xf0\xbb\xbe\xfd\x95\xe8\xbe\xd6\xe5D?\xa0\xbd\x96>\x9a\x15:.\x11b\xe0.\xc0\xa52\xbf\x17a\xbe\xaeX\xfb\xe4\xbd u\xbc>H%z\xbd\x8fO\xc7>x\x8a\xec.2\nv>e\x89\xdb.\xaa\xe2\xfc\xae\x87\x83\x9d>,\xd6\x97\xae$q\x0f?\xba\x82\xdf\xbdK\xbd\x81.\x8e\n\x9d.$\t\x0b?\xfd\xfa\x0e\xbfz\xba(>\xbd\x01\xa7\xae\xffl*\xbb\xc5y\',\'_\x0b/$\xa4G>\xb0\xf0\xb4.Nw\xc9\xaeE`L\xbd\x93\x8c+\xbf\xa9g|?w\xc6\x04\xbe\xbe$\xad\xaeN\x8a!\xaf\x81\xb6G\xbfX\xc9G\xadQel>\xe7\xce\x96>e\xf0Q\xbc\x03\xd5\xf9\xbe`\xc0\xf0.\x05\xfb\xf0\xbe\xc7`\xf9.\xa3\xe6\x96\xab4\x90\xcf\xbe\xf5\x81\x97\xae\xfe\xe2\xa6\xbd\x7f\x16\xa8>.\xba\x00\xaf\x04\xe1\xdd\xad?\x02\x1f\xbeC\xbd\xfc\xbe\xd4\x03\x05>\x13\x98\x97\xae=\xff\x15\xbd\xed\x159/\xc9\xda\xe7.\xca\xcan\xbcMy\xa0.\x9a\x12\x8d.\xb7\xa7\xc6>\xd2U4\xbe\x86\xae\x05?3\xc3\x93\xbe\xd2Y\xbd\xae&\x8c*\xaf\xb0H\x97\xbe\x0f\x19%\xaf\xa9\xca\x90\xbe\xa3\xf2\x06\xbf\xd6g\x9b\xbc!)U>,v\xab.\x81\xf8\xa4=\xcd\xc1\xb0\xae]\x8b\xf8*\x89d\xc9\xbe\x10\xc0\x91.|`\\\xbe(\xfe\x86><\n\xf6\xae\xef\xfb\x02\xafL\xfc\xad\xbe1U\x9d\xbe!\xe6B>\xa7\x1f\xb3\xaeX\x0cq\xba;\xfe\x87\xae\x9c7\xcf-[\x7f\x08=~\xb1\x03/\xdc:\xc4.T\xfa\x9a\xbe\xfdJ\x89\xbd+m%\xbe\xbf\x1e\xa9>\x1b\xa9W.e\xd1\x9f.\xf2\xeej>qz\x90.\x0c\xaa\xc6<\xc3\xe8\x18>\xfb\xe38\xbf,\xd0@>\xd0\x01\xbd.W\xff6>\x07\xca\x03/&\xee3.+\x00\x06\xbf\x07\xe6\xac\xae\xb5:\xe1\xbd\x1fM\x83=\x07\x82\xf9\xae$\xf3\xa2.\xd9\xa5\xfb>\xf6\x13\x16?\x17.i\xbfU2\xac\xae\xc7\\\xce=\xea\xfe\x10/\x0e\x85\xd2.`\xf3\x0b>e\x0b\xc6.:sz.y\xb7\xfa\xbb\x18\x80I>\x062\x8d\xbe\xe7,\xda\xbd\x1b\xc9\xa2\xae\xa4\xec\x0b\xaf\x9d\xef\x14>$\x02%.x\xd2)>u\x07\x92=\xb4\xb5`\xbf8\xf1@\xbe2\x1e\x93.\xcf\xbd~\xbe!\xc4\xf8.\xa7\x07.-\xbboJ\xbe\xa6\xd4\xcf\xae\xfe=v>\x8e\x940\xbe\x0c\xb7\xda\xaeC\xc0\xde\xad?4\x0b\xbe>%\x11?\x90\xdaJ\xbf\xad{\xba\xae\xd6\x03\xf6\xbdfx\x0e/a~\xbe.\xd5:\x94\xbd\x06\xb5\xbb.\x8f"\xb5.\x0b\x7f\xbe>(\x86\xc0\xbd\xdc\x17\x9b\xb8\x01\r\xa8\xbe\xc6\x08\xb0\xae(GB\xaf\xef\x17\x90\xbdb\x02\x8f\xaeV,@\xbe\x9aY7\xbeX\x94\x16\xbf\x89\xf1\xfe\xbb\xb3\xc7\x89.\xb74p=\xd7\x92\xe4.\xa3\x15F.\xcb\xee\xfd=\xccu\x10. \x99\x14>8\xaab\xbeo\x95\xd6\xaeD\xc8\xfb\xaeZ]\xb7\xbeK\xf0\x11?\xfa\x12\x08\xbf|\xb4\xc7\xae\r\x04\x10\xbb.\x1ch.\x8a\xaax\xad)\xa3\xf9\xbc\xbfO&\xae\xec\xedE.\x80\x89\xc6\xbe\x93\xbc\xa7\xbd\x1d\xd1\xae\xbd\x85w\xd0>/oL.q`\x9a.\x98R\t?k\xbd\x90.\xae\xd3\xa6\xbdk\xa1\x8e>\xe5\xadM\xbf\x02\xa6\xbf>s\x0e\xd1.f\x8a\x85>W`\x00/\xd1T\xef\xae$u\xc3\xbe\x8b\xfe\x91\xae\x17\xb4\x10>\x91\xf9\xbb>\xea\r\xe8\xae~\xa2\xad.3,\x13?R\x85.>\xf0\x9b\x14\xbf\xcbr\xd2\xae8\xc6\x01?\x04\xfd\xea.\xa7L\x10/\xefH\x84>;\xa8\x9c.\xbe\x9f\r\xae\xd0\x94]\xbd\xd2\xbc\xd4<\np\x08\xbe\xa9\xf8\xa0\xbd\xca\xc7\x8b\xac\xb1\x1b"\xafn\x15\x1c?q\xd6\n.N\xa1f>3\x94\x9b>0\x1f~\xbf\xeb\t\xf1\xbe\x05)\xb7.\x100\xf4\xbeJf\xe5.\x06\x1b\xc2\xad\x85M\x8e\xbd=]\xa7\xae\xd1\xe0,?\xf2@\xb0>\xdd-\xca\xae\xdbC\xd4\xad\xcc%\x15\xbe\xb4Y@>#z\x19\xbf:\x83\xb2-\te\x82\xbe{\t\x1b/\xa1\x0e\xe2-\xb2\x10\xa4<\xf7\x9f\xa3.\xed%t.\xdby\xd9>\xdf\xf0I\xbd~\xdd\xbe\xbdm(\xab\xbe,\xb1n.\x03\xcc+\xaf\xb6\xb8x>\x87\x96\x11\xae\\I\x8a\xbe\x94\xf8\xd6\xbe\x18M+\xbfj\x01/>\x86\xd2\x8d.\x82Ao=@Q\xbb.\xcc\x95\x17-\x0f\x82\xd8=\xc0\'$\xae\xee\xc5\xa8>\x91\n\xa6=xq\xbb\xaeC\x15\xe3\xae\xd4\xba\xcb\xbe\xd6\xa5g>\x17\x18\xa9\xbe\x985\xfb\xae\xb6\xcc\x9b\xbe\xdf\xd2\x94\xae`\xad\xb9,\xc3_\xca=\n\x91\xc7\xad\x08\r\x99\xae\xe9\xccn\xbe\xa3f&\xbd6\x81\xd5>\xc7\xbe)<)Sd.\xf4X\xa9\xad\xd1$\x81\xbe!\xcd{.\xe5eg\xbcc\xaf\x18=\x04\x19)\xbfe6d=\xcd\x14\xe9.T\xae\xf7=\x82m\xfc.KG\xeb\xae{8\xd7\xbe\xa6\xa2q\xaeT\x88}\xbe\xd6\xb71\xbd\x80j\xe2\xae\xbaQ\xa4.\x87\xd2?>a\xa5\x0f\xbd!Y\xc4\xbdL#\xc9\xae\xbf\xb6\x81\xbeh|\x0c/\xf4\xb8\xaa.\x07u\'>\xb4_\xdc.\x89K\xc2\xae"\r]\xbdE\xa3\xa7\xbd\xf76\x0c?\x01\x92r=\xae\xb69\xae\xd9\x7f\x0e\xaf5\x17\xff\xbe\x01\x18\xc1-m\x84A>\x95&S=~lD\xbfa\xc6\x8b\xbe\xfd^\xef.`\xcbA\xbe\xd3p\n/5\x04\x0e\xaf\xe5\x97\xcc\xbc(U\xa0\xae\xc8>m>\x07\xb8\xce\xbe/\x15\xd4\xaeP\xcc\x16\xaev\xcf\x95\xbdR\x84\x87\xbcrC\x1c\xbe\xd8\xa06.\x11\xd56\xbb4\x0f\x1d/\x92\x10\xa1.<\xdc]\xbd\xda\xdb\xd4.:\xa7|.\x1c\xb2\x90>\xcd\x1bC<\x840\x7f>q\xe6\x83<\x93\xfdL.%\x10N\xaf\xf5\xeb#\xbe\xa1\xbe\x1a\xae\xca\x0c\x97\xbd\xcdPf\xbeq\xae\x16\xbf\xa0\xd6\x1d=\xa3\x8e\xa1.\x1b\xfdi>\x82L\xbc\xae?\xbb#\xae\xd6c]>\x8e4\xa1\xac\t\xf9\x88=s"\xbe\xbe\x92s\xd3\xaen%\xf3\xaew\x9fe\xbe+\xb6\xa2=\xf1OI\xbc\x1en\x00\xaf\x13\x05\x85>\x8a%\x83.\xff\x99\xdb\xac\x98S\xcc\xbb', 0, 1, 'ordinal not in range(128)')
You may need to pass the encoding= option to numpy.load

I'm using the latest version of tensornets. Any clue why this is happening?

Minor issue with name scopes

Hello,
I've noticed a minor issue when using name scopes (mostly for Tensorboard visualization). For instance the following code raises an error in the utils.var_scope wrapper:

with tf.name_scope('A'):
        with tf.variable_scope('B'):
            x = tf.placeholder(shape=(None, 1024, 1024, 3), dtype=tf.float32)
            y = tensornets.MobileNet100(x, stem=True)

It seems the problem comes from line 243 where _scope = tf.get_variable_scope().name only looks at variable scope while the tf.get_collection(..., scope=_scope) at line 124 look through variable names.
It can be solved by replacing line 243 with _scope = tf.contrib.framework.get_name_scope(), but I'm not sure if it's the best workaround.

'odict_keys' object does not support indexing

When I execute the following code:

In [1]: import tensorflow as tf
/usr/software/anaconda3/lib/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: compiletime version 3.5 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.6
  return f(*args, **kwds)
imp
In [2]: import tensornets as nets

In [3]: inputs = tf.placeholder(tf.float32, shape=[1, 224, 224, 3])

In [4]: model = nets.DenseNet121(inputs)

In [5]: with tf.Session() as sess:
   ...:     nets.pretrained(model)

I encountered the following errors:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-6-ba1220a3288a> in <module>()
      1 with tf.Session() as sess:
----> 2     nets.pretrained(model)
      3 

/usr/software/anaconda3/lib/python3.6/site-packages/tensornets-0.1.0-py3.6.egg/tensornets/pretrained.py in pretrained(scopes)
     47         model_name = parse_scopes(scope)[0]
     48         try:
---> 49             __load_dict__[model_name](scope)
     50         except KeyError:
     51             found = False

/usr/software/anaconda3/lib/python3.6/site-packages/tensornets-0.1.0-py3.6.egg/tensornets/pretrained.py in load_densenet121(scopes)
    280         cache_subdir='models',
    281         file_hash='9817430b1d3634645f6b04b8c663c34f')
--> 282     return load_torch_weights(scopes, weights_path)
    283 
    284 

/usr/software/anaconda3/lib/python3.6/site-packages/tensornets-0.1.0-py3.6.egg/tensornets/utils.py in load_torch_weights(scopes, weights_path, move_rules)
    203     for (i, name) in enumerate(names):
    204         if 'running_mean' in name:
--> 205             names[i-1], names[i-2] = names[i-2], names[i-1]
    206 
    207     values = []

TypeError: 'odict_keys' object does not support indexing

How could I solve this problem? Thanks!

The output problem of sharing weights.

I use the code like below,

...
resnet = partial(tensornets.ResNet50, reuse=tf.AUTO_REUSE)
outputs_1 = resnet(x_1).get_outputs()
outputs_2 = resnet(x_2).get_outputs() 
...

outputs_2 appends the outputs of x_2 to outputs_1.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.