Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
4568ec45
D
Docs
项目概览
OpenHarmony
/
Docs
大约 1 年 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
4568ec45
编写于
7月 27, 2023
作者:
O
openharmony_ci
提交者:
Gitee
7月 27, 2023
浏览文件
操作
浏览文件
下载
差异文件
!21427 doc bugfix v3
Merge pull request !21427 from fangzhou0329/master
上级
bbc24f68
bb951cb5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
24 deletion
+24
-24
zh-cn/application-dev/ai/mindspore-guidelines-based-js.md
zh-cn/application-dev/ai/mindspore-guidelines-based-js.md
+2
-2
zh-cn/application-dev/reference/apis/js-apis-mindSporeLite.md
...n/application-dev/reference/apis/js-apis-mindSporeLite.md
+22
-22
未找到文件。
zh-cn/application-dev/ai/mindspore-guidelines-based-js.md
浏览文件 @
4568ec45
...
...
@@ -93,14 +93,14 @@ build() {
```
shell
Launching com.example.myapptfjs
$
hdc uninstall com.example.myapptfjs
$
hdc
install
-r
"
D:
\T
VOS
\J
SAPI
\M
yAppTfjs
\e
ntry
\b
uild
\d
efault
\o
utputs
\d
efault
\e
ntry-default-signed
.hap"
$
hdc
install
-r
"
path/to/xxx
.hap"
$
hdc shell aa start
-a
EntryAbility
-b
com.example.myapptfjs
```
2.
使用hdc连接设备,并将mnet.caffemodel.ms推送到设备中的沙盒目录。mnet_caffemodel_nhwc.bin在本地项目中的rawfile目录下。
```
shell
hdc
-t
7001005458323933328a00bcdf423800
file send .
\m
net.caffemodel.ms /data/app/el2/100/base/com.example.myapptfjs/haps/entry/files/
hdc
-t
your_device_id
file send .
\m
net.caffemodel.ms /data/app/el2/100/base/com.example.myapptfjs/haps/entry/files/
```
3.
在设备屏幕点击Test_MSLiteModel_predict触发用例,在HiLog打印结果中得到如下结果:
...
...
zh-cn/application-dev/reference/apis/js-apis-mindSporeLite.md
浏览文件 @
4568ec45
...
...
@@ -185,13 +185,13 @@ let modelName = '/path/to/xxx.ms';
let
syscontext
=
globalThis
.
context
;
syscontext
.
resourceManager
.
getRawFileContent
(
modelName
).
then
((
buffer
)
=>
{
let
modelBuffer
=
buffer
;
mindSporeLite
.
loadModelFromBuffer
(
modelBuffer
.
buffer
,
(
result
)
=>
{
const
modelInputs
=
result
.
getInputs
();
console
.
log
(
modelInputs
[
0
].
name
);
})
}).
catch
(
error
=>
{
console
.
error
(
'
Failed to get buffer, error code: ${error.code},message:${error.message}.
'
);
})
mindSporeLite
.
loadModelFromBuffer
(
modelBuffer
.
buffer
,
(
result
)
=>
{
const
modelInputs
=
result
.
getInputs
();
console
.
log
(
modelInputs
[
0
].
name
);
})
```
## mindSporeLite.loadModelFromBuffer
...
...
@@ -217,15 +217,15 @@ let modelName = '/path/to/xxx.ms';
let
syscontext
=
globalThis
.
context
;
syscontext
.
resourceManager
.
getRawFileContent
(
modelName
).
then
((
error
,
buffer
)
=>
{
let
modelBuffer
=
buffer
;
let
context
:
mindSporeLite
.
Context
=
{};
context
=
{
'
target
'
:
[
'
cpu
'
]};
mindSporeLite
.
loadModelFromBuffer
(
modelBuffer
.
buffer
,
context
,
(
result
)
=>
{
const
modelInputs
=
result
.
getInputs
();
console
.
log
(
modelInputs
[
0
].
name
);
})
}).
catch
(
error
=>
{
console
.
error
(
'
Failed to get buffer, error code: ${error.code},message:${error.message}.
'
);
})
let
context
:
mindSporeLite
.
Context
=
{};
context
=
{
'
target
'
:
[
'
cpu
'
]};
mindSporeLite
.
loadModelFromBuffer
(
modelBuffer
.
buffer
,
context
,
(
result
)
=>
{
const
modelInputs
=
result
.
getInputs
();
console
.
log
(
modelInputs
[
0
].
name
);
})
```
## mindSporeLite.loadModelFromBuffer
...
...
@@ -256,13 +256,13 @@ let modelName = '/path/to/xxx.ms';
let
syscontext
=
globalThis
.
context
;
syscontext
.
resourceManager
.
getRawFileContent
(
modelName
).
then
((
buffer
)
=>
{
let
modelBuffer
=
buffer
;
mindSporeLite
.
loadModelFromBuffer
(
modelBuffer
.
buffer
).
then
((
result
)
=>
{
const
modelInputs
=
result
.
getInputs
();
console
.
log
(
modelInputs
[
0
].
name
);
})
}).
catch
(
error
=>
{
console
.
error
(
'
Failed to get buffer, error code: ${error.code},message:${error.message}.
'
);
})
mindSporeLite
.
loadModelFromBuffer
(
modelBuffer
.
buffer
).
then
((
result
)
=>
{
const
modelInputs
=
result
.
getInputs
();
console
.
log
(
modelInputs
[
0
].
name
);
})
```
## mindSporeLite.loadModelFromFd
...
...
@@ -402,7 +402,7 @@ predict(inputs: MSTensor[], callback: Callback<MSTensor[]>): void
import
resourceManager
from
'
@ohos.resourceManager
'
let
inputName
=
'
input_data.bin
'
;
let
syscontext
=
globalThis
.
context
;
syscontext
.
resourceManager
.
getRawFileContent
(
inputName
).
then
((
buffer
)
=>
{
syscontext
.
resourceManager
.
getRawFileContent
(
inputName
).
then
(
async
(
buffer
)
=>
{
let
inputBuffer
=
buffer
;
let
model_file
=
'
/path/to/xxx.ms
'
;
let
mindSporeLiteModel
=
await
mindSporeLite
.
loadModelFromFile
(
model_file
);
...
...
@@ -442,7 +442,7 @@ predict(inputs: MSTensor[]): Promise<MSTensor[]>
import
resourceManager
from
'
@ohos.resourceManager
'
let
inputName
=
'
input_data.bin
'
;
let
syscontext
=
globalThis
.
context
;
syscontext
.
resourceManager
.
getRawFileContent
(
inputName
).
then
((
buffer
)
=>
{
syscontext
.
resourceManager
.
getRawFileContent
(
inputName
).
then
(
async
(
buffer
)
=>
{
let
inputBuffer
=
buffer
;
let
model_file
=
'
/path/to/xxx.ms
'
;
let
mindSporeLiteModel
=
await
mindSporeLite
.
loadModelFromFile
(
model_file
);
...
...
@@ -543,7 +543,7 @@ getData(): ArrayBuffer
import
resourceManager
from
'
@ohos.resourceManager
'
let
inputName
=
'
input_data.bin
'
;
let
syscontext
=
globalThis
.
context
;
syscontext
.
resourceManager
.
getRawFileContent
(
inputName
).
then
((
buffer
)
=>
{
syscontext
.
resourceManager
.
getRawFileContent
(
inputName
).
then
(
async
(
buffer
)
=>
{
let
inputBuffer
=
buffer
;
let
model_file
=
'
/path/to/xxx.ms
'
;
let
mindSporeLiteModel
=
await
mindSporeLite
.
loadModelFromFile
(
model_file
);
...
...
@@ -578,13 +578,13 @@ setData(inputArray: ArrayBuffer): void
import
resourceManager
from
'
@ohos.resourceManager
'
let
inputName
=
'
input_data.bin
'
;
let
syscontext
=
globalThis
.
context
;
syscontext
.
resourceManager
.
getRawFileContent
(
inputName
).
then
((
buffer
)
=>
{
syscontext
.
resourceManager
.
getRawFileContent
(
inputName
).
then
(
async
(
buffer
)
=>
{
inputBuffer
=
buffer
;
let
model_file
=
'
/path/to/xxx.ms
'
;
let
mindSporeLiteModel
=
await
mindSporeLite
.
loadModelFromFile
(
model_file
);
const
modelInputs
=
mindSporeLiteModel
.
getInputs
();
modelInputs
[
0
].
setData
(
inputBuffer
.
buffer
);
})
let
model_file
=
'
/path/to/xxx.ms
'
;
let
mindSporeLiteModel
=
await
mindSporeLite
.
loadModelFromFile
(
model_file
);
const
modelInputs
=
mindSporeLiteModel
.
getInputs
();
modelInputs
[
0
].
setData
(
inputBuffer
.
buffer
);
```
## DataType
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录