PaddlePaddle / PaddlePaddle/FastDeploy
对于PaddleClas部署中遇到的问题
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3.7k
- Forks
- 756
- Avg merge
- 19h 28m
- Merged PRs (30d)
- 4
Description
使用PaddleClas中ResNet50网络进行训练,并按照要求转换网络,得到inference.pdiparams,inference.pdmodel,并且添加了.yaml文件。在部署过程中,使用实例程序inter.py,输入图片为训练中使用的图片,但显示直接采用cv2.imread读取的图片为unit8,而程序要求float,错误的提示为:
Failed to Infer: Unexpected input data type. Actual: (tensor(uint8)) , expected: (tensor(float))
经过im.astype(np.float32) / 255后成功将dtype转换为float32,运行后显示错误:
Failed to Infer: Got invalid dimensions for input: x for the following indices
index: 1 Got: 227 Expected: 3
index: 3 Got: 3 Expected: 227
Please fix either the inputs or the model.
经过np.transpose(image,(2,0,1)),后改变维度顺序,再次运行,报错为:
Invalid number of channels in input image:
'VScn::contains(scn)'
where
'scn' is 227
维度顺序仍然错误,即前面要求通道数位置为1,后面要求通道数位置为3,请问应该如何解决这个矛盾?是否是我输入图片格式的问题(.jpg)或者我设置的问题?程序设置如下:
def parse_arguments():
import argparse
import ast
parser = argparse.ArgumentParser()
parser.add_argument(
"--model", default="models/ResNet50", help="Path of PaddleClas model.")
parser.add_argument(
"--image", type=str, default="data2/00010.jpg",help="Path of test image file.")
parser.add_argument(
"--topk", type=int, default=1, help="Return topk results.")
parser.add_argument(
"--device",
type=str,
default='gpu',
help="Type of inference device, support 'cpu' or 'gpu' or 'ipu' or 'kunlunxin' or 'ascend' ."
)
parser.add_argument(
"--use_trt",
type=ast.literal_eval,
default=False,
help="Wether to use tensorrt.")
return parser.parse_args()
Contributor guide
No contributing guide indexed for this repository
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.
Research direction
Start with the inter.py example and the supplied ResNet50 model files, then inspect how the image is read, converted, resized, and passed to inference. Reproduce the dtype and dimension errors with data2/00010.jpg; done means the preprocessing matches the model input and inference completes without the channel-order failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, opencv, python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100