|
rt,不论我的输入内容是什么,我的模型输出的结果经过后处理后似乎都是一样的,求dalao帮我看看我设置的input是存在什么样的问题
我的setinput部分代码
- Java_com_wuzhengai_examination_tfliterun_blazeface_rknn_BlazeFaceRknn_detect(
- JNIEnv *env,
- jobject thiz,
- jbyteArray input,
- jbyteArray output1,
- jbyteArray output2) {
- if (!created) {
- LOGE("run_yolo: init yolo hasn't successful!");
- return false;
- }
- jboolean inputCopy = JNI_FALSE;
- jbyte *const inData = env->GetByteArrayElements(input, &inputCopy);
- // 获取数组长度
- jsize length = env->GetArrayLength(input);
- // 创建一个int8_t数组
- int8_t *inputData = new int8_t[length];
- // inputData
- for (int i = 0; i < length; i++) {
- inputData[i] = static_cast<int8_t>(inData[i]);
- }
- jboolean outputCopy = JNI_FALSE;
- jbyte *const y0 = env->GetByteArrayElements(output1, &outputCopy);
- jbyte *const y1 = env->GetByteArrayElements(output2, &outputCopy);
- rknn_input inputs[1];
- memset(inputs, 0, sizeof(inputs));
- inputs[0].index = 0;
- inputs[0].type = RKNN_TENSOR_INT8;
- // float 类型需要乘以2?不清楚
- inputs[0].size = m_in_height * m_in_width * m_in_channel;
- // inputs[0].size =75264;
- inputs[0].fmt = RKNN_TENSOR_NHWC;
- inputs[0].pass_through = 1;
- inputs[0].buf = inData;
- int ret = rknn_inputs_set(ctx, 1, inputs);
- rknn_output outputs[2];
- memset(outputs, 0, sizeof(outputs));
- for (int i = 0; i < 2; ++i) {
- outputs[i].want_float = 0;
- }
- if (ret < 0) {
- LOGE("rknn_set fail! ret=%d\n", ret);
- return false;
- }
- // LOGE("rknn set %d",ret)
- ret = rknn_run(ctx, nullptr);
- if (ret < 0) {
- LOGE("rknn_run fail! ret=%d\n", ret);
- return false;
- }
- rknn_outputs_get(ctx, 2, outputs, NULL);
- int8_t *kk = static_cast<int8_t *>(inputs[0].buf);
- int8_t *kk3 = static_cast<int8_t *>(outputs[1].buf);
- memcpy(y0, outputs[0].buf, output_attrs[0].n_elems * sizeof(char));
- memcpy(y1, outputs[1].buf, output_attrs[1].n_elems * sizeof(char));
- LOGE("sesekan %d,%d,%d,%d", kk[25423], inputData[25423], y1[200], kk3[200]);
- //
- env->ReleaseByteArrayElements(input, inData, JNI_ABORT);
- env->ReleaseByteArrayElements(output1, y0, 0);
- env->ReleaseByteArrayElements(output2, y1, 0);
- rknn_outputs_release(ctx, 2, outputs);
- return JNI_TRUE;
- }
|
|