We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
private void dynamicLoadModel(String modelPath, String yamlPath) { predictButton.setText("正在加载模型"); predictButton.setEnabled(false); radioGroup.setEnabled(false); tvOutputResult.setText(""); tvInferenceTime.setText("模型预测耗时: -- 毫秒");
// 由于切换过程中加载模型UI会卡住,使用线程保证用户体验,创建后台单线程池 ExecutorService executorService = Executors.newSingleThreadExecutor(); executorService.submit(new Runnable() { @Override public void run() { // 执行耗时操作 SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(MainActivity.this); int cpuThreadNum = Integer.parseInt(sharedPreferences.getString(getString(R.string.CPU_THREAD_NUM_KEY), getString(R.string.CPU_THREAD_NUM_DEFAULT))); String cpuPowerMode = sharedPreferences.getString(getString(R.string.CPU_POWER_MODE_KEY), getString(R.string.CPU_POWER_MODE_DEFAULT)); try { String realModelPath = modelPath; if (!modelPath.substring(0, 1).equals("/")) { String modelFileName = Utils.getFileNameFromString(modelPath); realModelPath = MainActivity.this.getCacheDir() + File.separator + modelFileName; Utils.copyFileFromAssets(MainActivity.this, modelPath, realModelPath); } String realYamlPath = yamlPath; if (!yamlPath.substring(0, 1).equals("/")) { String yamlFileName = Utils.getFileNameFromString(yamlPath); realYamlPath = MainActivity.this.getCacheDir() + File.separator + yamlFileName; Utils.copyFileFromAssets(MainActivity.this, yamlPath, realYamlPath); } configParser.init(realModelPath, realYamlPath, cpuThreadNum, cpuPowerMode); visualize.init(configParser.getNumClasses()); } catch (Exception e) { e.printStackTrace(); Toast.makeText(MainActivity.this, "配置加载失败!", Toast.LENGTH_SHORT).show(); } runOnUiThread(new Runnable() { @Override public void run() { // reload model if configure has been changed loadModel(); } }); } }); // 关闭线程池 executorService.shutdown(); }
The text was updated successfully, but these errors were encountered:
已收到您的issue,等内部同学看一下
Sorry, something went wrong.
建议先用CPP Demo跑一下 (参考 https://www.paddlepaddle.org.cn/lite/v2.12/demo_guides/arm_cpu.html#yunxingtuxiangfenleishilichengxu ),脱离 APP 确认下二次加载是否有问题,先排除一下APP集成本身的问题,在SHELL Demo中运行确认下。
No branches or pull requests
1)Paddle Lite 版本:2.13-rc
2)Host 环境:Mac OS 14.4.1
3)运行设备环境:小米12S Ultra
4)预测后端信息:安卓端侧部署
1)预测 API:SDK二次开发包、原生so包
2)预测选项信息:armv8,单线程
3)预测库来源:官网下载
private void dynamicLoadModel(String modelPath, String yamlPath) {
predictButton.setText("正在加载模型");
predictButton.setEnabled(false);
radioGroup.setEnabled(false);
tvOutputResult.setText("");
tvInferenceTime.setText("模型预测耗时: -- 毫秒");
The text was updated successfully, but these errors were encountered: