tensorflow / tensorflow/models
convert to tensorrt got issue nasnet_mobile image classification
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.7k
- Forks
- 44.8k
- PR merge metrics
- No merged PRs in 30d
Description
Prerequisites
jetson nano board
CUDA : 10.2
tensorrt : 7.1
cudnn : 8.0
jetpack : 4.5.1
Tensorflow 1.15.5
1. The entire URL of the file you are using
https://storage.googleapis.com/download.tensorflow.org/models/nasnet-a_mobile_04_10_2017.tar.gz
2. Describe the feature you request
I convert nasnet mobile from checkpoint to frozen_graph.pb and then I test with frozen_graph.pb it's working for me.
And then I convert to uff file with python3 /usr/lib/python3.6/dist-packages/uff/bin/convert_to_uff.py frozen_graph.pb
after I have a uff file I build tensorrt with this code :
import argparse
import tensorrt as trt
TRT_LOGGER = trt.Logger(trt.Logger.WARNING)
def get_parser():
parser = argparse.ArgumentParser(description="Build TensorRT Engine")
parser.add_argument("--model",default="model.uff",help="Path to uff file default[model.uff].")
parser.add_argument("--output",default="model.engine",help="Path to output engine default[model.engine].")
parser.add_argument("--input_name",default="input",help="Give name input of Graph default[input].")
parser.add_argument("--output_name",default="MobilenetV1/Predictions/Reshape_1",help="Give name output of Graph default[MobilenetV1/Predictions/Reshape_1].")
parser.add_argument("--fp16", action="store_true",help="set --fp16 for Build TensorRT FP16")
parser.add_argument("--height",type=int,default=224,help="height input image default [224].")
parser.add_argument("--width",type=int,default=224,help="width input image default [224].")
parser.add_argument("--batch_size",type=int,default=1,help="batch size input image default [1].")
parser.add_argument("--channel",type=int,default=3,help="channel input image default [3].")
return parser
args = get_parser().parse_args()
print(args)
with trt.Builder(TRT_LOGGER) as builder, builder.create_network() as network, trt.UffParser() as parser:
builder.max_workspace_size = 1<<28
builder.max_batch_size = args.batch_size
builder.fp16_mode = args.fp16
parser.register_input(args.input_name,(args.channel,args.width,args.height))
parser.register_output(args.output_name)
parser.parse(args.model,network)
engine = builder.build_cuda_engine(network)
buf = engine.serialize()
with open(args.output, 'wb') as f:
f.write(buf)
I got issue like below :
[TensorRT] ERROR: cell_stem_1/path2_conv/Conv2D: kernel weights has count 352 but 341 was expected
[TensorRT] ERROR: cell_stem_1/path2_conv/Conv2D: count of 352 weights in kernel, but kernel dimensions (1,1) with 31 input channels, 11 output channels and 1 groups were specified. Expected Weights count is 31 * 11 * 11 / 1 = 341
[TensorRT] ERROR: cell_stem_1/path2_conv/Conv2D: kernel weights has count 352 but 341 was expected
[TensorRT] ERROR: cell_stem_1/path2_conv/Conv2D: count of 352 weights in kernel, but kernel dimensions (1,1) with 31 input channels, 11 output channels and 1 groups were specified. Expected Weights count is 31 * 11 * 11 / 1 = 341
[TensorRT] ERROR: cell_stem_1/path2_conv/Conv2D: kernel weights has count 352 but 341 was expected
[TensorRT] ERROR: cell_stem_1/path2_conv/Conv2D: count of 352 weights in kernel, but kernel dimensions (1,1) with 31 input channels, 11 output channels and 1 groups were specified. Expected Weights count is 31 * 11 * 11 / 1 = 341
[TensorRT] ERROR: cell_stem_1/path2_conv/Conv2D: kernel weights has count 352 but 341 was expected
[TensorRT] ERROR: cell_stem_1/path2_conv/Conv2D: count of 352 weights in kernel, but kernel dimensions (1,1) with 31 input channels, 11 output channels and 1 groups were specified. Expected Weights count is 31 * 11 * 11 / 1 = 341
[TensorRT] ERROR: cell_stem_1/path2_conv/Conv2D: kernel weights has count 352 but 341 was expected
[TensorRT] ERROR: cell_stem_1/path2_conv/Conv2D: count of 352 weights in kernel, but kernel dimensions (1,1) with 31 input channels, 11 output channels and 1 groups were specified. Expected Weights count is 31 * 11 * 11 / 1 = 341
[TensorRT] ERROR: cell_stem_1/path2_conv/Conv2D: kernel weights has count 352 but 341 was expected
[TensorRT] ERROR: cell_stem_1/path2_conv/Conv2D: count of 352 weights in kernel, but kernel dimensions (1,1) with 31 input channels, 11 output channels and 1 groups were specified. Expected Weights count is 31 * 11 * 11 / 1 = 341
[TensorRT] ERROR: cell_stem_1/path2_conv/Conv2D: kernel weights has count 352 but 341 was expected
[TensorRT] ERROR: cell_stem_1/path2_conv/Conv2D: count of 352 weights in kernel, but kernel dimensions (1,1) with 31 input channels, 11 output channels and 1 groups were specified. Expected Weights count is 31 * 1*1 * 11 / 1 = 341
[TensorRT] ERROR: UffParser: Parser error: cell_stem_1/final_path_bn/FusedBatchNormV3: The input to the Scale Layer is required to have a minimum of 3 dimensions.
[TensorRT] ERROR: Network must have at least one output
[TensorRT] ERROR: Network validation failed.
Traceback (most recent call last):
File "tensorrt_convert.py", line 26, in
buf = engine.serialize()
AttributeError: 'NoneType' object has no attribute 'serialize'
my convert slim_model like inception mobilenet resnetv1 resnetv2 to tensorrt it's working for me.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.