-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
efficientAD_det model.ae.encoder.enconv1.weight 1536,There was a problem during conversion #1605
Comments
Using the https://github.com/B1SH0PP/EfficientAD_TRT model to run gen_wts.py, the error is as follows: Traceback (most recent call last): |
@B1SH0PP Can you help here? |
The first problem has been solved, but I don't know how to solve the second problem. Another question is, when performing tensorrt inference, why is the inference time longer when the batch size is set to 4, 8, 16, or 32 than when it is set to 1? How can this be solved? |
@wang-xinyu |
@wang-xinyu @B1SH0PP
/* PDN_samll_student */
Based on the above 1 and 2, it will lead to serious loss of accuracy, and it will also lead to different input data and the same output results.
|
I also found a problem that the author used an input with three dimensions, and the python version had four dimensions, with a batchsize added.
|
3-dimension is fine. Can you try the same model which B1SH0PP was using? |
OK, I'll try |
@wang-xinyu `ICudaEngine* build_efficientAD_engine(unsigned int maxBatchSize, IBuilder* builder, IBuilderConfig* config, DataType dt,
|
Double check your layers one by one. And you can also mark the middle layers as output, to compare the tensor values with pytorch. |
@wang-xinyu cpu_output_data[0]:-0.0233255 teacher relu3: tensor(0.1133, device='cuda:0', dtype=torch.float16) cpu_output_data[0]:0.126856 teacher avgpoo2: torch.Size([1, 256, 61, 61]) cpu_output_data[0]:0.265905 teacher relu2: torch.Size([1, 256, 123, 123]) cpu_output_data[0]:0.320983 teacher avgpool1: torch.Size([1, 128, 126, 126]) cpu_output_data[batch * kOutputSize]:2032128 teacher relu1: torch.Size([1, 128, 253, 253]) cpu_output_data[batch * kOutputSize]:8193152 student: teacher conv4: torch.Size([1, 768, 56, 56]) cpu_output_data[batch * kOutputSize]:2408448 teacher relu3: torch.Size([1, 256, 59, 59]) cpu_output_data[batch * kOutputSize]:891136 teacher avgpoo2: torch.Size([1, 256, 61, 61]) cpu_output_data[batch * kOutputSize]:952576 teacher relu2: torch.Size([1, 256, 123, 123]) cpu_output_data[batch * kOutputSize]:3873024 teacher avgpool1: torch.Size([1, 128, 126, 126]) cpu_output_data[batch * kOutputSize]:2032128 teacher relu1: torch.Size([1, 128, 253, 253]) cpu_output_data[batch * kOutputSize]:8193152 torch.pow distance_st: torch.Size([1, 384, 56, 56]) cpu_output_data[batch * kOutputSize]:1204224 torch.mean map_st: torch.Size([1, 1, 56, 56]) cpu_output_data[batch * kOutputSize]:3136 torch.mean map_stae: torch.Size([1, 1, 56, 56]) F.pad map_st: torch.Size([1, 1, 64, 64]) F.pad map_stae: torch.Size([1, 1, 64, 64]) F.interpolate map_st: torch.Size([1, 1, 256, 256]) F.interpolate map_stae: torch.Size([1, 1, 256, 256]) normalize map_st: torch.Size([1, 1, 256, 256]) normalize map_stae: torch.Size([1, 1, 256, 256]) anomaly_map: torch.Size([1, 1, 256, 256]) ` |
@wang-xinyu There is an error in the code, and the accuracy difference is now 0.0013. Why does batchsize increase linearly? |
Maybe your GPU's compute resource is already fully used even when bs=1. |
Env
About this repo
Your problem
I trained the model through anomalib and used https://github.com/wang-xinyu/tensorrtx/tree/master/efficient_ad.Can you help me find out what the problem is? I am using small Version
mkdir build
cd build
cmake ..
make
./efficientAD_det -s model.wts model.engine
The following bug appeared:
[12/05/2024-13:39:40] [E] [TRT] 3: ae.encoder.enconv1:kernel weights has count 0 but 1536 was expected
[12/05/2024-13:39:40] [E] [TRT] 4: ae.encoder.enconv1: count of 0 weights in kernel, but kernel dimensions (4,4) with 3 input channels, 32 output channels and 1 groups were specified. Expected Weights count is 3 * 44 * 32 / 1 = 1536
[12/05/2024-13:39:40] [E] [TRT] 4: [convolutionNode.cpp::computeOutputExtents::58] Error Code 4: Internal Error (ae.encoder.enconv1: number of kernel weights does not match tensor dimensions)
[12/05/2024-13:39:40] [E] [TRT] 3: [network.cpp::addResize::1382] Error Code 3: API Usage Error (Parameter check failed at: optimizer/api/network.cpp::addResize::1382, condition: input.getDimensions().nbDims > 0
)
efficientAD_det: /tensorrt_ad/efficient_ad/src/model.cpp:242: nvinfer1::ILayer interpConvRelu(nvinfer1::INetworkDefinition*, std::map<std::__cxx11::basic_string, nvinfer1::Weights>&, nvinfer1::ITensor&, int, int, int, int, int, std::string, int): Assertion `interpolateLayer != nullptr' failed.
已放弃 (核心已转储)
The wts parsed content is
The text was updated successfully, but these errors were encountered: