【嵌入式AI挑战营】03GCC交叉编译环境安装
<div><strong>交叉编译环境GCC安装和程序编译</strong></div><div><strong>一、SDK下载安装</strong></div>
<div>困扰我时间挺长的一个SKD开发环境安装,Buildroot 系统的交叉编译工具链可在 SDK 中获取。然后下载这个工具链内容,尝试按照教程安装,但发现它这个链接下的内容应该不是工具链,之后进行了漫长的工具链查找阶段。但是教程是对的。。</div>
<div><a href="https://wiki.luckfox.com/zh/Luckfox-Pico/Cross-Compile/">https://wiki.luckfox.com/zh/Luckfox-Pico/Cross-Compile/</a> 交叉编译程序教程</div>
<div>但安装后发现是自己忽略了什么,因为在入门指南和资料下载内有相关的链接。再次按照安装教程进行程序安装。</div>
<div><a href="https://wiki.luckfox.com/zh/Luckfox-Pico/Download">https://wiki.luckfox.com/zh/Luckfox-Pico/Download</a></div>
<div><a href="https://wiki.luckfox.com/zh/Luckfox-Pico/Download"></a></div>
<div>下载SDK的地址如图所示:</div>
<div><a href="https://github.com/LuckfoxTECH/luckfox-pico">https://github.com/LuckfoxTECH/luckfox-pico</a></div>
<div><a href="https://gitee.com/LuckfoxTECH/luckfox-pico">https://gitee.com/LuckfoxTECH/luckfox-pico</a></div>
<ol>
<li><strong>交叉编译器安装后测试</strong></li>
</ol>
<div>以程序 hello.c 为例,编译出对应的可执行文件,文件执行效果是在终端上打印 hello world 。hello.c 代码如下:</div>
<div>#include <stdio.h></div>
<div>#include <stdlib.h></div>
<div>int main()</div>
<div>{</div>
<div>printf("hello world\n");</div>
<div>return 0;</div>
<div>}</div>
<div></div>
<div>编译成功。</div>
<ol>
<li>ONNX转换到RKNN模型<br />
转换代码convert.py<br />
import sys<br />
from rknn.api import RKNN<br />
DATASET_PATH = '../model/dataset.txt'<br />
DEFAULT_RKNN_PATH = '../model/facenet.rknn'<br />
DEFAULT_QUANT = True<br />
def parse_arg():<br />
if len(sys.argv) < 3:<br />
print("Usage: python3 {} onnx_model_path ".format(sys.argv));<br />
print(" platform choose from ")<br />
print(" dtype choose from for ")<br />
print(" dtype choose from for ")<br />
exit(1)<br />
model_path = sys.argv<br />
platform = sys.argv<br />
do_quant = DEFAULT_QUANT<br />
if len(sys.argv) > 3:<br />
model_type = sys.argv<br />
if model_type not in ['i8', 'u8', 'fp']:<br />
print("ERROR: Invalid model type: {}".format(model_type))<br />
exit(1)<br />
elif model_type in ['i8', 'u8']:<br />
do_quant = True<br />
else:<br />
do_quant = False<br />
if len(sys.argv) > 4:<br />
output_path = sys.argv<br />
else:<br />
output_path = DEFAULT_RKNN_PATH<br />
return model_path, platform, do_quant, output_path<br />
if __name__ == '__main__':<br />
model_path, platform, do_quant, output_path = parse_arg()<br />
# Create RKNN object<br />
rknn = RKNN(verbose=False)<br />
# Pre-process config<br />
print('--> Config model')<br />
rknn.config(mean_values=[], std_values=[], target_platform=platform)<br />
print('done')<br />
# Load model<br />
print('--> Loading model')<br />
ret = rknn.load_onnx(model=model_path)<br />
if ret != 0:<br />
print('Load model failed!')<br />
exit(ret)<br />
print('done')<br />
# Build model<br />
print('--> Building model')<br />
ret = rknn.build(do_quantization=do_quant, dataset=DATASET_PATH)<br />
if ret != 0:<br />
print('Build model failed!')<br />
exit(ret)<br />
print('done')<br />
# Export rknn model<br />
print('--> Export rknn model')<br />
ret = rknn.export_rknn(output_path)<br />
if ret != 0:<br />
print('Export rknn model failed!')<br />
exit(ret)<br />
print('done')<br />
# Release<br />
rknn.release()<br />
这个代码针对不同的程序需要进行改动,才可以进行使用。</li>
<li> </li>
</ol>
<p><!--importdoc--></p>
大佬,rknn是大佬你自己训练出来的吗?能不能教一下我。 lugl4313820 发表于 2025-1-7 15:43
大佬,rknn是大佬你自己训练出来的吗?能不能教一下我。
<p>目前的不是 我也在摸索训练转onnx还行 在转rknn遇到问题了</p>
页:
[1]