树莓派4B+ python 3.7.3
利用yolov3 【608,608】 生成 model.nb
执行如下程序
from paddlelite.lite import *
from PIL import Image
import numpy as np
设置config信息
config = MobileConfig()
config.set_model_from_file("model.np")
创建predictor
predictor = create_paddle_predictor(config)
从图片读入数据
image = Image.open('test.jpg')
resized_image = image.resize((608, 608), Image.BILINEAR)
image_data = np.array(resized_image).flatten().tolist()
设置输入数据
input_tensor = predictor.get_input(0)
input_tensor.resize([1, 3, 608 608])
input_tensor.set_float_data(image_data)
执行预测
predictor.run()
得到输出数据
output_tensor = predictor.get_output(0)
print(output_tensor.shape())
print(output_tensor.float_data()[:10])
错误代码
Backend terminated or disconnected.Fatal Python error: Segmentation fault
Current thread 0xb6fafad0 (most recent call first):
File "/home/pi/Desktop/run_jpg.py", line 27 in
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 1272 in _execute_prepared_user_code
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 1200 in wrapper
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 1213 in wrapper
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 1259 in execute_source
问题1:yolov3 如何 设置输入数据
问题2:从图片如何读入数据
1条答案
按热度按时间wkyowqbh1#
yolov3需要两个输入tensor,另一个input_tensor1 = predictor.get_input(1),你需要设置图像尺寸。