AR 眼镜之-条形码识别-实现方案

目录

📂 前言

AR 眼镜系统版本

条形码识别

1. 🔱 技术方案

1.1 技术方案概述

1.2 实现方案

1)相机App显示模块

2)算法so库JNI模块

3)算法条形码识别模块

2. 💠 实现相机App显示模块

2.1 创建 BarcodeIdentifyDemoActivity.kt

2.2 创建 activity_barcode_identify_demo.xml

2.3 创建 AlgorithmLibHelper.kt

2.4 创建 AssetsHelper.kt

2.5 创建 ProductBean.kt

3. ⚛️ 算法so库JNI模块

3.1 新建CMakeLists.txt,引入算法so库以及头文件

1)CMakeLists.txt 内容如下:

2)引入算法so库以及头文件

3.2 新建cpp文件,调用算法so库方法

3.3 新建native方法,加载JNI模块生成的库以及映射对应方法

3.4 配置 build.gradle 文件

4. ✅ 小结


📂 前言

AR 眼镜系统版本

        W517 Android9。

条形码识别

        AR眼镜中相机App,调用算法条形码识别接口,获取到算法接口返回文本后,将文本显示在眼镜页面。

1. 🔱 技术方案

1.1 技术方案概述

        条形码识别功能的实现,主要包括以下三大模块:相机App显示模块、算法so库JNI模块、以及算法条形码识别模块。

1.2 实现方案

1)相机App显示模块
  1. 实现相机预览、拍照与保存功能;

  2. 传入拍照后的图片路径,调用算法so库JNI模块;

  3. 显示算法so库JNI模块返回的条形码识别到的商品信息。

2)算法so库JNI模块
  1. 新建CMakeLists.txt,引入算法so库以及头文件;

  2. 新建cpp文件,调用算法so库方法;

  3. 新建native方法,加载JNI模块生成的库以及映射对应方法。

3)算法条形码识别模块
  1. 对照片进行处理,获取到照片中的二维码;

  2. 调用二维码识别so库,获取二维码中的信息;

  3. 将二维码信息与数据库匹配,返回匹配到的商品信息。

2. 💠 实现相机App显示模块

2.1 创建 BarcodeIdentifyDemoActivity.kt

        主要实现相机预览、拍照与保存等功能。可参考《一周内从0到1开发一款 AR眼镜 相机应用?》

class BarcodeIdentifyDemoActivity :BaseActivity<ActivityBarcodeIdentifyDemoBinding, MainViewModel>() {private val TAG = BarcodeIdentifyDemoActivity::class.java.simpleNameprivate val DEFAULT_CONTENT ="    \"商品名称\": \"\",\n" + "    \"品牌\": \"\",\n" + "    \"规格型号\": \"\",\n" + "    \"价格\": \"\",\n" + "    \"原产地\": \"\",\n" + "    \"税率\": \"\",\n" + "    \"税号\": \"\",\n" + "    \"功能用途\":\"\""private val CAMERA_MAX_RESOLUTION = Size(3264, 2448)private var mCameraExecutor: ExecutorService = Executors.newSingleThreadExecutor()private var mImageCapture: ImageCapture? = nullprivate var mIsBarcodeRecognition: Boolean = falseprivate var mTimeOut: CountDownTimer? = nulloverride fun initBinding(inflater: LayoutInflater): ActivityBarcodeIdentifyDemoBinding =ActivityBarcodeIdentifyDemoBinding.inflate(inflater)override fun initData() {AlgorithmLibHelper.init(this)AlgorithmLibHelper.productBeanLiveData.observe(this) {Log.i(TAG, "initData: $it")if (it != null) {runOnUiThread {binding.loading.visibility = GONEmIsBarcodeRecognition = falsebinding.content.text ="    \"商品名称\": \"${it.product_name}\",\n" + "    \"品牌\": \"${it.brand}\",\n" + "    \"规格型号\": \"${it.specifications}\",\n" + "    \"价格\": \"${it.price}\",\n" + "    \"原产地\": \"${it.country_of_origin}\",\n" + "    \"税率\": \"${it.tax_rate}\",\n" + "    \"税号\": \"${it.tax_code}\",\n" + "    \"功能用途\":\"${it.function_and_use}\""mTimeOut?.cancel()mTimeOut = null}} else {errorHandle()}}}override fun initViewModel() {viewModel.init(this)}override fun initView() {initWindow()switchToPhoto()binding.parent.setOnClickListener {try {if (mImageCapture == null || mIsBarcodeRecognition) {AGGToast(this, Toast.LENGTH_SHORT, "please hold on").show()} else {mIsBarcodeRecognition = truebinding.loading.setContent("Identify...")binding.loading.visibility = VISIBLEtakePicture()}} catch (e: Exception) {e.printStackTrace()}}binding.loading.visibility = VISIBLE}override fun onResume() {Log.i(TAG, "onResume: ")super.onResume()}override fun onStop() {Log.i(TAG, "onStop: ")super.onStop()}override fun onDestroy() {Log.i(TAG, "onDestroy: ")mTimeOut?.cancel()mTimeOut = nullAnimatorSwitchHelper.isAnimating = falseAnimatorSwitchHelper.isFirstSwitch = truesuper.onDestroy()mCameraExecutor.shutdown()XrEnvironment.getInstance().imuReset()AlgorithmLibHelper.release()}private fun initWindow() {Log.i(TAG, "initWindow: ")val lp = window.attributeslp.dofIndex = 0lp.subType = WindowManager.LayoutParams.WINDOW_IMMERSIVE_0DOFwindow.attributes = lp}private fun switchToPhoto() {Log.i(TAG, "switchToPhoto: ")val cameraProviderFuture = ProcessCameraProvider.getInstance(this)cameraProviderFuture.addListener({try {mImageCapture = ImageCapture.Builder().setCaptureMode(ImageCapture.CAPTURE_MODE_MAXIMIZE_QUALITY).setTargetResolution(CAMERA_MAX_RESOLUTION).build()val cameraSelector = CameraSelector.DEFAULT_BACK_CAMERAval cameraProvider = cameraProviderFuture.get()cameraProvider.unbindAll()// 可预览val preview = Preview.Builder().build()binding.previewView.apply {implementationMode = PreviewView.ImplementationMode.COMPATIBLEpreview.setSurfaceProvider(surfaceProvider)clipToOutline = truevisibility = VISIBLE}cameraProvider.bindToLifecycle(this, cameraSelector, preview, mImageCapture)// 无预览
//                cameraProvider.bindToLifecycle(this, cameraSelector, mImageCapture)binding.loading.visibility = GONE} catch (e: java.lang.Exception) {Log.e(TAG, "bindCamera Failed!: $e")}}, ContextCompat.getMainExecutor(this))}/*** 拍照*/private fun takePicture() {Log.i(TAG, "takePicture: ")SoundPoolTools.playCameraPhoto(this)val photoFile = viewModel.createPhotoFile()mImageCapture?.takePicture(ImageCapture.OutputFileOptions.Builder(photoFile).build(),mCameraExecutor,object : ImageCapture.OnImageSavedCallback {override fun onError(exc: ImageCaptureException) {Log.e(TAG, "Photo capture failed: ${exc.message}", exc)}@SuppressLint("SetTextI18n")override fun onImageSaved(output: ImageCapture.OutputFileResults) {val savedUri = output.savedUri ?: Uri.fromFile(photoFile)Log.i(TAG, "Photo capture succeeded: ${savedUri.path}")runOnUiThread { updateFlashPreview(savedUri) }viewModel.updateMediaFile(this@BarcodeIdentifyDemoActivity, photoFile)// 调用条形码识别算法lifecycleScope.launch {withContext(Dispatchers.IO) {savedUri.path?.let {AlgorithmLibHelper.identifyBarcode(it)}}}// 超时逻辑runOnUiThread {mTimeOut?.cancel()mTimeOut = nullmTimeOut = object : CountDownTimer(15000L, 1000) {override fun onTick(millisUntilFinished: Long) {}override fun onFinish() {Log.e(TAG, "onFinish: identify timeout")AGGToast(this@BarcodeIdentifyDemoActivity,Toast.LENGTH_SHORT,"identify timeout").show()errorHandle()}}.start()}}})}private fun updateFlashPreview(savedUri: Uri) {binding.flashPreview.apply {visibility = VISIBLEGlide.with(this@BarcodeIdentifyDemoActivity).load(savedUri).into(this)// 创建动画val animatorAlpha = ObjectAnimator.ofFloat(this, "alpha", 0f, 1f)val animatorX = ObjectAnimator.ofFloat(this, "translationX", 0f, SizeUtils.dp2px(-144f).toFloat())// 同时播放X和Y轴的动画val animatorSet = AnimatorSet()animatorSet.playTogether(animatorAlpha, animatorX)animatorSet.interpolator = EaseOutInterpolator()animatorSet.duration = CAMERA_FLASH_PREVIEW_ANIM_TIMEanimatorSet.start()// 设置动画监听器,在动画结束后等待2秒,然后隐藏图片animatorSet.addListener(object : AnimatorListenerAdapter() {override fun onAnimationEnd(animation: Animator) {super.onAnimationEnd(animation)// 2秒后隐藏图片postDelayed({visibility = GONE}, CAMERA_FLASH_PREVIEW_SHOW_TIME)}})}}private fun errorHandle() {runOnUiThread {binding.content.text = DEFAULT_CONTENTbinding.loading.visibility = GONEmIsBarcodeRecognition = falsemTimeOut?.cancel()mTimeOut = null}}}

2.2 创建 activity_barcode_identify_demo.xml

        包括显示算法so库JNI模块返回的条形码识别到的商品信息。

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"android:id="@+id/parent"android:layout_width="match_parent"android:layout_height="match_parent"android:keepScreenOn="true"><com.agg.ui.AGGActionBarandroid:id="@+id/title"android:layout_width="wrap_content"android:layout_height="wrap_content"app:UIActionBarTitle="Barcode Identify"app:UITitleLevel="M"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent" /><com.agg.ui.AGGTextViewandroid:id="@+id/content"style="@style/TextBody5"android:layout_width="match_parent"android:layout_height="0dp"android:layout_marginHorizontal="32dp"android:layout_marginTop="16dp"android:layout_marginBottom="64dp"android:gravity="center_vertical|start"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toBottomOf="@id/title" /><androidx.camera.view.PreviewViewandroid:id="@+id/previewView"android:layout_width="138dp"android:layout_height="104dp"android:layout_marginEnd="24dp"android:layout_marginBottom="24dp"android:background="@drawable/shape_corner_20dp_stroke_4dp_ffffff"android:foreground="@drawable/shape_corner_20dp_stroke_4dp_ffffff"android:visibility="gone"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintEnd_toEndOf="parent" /><com.agg.ui.AGGCircleImageViewandroid:id="@+id/flashPreview"android:layout_width="138dp"android:layout_height="104dp"android:layout_marginEnd="24dp"android:layout_marginBottom="24dp"android:contentDescription="@null"android:visibility="gone"app:borderColor="#FFFFC810"app:borderWidth="4dp"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintEnd_toEndOf="parent"app:radius="20dp" /><com.agg.ui.AGGIdentifyandroid:id="@+id/loading"android:layout_width="wrap_content"android:layout_height="wrap_content"app:UIContent="Open Camera..."app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent" /></androidx.constraintlayout.widget.ConstraintLayout>

2.3 创建 AlgorithmLibHelper.kt

        访问条形码算法的帮助类,进行封装隔离,通过传入拍照后的图片路径,调用算法so库JNI模块。

object AlgorithmLibHelper {val productBeanLiveData = MutableLiveData<ProductBean>()private val TAG = AlgorithmLibHelper::class.java.simpleNameprivate var algorithmLib: AlgorithmLib? = nullfun init(context: Context) {Log.i(TAG, "init: ")val jsonFilePath = getJsonFilePath(context, "barcode_information_final.json")Log.i(TAG, "init: jsonFilePath=$jsonFilePath")algorithmLib = AlgorithmLib()algorithmLib?.initMatch(jsonFilePath)}fun identifyBarcode(imagePath: String) = runBlocking {Log.i(TAG, "identifyBarcode: imagePath=$imagePath")val identifyBarContent = algorithmLib?.matchBarcode(imagePath) ?: ""Log.i(TAG, "identifyBarcode: identifyBarContent=$identifyBarContent")if (identifyBarContent.isNotEmpty()) {try {val productInfo = GsonUtils.fromJson(identifyBarContent, ProductInfo::class.java)productBeanLiveData.postValue(productInfo.product_info)} catch (e: Exception) {e.printStackTrace()productBeanLiveData.postValue(ProductBean())}} else {productBeanLiveData.postValue(ProductBean())}}fun release() {Log.i(TAG, "release: ")algorithmLib = null}}

2.4 创建 AssetsHelper.kt

        由于算法库的商品数据库,采用的本地json数据库,所以当前技术方案就是通过app预先在源代码路径中放好json文件,然后动态将json文件拷贝到应用路径下,方便算法库读取与查询。

object AssetsHelper {fun getJsonFilePath(context: Context, assetName: String): String {val targetPath =AGGFileUtils.getMediaOutputDirectory(context as ContextWrapper).absolutePath + File.separator + assetNamecopyAssetToFile(context, assetName, targetPath)return targetPath}private fun copyAssetToFile(context: Context, assetName: String, targetPath: String) {val assetManager = context.assetsval inputStream: InputStream = assetManager.open(assetName)val file = File(targetPath)val outputStream = FileOutputStream(file)val buffer = ByteArray(1024)var read: Intwhile (inputStream.read(buffer).also { read = it } != -1) {outputStream.write(buffer, 0, read)}outputStream.flush()outputStream.close()inputStream.close()}}

        在src/main/assets/ 路径下放置 barcode_information_final.json 文件。

2.5 创建 ProductBean.kt

        商品信息的数据Bean,通过算法库返回的商品Json数据格式转换。

data class ProductBean(var product_name: String = "",var brand: String = "",var specifications: String = "",var price: String = "",var country_of_origin: String = "",var tax_rate: String = "",var tax_code: String = "",var function_and_use: String = "",
)data class ProductInfo(var product_info: ProductBean)/*
{"product_info": {"brand": "舒肤佳","country_of_origin": "中国","function_and_use": "用于日常清洁皮肤,有效去除污垢和细菌","price": "¥3.50","product_name": "香皂","specifications": "115G","tax_code": "1","tax_rate": "13%"}
}
*/

3. ⚛️ 算法so库JNI模块

  1. 新建CMakeLists.txt,引入算法so库以及头文件;

  2. 新建cpp文件,调用算法so库方法;

  3. 新建native方法,加载JNI模块生成的库以及映射对应方法。

3.1 新建CMakeLists.txt,引入算法so库以及头文件

1)CMakeLists.txt 内容如下:
# 1. 设置 CMake 的最低版本要求
cmake_minimum_required(VERSION 3.22.1)# 2. 设置项目名称和支持的语言
project(BarcodeIdentify C CXX)# 3.1 指定头文件目录
include_directories(${PROJECT_SOURCE_DIR}/include)# 3.2 添加一个共享库目标:创建一个共享库来使用.so 库
add_library( # Sets the name of the library.barcode_match_jni# Sets the library as a shared library.SHARED# Provides a relative path to your source file(s).BarcodeMatchJni.cpp)
add_library( # Sets the name of the library.lib_barcode_match_interface# Sets the library as a shared library.SHARED# Provides a relative path to your source file(s).IMPORTED)
add_library( # Sets the name of the library.lib_barcode_match# Sets the library as a shared library.SHARED# Provides a relative path to your source file(s).IMPORTED)
add_library( # Sets the name of the library.lib_ZXing# Sets the library as a shared library.SHARED# Provides a relative path to your source file(s).IMPORTED)# 4. 设置 .so 文件的路径
set_target_properties(lib_barcode_match_interfacePROPERTIES IMPORTED_LOCATION${PROJECT_SOURCE_DIR}/lib/armeabi-v7a/libbarcode_match_interface.so)
set_target_properties(lib_barcode_matchPROPERTIES IMPORTED_LOCATION${PROJECT_SOURCE_DIR}/lib/armeabi-v7a/libbarcode_match.so)
set_target_properties(lib_ZXingPROPERTIES IMPORTED_LOCATION${PROJECT_SOURCE_DIR}/lib/armeabi-v7a/libZXing.so)# 5.1 链接系统库(例如 log 库)
find_library( # Sets the name of the path variable.log-lib# Specifies the name of the NDK library that# you want CMake to locate.log)
# 5.2 链接.so 库到目标
target_link_libraries( # Specifies the target library.barcode_match_jnilib_barcode_match_interfacelib_barcode_matchlib_ZXing# Links the target library to the log library# included in the NDK.${log-lib})
2)引入算法so库以及头文件

        算法 barcode_match_interface.h 头文件如下:

#ifndef BARCODE_MATCH_INTERFACE_H
#define BARCODE_MATCH_INTERFACE_H
#include <string>
class barcode_match_interface
{
private:void *barcode_match;
public:barcode_match_interface(/* args */);~barcode_match_interface();int init_barcode_match_interface(std::string json_input_path);std::string barcode_match_process(std::string input_img_path);
};#endif

3.2 新建cpp文件,调用算法so库方法

#include <jni.h>
#include <string>
#include <android/log.h>
#include "barcode_match_interface.h" // 包含算法库的头文件#define ALOGD(tag, ...) __android_log_print(ANDROID_LOG_DEBUG, tag, __VA_ARGS__)// 创建一个全局指针,用于存储 BarcodeMatch 类的实例
barcode_match_interface* barcodeMatchInstance = nullptr;// 实现 JNI 方法:initMatch
extern "C"
JNIEXPORT jint JNICALL
Java_com_agg_mocamera_portal_feature_demo_lib_AlgorithmLib_initMatch(JNIEnv* env, jobject thiz, jstring jsonInputPath) {const char* nativeJsonInputPath = env->GetStringUTFChars(jsonInputPath, nullptr);barcodeMatchInstance = new barcode_match_interface();int result = barcodeMatchInstance->init_barcode_match_interface(std::string(nativeJsonInputPath));env->ReleaseStringUTFChars(jsonInputPath, nativeJsonInputPath);if (result != 0) {delete barcodeMatchInstance;barcodeMatchInstance = nullptr;}return result;return 0;
}// 实现 JNI 方法:matchBarcode
extern "C"
JNIEXPORT jstring JNICALL
Java_com_agg_mocamera_portal_feature_demo_lib_AlgorithmLib_matchBarcode(JNIEnv *env, jobject thiz, jstring inputImagePath) {const char* nativeInputImagePath = env->GetStringUTFChars(inputImagePath, nullptr);std::string result;if (barcodeMatchInstance != nullptr) {result = barcodeMatchInstance->barcode_match_process(std::string(nativeInputImagePath));} else {result = "Error: BarcodeMatch instance not initialized";}ALOGD("TAG-AGG","%s", result.c_str());env->ReleaseStringUTFChars(inputImagePath, nativeInputImagePath);return env->NewStringUTF(result.c_str());
}

3.3 新建native方法,加载JNI模块生成的库以及映射对应方法

class AlgorithmLib {external fun initMatch(jsonInputPath: String): Intexternal fun matchBarcode(imagePath: String): Stringcompanion object {init {System.loadLibrary("barcode_match_jni")}}}

3.4 配置 build.gradle 文件

        在build.gradle文件中,确保项目支持所需的ABI架构。

android {defaultConfig {ndk {abiFilters 'armeabi-v7a'}}

        在 build.gradle 文件中配置 CMake。

android {externalNativeBuild {cmake {path "src/main/cpp/CMakeLists.txt"}}

注:对于算法条形码识别模块,由于篇幅与技术栈问题,本文就不再赘述。

4. ✅ 小结

        对于条形码识别,本文只是一个基础实现方案,更多业务细节请参考产品逻辑去实现。

        另外,由于本人能力有限,如有错误,敬请批评指正,谢谢。


本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.pswp.cn/news/910626.shtml
繁体地址,请注明出处:http://hk.pswp.cn/news/910626.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

华为云 Flexus+DeepSeek 征文|基于 CCE 集群部署 Dify 平台工作流:科研论文翻译与 SEO 优化工具的全流程设计实践

华为云 FlexusDeepSeek 征文&#xff5c;基于 CCE 集群部署 Dify 平台工作流&#xff1a;科研论文翻译与 SEO 优化工具的全流程设计实践 背景 作为被科研论文折磨已久的大学生&#xff0c;希望研究成果能被更多人看到&#xff0c;尤其是在学术全球化的趋势下&#xff0c;论文翻…

C++对象继承详解:从入门到精通

继承是面向对象编程的三大特性之一&#xff0c;也是C中实现代码复用和多态的重要机制。本文将带你深入理解C继承的核心概念与应用。 一、继承的基本概念 1.1 什么是继承&#xff1f; 继承允许我们基于已有的类创建新类&#xff0c;新类&#xff08;派生类&#xff09;可以继…

Jenkins安装与配置全攻略:从入门到高级功能实战

在DevOps实践中,Jenkins作为最流行的持续集成工具之一,扮演着至关重要的角色。本文将全面介绍Jenkins的安装、配置及高级功能使用,帮助开发、运维和测试团队快速搭建高效的CI/CD流水线。 一、Jenkins安装 1.1 环境准备 Jenkins官网:https://jenkins.io 注意:Jenkins 2…

[OS_26] 计算机系统安全 | CIA原则 | 侧信道攻击

系统调用是唯一访问操作系统对象的途径 拒绝越权访问 →→ Confidentiality拒绝越权修改 →→ Integrity(再加上公平资源调度 →→ Availability) 在操作系统 API 上&#xff0c;我们可以构建命令行工具、编译器、数据库、浏览器等丰富的应用。 当越来越多用户开始共享计算机、…

Chromium 136 编译指南 macOS篇:编译优化技巧(六)

1. 引言 在现代软件开发的高效化进程中&#xff0c;编译优化已经从简单的性能调优发展为一门综合性的工程科学。对于Chromium 136这样一个包含超过2500万行代码的超大规模项目而言&#xff0c;编译时间往往成为制约开发效率的关键瓶颈。在典型的开发场景中&#xff0c;一次完整…

Spark教程6:Spark 底层执行原理详解

文章目录 一、整体架构概述二、核心组件详解1. SparkContext2. DAG Scheduler3. Task Scheduler4. Executor 三、作业执行流程1. DAG 生成与 Stage 划分2. Task 调度与执行3. 内存管理 四、Shuffle 机制详解1. Shuffle 过程2. Shuffle 优化 五、内存管理机制1. 统一内存管理&am…

xlsx-style 插件批量导出多个sheet表格excel中遇到的问题及解决

Vue2中 前端界面导出表格&#xff0c;使用XLSXS插件版本(^0.8.13)导出表格存在表格背景颜色无法正常展示&#xff0c;百分比数据没有正常展示 【有条件的尽量先升级高版本插件&#xff0c;此插件版本对样式支持度不够】 优先考虑插件版本升级 同样的使用方法在vue3中没有出现错…

Java后端与Vue前端项目部署全流程:从环境配置到Nginx反向代理

文章目录 1. 准备项目所需的环境2. 后端项目打包步骤 1&#xff1a;使用 Maven 打包步骤 2&#xff1a;定位生成的 JAR 包步骤 3&#xff1a;上传 JAR 包到 Linux 系统步骤 4&#xff1a;验证 Java 环境步骤 5&#xff1a;启动 JAR 包 3. 前端项目打包步骤 1&#xff1a;执行 B…

Mybatis踩坑之一天

background: 对接AML系统&#xff0c;日间实时需要送交易对手要素过去&#xff08;目前主要是交易对手全名&#xff09;&#xff0c;夜间需要将历史交易送AML进行回溯&#xff0c;交互方式是文件。文件要素为日期、对手类型、对手名、交易流水之类。 设置对送AML的文件设计表…

【PyTorch】分布式训练报错记录-ERROR:torch.distributed.elastic.multiprocessing.api:failed (exitcode: 1)

最近&#xff0c;我在服务器上起基于PyTorch分布式框架的预训练实验&#xff0c;起初实验都在顺利进行&#xff0c;但是当我们把模型的深度与宽度调大之后&#xff0c;模型在训练几代之后便会出现如下的报错&#xff1a; WARNING:torch.distributed.elastic.multiprocessing.a…

有哪些词编码模型

有哪些词编码模型 词编码模型:是将自然语言符号映射为稠密的高维向量,使语义相近的词汇在向量空间中位置接近。 不过,也有部分模型会考虑字母或字符信息,如基于字节对编码(BPE)的模型会将单词拆分成子词,这里的子词可能是字母组合。 词编码模型的原理主要是通过机器学…

Mono 功能介绍与使用示例

Mono 功能介绍与使用示例 一、核心概念与特性 Mono 是 Spring Reactor 框架中的核心组件&#xff0c;属于响应式编程&#xff08;Reactive Programming&#xff09;模型&#xff0c;专注于处理包含 0 或 1 个元素 的异步序列[1][2][5]。其核心特点包括&#xff1a; 异步非阻…

5060Ti双显卡+LLaMA-factory大模型微调环境搭建

查看环境确定安装版本安装CUDA12.8安装Anaconda安装Visual Studio C桌面开发环境&#xff08;编译llama.cpp需要&#xff09;安装cmake(编译llama.cpp需要)安装llama.cpp(用于量化)安装huggingface-cli安装llama-factory安装PyTorch2.7.0安装bitsandbytes安装flash-attention加…

Lnmp和XunRuiCMS一键部署(Rocky linux)

先上传XunRuiCMS-Study.zip包到当前目录&#xff0c;可以去官网下载 #!/bin/bash # function: install nginx mysql php on Rocky Linux 9.5 with fixed PHP-FPM configip$(hostname -I | awk {print $1}) yhxunrui passwordxunrui123# 检查是否为root用户 if [ "$USER&qu…

高精度OFDR设备在CPO交换机中的应用

光电共封装&#xff08;CPO&#xff09;交换机的特点 核心需求&#xff1a;CPO将光模块与交换芯片集成封装&#xff0c;缩短电互连距离&#xff0c;降低功耗和延迟&#xff0c;但需解决以下挑战&#xff1a; 1.光器件微型化&#xff1a;硅光芯片、光纤阵列等需高精度制造。 …

Vulkan 通过 CMake 集成 Dear ImGUI

一、 目录与文件部署 从官网获取 IMGUI 代码库&#xff0c;在项目 extern 目录下新建 imgui 目录&#xff0c;将相关文件复制进去&#xff0c;构建出如下目录结构&#xff1a; . ├── build ├── extern │ ├── glfw │ ├── glm │ └── imgui │ ├…

Linux设备框架:kset与kobject基本介绍

系列文章目录 Linux设备框架&#xff1a;kset与kobject基本介绍 [link] Linux设备框架&#xff1a;kset与kobject源码分析 [link] kset与kobject基本介绍 一、前言二、kobject、kset和设备的关系2.1 kset 结构体2.2 kobject 结构体 三、总结 一、前言 Linux 设备模型如同一座拥…

【AI论文】扩展大型语言模型(LLM)智能体在测试时的计算量

摘要&#xff1a;扩展测试时的计算量在提升大型语言模型&#xff08;LLMs&#xff09;的推理能力方面已展现出显著成效。在本研究中&#xff0c;我们首次系统地探索了将测试时扩展方法应用于语言智能体&#xff0c;并研究了该方法在多大程度上能提高其有效性。具体而言&#xf…

LeapMotion-PhysicalHandsManager 类详解

PhysicalHandsManager 类详解 这个类是 Ultraleap 物理手交互系统的核心管理器,负责处理手部物理交互的不同模式。下面我将详细解析这个类的结构和功能: 类概述 PhysicalHandsManager 继承自 LeapProvider,是物理手交互系统的中央控制器: public class PhysicalHandsMa…

vue-22(理解组合式 API:setup、ref、reactive)

Vue.js 中的组合式 API 代表了我们构建和组织组件方式的重大转变。它为传统的选项式 API 提供了一种更灵活、更强大的替代方案&#xff0c;尤其适用于复杂的应用程序。本章将深入探讨组合式 API 的核心概念&#xff1a;setup函数、ref和reactive&#xff0c;为你构建更可维护、…