提交 bb951cb5 编写于 作者: F fangzhou0329

doc modify

Signed-off-by: Nfangzhou0329 <fangzhou12@huawei.com>
上级 bbc24f68
......@@ -93,14 +93,14 @@ build() {
```shell
Launching com.example.myapptfjs
$ hdc uninstall com.example.myapptfjs
$ hdc install -r "D:\TVOS\JSAPI\MyAppTfjs\entry\build\default\outputs\default\entry-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 .\mnet.caffemodel.ms /data/app/el2/100/base/com.example.myapptfjs/haps/entry/files/
hdc -t your_device_id file send .\mnet.caffemodel.ms /data/app/el2/100/base/com.example.myapptfjs/haps/entry/files/
```
3. 在设备屏幕点击Test_MSLiteModel_predict触发用例,在HiLog打印结果中得到如下结果:
......
......@@ -185,12 +185,12 @@ let modelName = '/path/to/xxx.ms';
let syscontext = globalThis.context;
syscontext.resourceManager.getRawFileContent(modelName).then((buffer) => {
let modelBuffer = buffer;
}).catch(error => {
console.error('Failed to get buffer, error code: ${error.code},message:${error.message}.');
})
mindSporeLite.loadModelFromBuffer(modelBuffer.buffer, (result) => {
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
......@@ -217,14 +217,14 @@ let modelName = '/path/to/xxx.ms';
let syscontext = globalThis.context;
syscontext.resourceManager.getRawFileContent(modelName).then((error,buffer) => {
let modelBuffer = buffer;
}).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) => {
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}.');
})
```
## mindSporeLite.loadModelFromBuffer
......@@ -256,12 +256,12 @@ let modelName = '/path/to/xxx.ms';
let syscontext = globalThis.context;
syscontext.resourceManager.getRawFileContent(modelName).then((buffer) => {
let modelBuffer = buffer;
}).catch(error => {
console.error('Failed to get buffer, error code: ${error.code},message:${error.message}.');
})
mindSporeLite.loadModelFromBuffer(modelBuffer.buffer).then((result) => {
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.loadModelFromFd
......@@ -402,7 +402,7 @@ predict(inputs: MSTensor[], callback: Callback&lt;MSTensor[]&gt;): 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&lt;MSTensor[]&gt;
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.
先完成此消息的编辑!
想要评论请 注册