Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Lee__C_
Beginner
91 Views

Running Darknet VGG Model on Intel NCS2

Hi,

I currently have a VGG model in Darknet framework (model in .cfg and weights in .weights) and the goal is to run that on the Intel NCS2.

I have attempted to use the DW2TF tool available on github to convert to tensorflow format then to convert to IR format, but was met with error upon execution.

This was the command I used.

python3 main.py\
--cfg data/vgg-16.cfg\
--weights data/vgg-16.weights\
--output output\
--gpu 0

Below is the output from the program

0 Tensor("network/net1:0", shape=(?, 256, 256, 3), dtype=float32)
=> Ignore:  {'name': 'crop', 'crop_height': '224', 'crop_width': '224', 'flip': '1', 'exposure': '1', 'saturation': '1', 'angle': '0'}
1 Tensor("network/net1:0", shape=(?, 256, 256, 3), dtype=float32)
2 Tensor("network/convolutional1/Activation:0", shape=(?, 256, 256, 64), dtype=float32)
3 Tensor("network/convolutional2/Activation:0", shape=(?, 256, 256, 64), dtype=float32)
4 Tensor("network/maxpool1/MaxPool:0", shape=(?, 128, 128, 64), dtype=float32)
5 Tensor("network/convolutional3/Activation:0", shape=(?, 128, 128, 128), dtype=float32)
6 Tensor("network/convolutional4/Activation:0", shape=(?, 128, 128, 128), dtype=float32)
7 Tensor("network/maxpool2/MaxPool:0", shape=(?, 64, 64, 128), dtype=float32)
8 Tensor("network/convolutional5/Activation:0", shape=(?, 64, 64, 256), dtype=float32)
9 Tensor("network/convolutional6/Activation:0", shape=(?, 64, 64, 256), dtype=float32)
10 Tensor("network/convolutional7/Activation:0", shape=(?, 64, 64, 256), dtype=float32)
11 Tensor("network/maxpool3/MaxPool:0", shape=(?, 32, 32, 256), dtype=float32)
12 Tensor("network/convolutional8/Activation:0", shape=(?, 32, 32, 512), dtype=float32)
13 Tensor("network/convolutional9/Activation:0", shape=(?, 32, 32, 512), dtype=float32)
14 Tensor("network/convolutional10/Activation:0", shape=(?, 32, 32, 512), dtype=float32)
15 Tensor("network/maxpool4/MaxPool:0", shape=(?, 16, 16, 512), dtype=float32)
16 Tensor("network/convolutional11/Activation:0", shape=(?, 16, 16, 512), dtype=float32)
17 Tensor("network/convolutional12/Activation:0", shape=(?, 16, 16, 512), dtype=float32)
18 Tensor("network/convolutional13/Activation:0", shape=(?, 16, 16, 512), dtype=float32)
19 Tensor("network/maxpool5/MaxPool:0", shape=(?, 8, 8, 512), dtype=float32)
=> Ignore:  {'name': 'connected', 'output': '4096', 'activation': 'relu'}
20 Tensor("network/maxpool5/MaxPool:0", shape=(?, 8, 8, 512), dtype=float32)
=> Ignore:  {'name': 'dropout', 'probability': '.5'}
21 Tensor("network/maxpool5/MaxPool:0", shape=(?, 8, 8, 512), dtype=float32)
=> Ignore:  {'name': 'connected', 'output': '4096', 'activation': 'relu'}
22 Tensor("network/maxpool5/MaxPool:0", shape=(?, 8, 8, 512), dtype=float32)
=> Ignore:  {'name': 'dropout', 'probability': '.5'}
23 Tensor("network/maxpool5/MaxPool:0", shape=(?, 8, 8, 512), dtype=float32)
=> Ignore:  {'name': 'connected', 'output': '1000', 'activation': 'linear'}
24 Tensor("network/maxpool5/MaxPool:0", shape=(?, 8, 8, 512), dtype=float32)
Traceback (most recent call last):
  File "/home/acusensus/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1628, in _create_c_op
    c_op = c_api.TF_FinishOperation(op_desc)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Can not squeeze dim[1], expected a dimension of 1, got 8 for 'network/softmax1/Squeeze' (op: 'Squeeze') with input shapes: [?,8,8,512].

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 112, in <module>
    main(args)
  File "main.py", line 53, in main
    parse_net(args.layers, args.cfg, args.weights, args.training)
  File "main.py", line 33, in parse_net
    training=training, const_inits=const_inits, verbose=verbose)
  File "/home/acusensus/usb_accel_proj/DW2TF/util/cfg_layer.py", line 198, in get_cfg_layer
    layer = _cfg_layer_dict.get(layer_name, cfg_ignore)(B, H, W, C, net, param, weights_walker, stack, output_index, scope, training, const_inits, verbose)
  File "/home/acusensus/usb_accel_proj/DW2TF/util/cfg_layer.py", line 169, in cfg_softmax
    net = tf.squeeze(net, axis=[1, 2], name=scope+'/Squeeze')
  File "/home/acusensus/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 488, in new_func
    return func(*args, **kwargs)
  File "/home/acusensus/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py", line 2573, in squeeze
    return gen_array_ops.squeeze(input, axis, name)
  File "/home/acusensus/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/ops/gen_array_ops.py", line 8236, in squeeze
    "Squeeze", input=input, squeeze_dims=axis, name=name)
  File "/home/acusensus/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "/home/acusensus/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 488, in new_func
    return func(*args, **kwargs)
  File "/home/acusensus/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3274, in create_op
    op_def=op_def)
  File "/home/acusensus/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1792, in __init__
    control_input_ops)
  File "/home/acusensus/anaconda3/envs/py36/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1631, in _create_c_op
    raise ValueError(str(e))
ValueError: Can not squeeze dim[1], expected a dimension of 1, got 8 for 'network/softmax1/Squeeze' (op: 'Squeeze') with input shapes: [?,8,8,512].

 

It would be great if someone can recommend any methods which can allow me to run the VGG Darknet model on the Intel NCS2 devices.

One potential fallback solution I have considered is transitioning to another framework which is more readily supported by the model optimizer. For example, tensorflow or caffe.

 

Thanks for taking the time to read over the post.

Lee.

0 Kudos
3 Replies
Shubha_R_Intel
Employee
91 Views

Dear Lee, C.,

Perhaps someone in the OpenVino community can help you - but your question is not an OpenVino one. We do support VGG16 and VGG19, please look at the supported tensorflow OpenVino list .

You may have better luck if you posted to https://github.com/pjreddie/darknet/issues

Thanks,

Shubha

 

 

Lee__C_
Beginner
91 Views

Dear Shubha,

 

Thank you for the response. I think working directly with the supported VGG16 and VGG19 models in TensorFlow maybe more applicable.

 

Kind regards,

Lee.

Shubha_R_Intel
Employee
91 Views

Dear Lee, C.,

Yes I agree ! Glad to help.

Thanks,

Shubha

 

Reply