LightOnOCR-2-1B教程:从安装到实战完整指南

LightOnOCR-2-1B教程:从安装到实战完整指南

1. 引言

你是不是经常遇到这样的烦恼:手头有一堆纸质文档需要数字化,或者收到PDF文件想要提取里面的文字,但传统的OCR工具要么识别不准,要么速度太慢?今天我要介绍的LightOnOCR-2-1B,可能就是你要找的解决方案。

这个仅有10亿参数的多语言OCR模型,在保持小巧体积的同时,实现了令人惊艳的识别精度和处理速度。它支持11种语言(中文、英文、日文、法文、德文、西班牙文、意大利文、荷兰文、葡萄牙文、瑞典文、丹麦文),无论是技术文档、商业报表还是学术论文,都能高效处理。

最让人惊喜的是,尽管模型体积只有同类大模型的九分之一,但在权威测试中准确率反而更高,处理速度还快了3倍多。这意味着你可以用更少的硬件资源,完成更多的文档处理任务。

本教程将手把手带你从零开始,完整掌握LightOnOCR-2-1B的安装、配置和使用方法。无论你是开发者、研究人员,还是普通用户,都能快速上手这个强大的OCR工具。

2. 环境准备与快速部署

2.1 系统要求

在开始之前,请确保你的系统满足以下基本要求:

  • 操作系统:Linux(推荐Ubuntu 20.04+)或Windows WSL2
  • Python版本:3.8或更高版本
  • GPU内存:至少16GB(推荐24GB以上以获得最佳性能)
  • 系统内存:至少32GB RAM
  • 磁盘空间:至少10GB可用空间(用于模型文件和依赖包)

如果你没有GPU设备,也可以使用CPU运行,但处理速度会显著降低。对于生产环境,强烈建议使用GPU加速。

2.2 一键部署脚本

为了简化安装过程,我准备了一个完整的部署脚本,可以自动处理所有依赖和环境配置:

#!/bin/bash

# LightOnOCR-2-1B 自动部署脚本
echo "开始安装 LightOnOCR-2-1B..."

# 创建项目目录
mkdir -p ~/LightOnOCR-2-1B
cd ~/LightOnOCR-2-1B

# 安装系统依赖
sudo apt update
sudo apt install -y python3-pip python3-venv curl wget

# 创建Python虚拟环境
python3 -m venv ocr_env
source ocr_env/bin/activate

# 安装Python依赖
pip install --upgrade pip
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
pip install transformers>=4.40.0 gradio>=4.20.0 pypdfium2>=4.30.0
pip install vllm>=0.3.2 requests pillow

# 下载模型文件(如果直接使用Hugging Face的自动下载,可跳过此步)
echo "模型将在首次运行时自动从Hugging Face下载"

# 创建启动脚本
cat > start_ocr.sh << 'EOF'
#!/bin/bash
cd ~/LightOnOCR-2-1B
source ocr_env/bin/activate

# 启动Gradio前端界面
python -c "
from transformers import LightOnOcrForConditionalGeneration, LightOnOcrProcessor
import gradio as gr
import torch

# 加载模型
device = 'cuda' if torch.cuda.is_available() else 'cpu'
model = LightOnOcrForConditionalGeneration.from_pretrained('lightonai/LightOnOCR-2-1B', torch_dtype=torch.float16).to(device)
processor = LightOnOcrProcessor.from_pretrained('lightonai/LightOnOCR-2-1B')

def extract_text(image):
    try:
        # 准备输入
        conversation = [{'role': 'user', 'content': [{'type': 'image', 'image': image}]}]
        inputs = processor.apply_chat_template(conversation, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors='pt')
        inputs = {k: v.to(device) for k, v in inputs.items()}
        
        # 生成文本
        output_ids = model.generate(**inputs, max_new_tokens=1024)
        generated_text = processor.decode(output_ids[0], skip_special_tokens=True)
        return generated_text
    except Exception as e:
        return f'处理出错: {str(e)}'

# 创建Gradio界面
iface = gr.Interface(
    fn=extract_text,
    inputs=gr.Image(type='pil', label='上传图片'),
    outputs=gr.Textbox(label='识别结果'),
    title='LightOnOCR-2-1B 文字识别',
    description='上传图片提取文字内容'
)

iface.launch(server_name='0.0.0.0', server_port=7860)
"
EOF

chmod +x start_ocr.sh

echo "安装完成!"
echo "启动服务: ./start_ocr.sh"
echo "Web界面: http://localhost:7860"

将上述脚本保存为install_ocr.sh,然后运行:

chmod +x install_ocr.sh
./install_ocr.sh

脚本会自动完成所有环境的配置,包括创建虚拟环境、安装依赖包,并生成启动脚本。

3. 基础使用教程

3.1 Web界面使用

部署完成后,最简单的使用方式就是通过Web界面:

  1. 启动服务:

    cd ~/LightOnOCR-2-1B
    ./start_ocr.sh
    
  2. 访问界面:在浏览器中打开 http://localhost:7860(如果是在远程服务器上部署,请将localhost替换为服务器IP地址)

  3. 上传图片:点击上传按钮,选择要识别的图片文件(支持PNG、JPEG格式)

  4. 提取文字:点击"Submit"按钮,系统会自动识别图片中的文字并显示结果

界面操作非常简单直观,即使没有技术背景的用户也能快速上手。系统会自动处理图片预处理、文字识别、后处理等所有步骤,你只需要等待结果即可。

3.2 命令行使用

对于喜欢命令行的用户,也可以通过Python脚本直接调用:

#!/usr/bin/env python3
# ocr_cli.py - 命令行OCR工具

import argparse
import torch
from PIL import Image
from transformers import LightOnOcrForConditionalGeneration, LightOnOcrProcessor

def main():
    parser = argparse.ArgumentParser(description='LightOnOCR-2-1B 命令行工具')
    parser.add_argument('image_path', help='要识别的图片路径')
    parser.add_argument('--output', '-o', help='输出文件路径(可选)')
    args = parser.parse_args()

    # 加载模型
    device = "cuda" if torch.cuda.is_available() else "cpu"
    print(f"使用设备: {device}")
    
    print("加载模型中...")
    model = LightOnOcrForConditionalGeneration.from_pretrained(
        "lightonai/LightOnOCR-2-1B", 
        torch_dtype=torch.float16
    ).to(device)
    processor = LightOnOcrProcessor.from_pretrained("lightonai/LightOnOCR-2-1B")

    # 加载图片
    print("处理图片...")
    image = Image.open(args.image_path).convert('RGB')

    # 准备输入
    conversation = [{"role": "user", "content": [{"type": "image", "image": image}]}]
    inputs = processor.apply_chat_template(
        conversation,
        add_generation_prompt=True,
        tokenize=True,
        return_dict=True,
        return_tensors="pt",
    )
    inputs = {k: v.to(device) for k, v in inputs.items()}

    # 生成文本
    print("识别文字中...")
    output_ids = model.generate(**inputs, max_new_tokens=1024)
    generated_ids = output_ids[0, inputs["input_ids"].shape[1]:]
    result_text = processor.decode(generated_ids, skip_special_tokens=True)

    # 输出结果
    if args.output:
        with open(args.output, 'w', encoding='utf-8') as f:
            f.write(result_text)
        print(f"结果已保存到: {args.output}")
    else:
        print("\n识别结果:")
        print("=" * 50)
        print(result_text)
        print("=" * 50)

if __name__ == "__main__":
    main()

使用方法:

# 识别单张图片
python ocr_cli.py example.jpg

# 识别图片并保存结果到文件
python ocr_cli.py example.jpg -o result.txt

4. API接口调用

4.1 启动API服务

对于需要集成到其他系统的场景,可以使用vLLM启动API服务:

# 启动API服务
vllm serve lightonai/LightOnOCR-2-1B \
    --host 0.0.0.0 \
    --port 8000 \
    --limit-mm-per-prompt '{"image": 1}' \
    --mm-processor-cache-gb 0 \
    --no-enable-prefix-caching

服务启动后,会提供两个端点:

  • 前端界面: http://<服务器IP>:7860
  • 后端API: http://<服务器IP>:8000/v1/chat/completions

4.2 Python客户端调用

import requests
import base64
from PIL import Image
import io

def ocr_api_call(image_path, api_url="http://localhost:8000/v1/chat/completions"):
    """
    调用LightOnOCR API进行文字识别
    
    Args:
        image_path: 图片文件路径
        api_url: API端点地址
    
    Returns:
        str: 识别结果文本
    """
    # 读取图片并转换为base64
    with Image.open(image_path) as img:
        img = img.convert('RGB')
        buffer = io.BytesIO()
        img.save(buffer, format='JPEG')
        image_base64 = base64.b64encode(buffer.getvalue()).decode('utf-8')
    
    # 准备请求数据
    payload = {
        "model": "lightonai/LightOnOCR-2-1B",
        "messages": [{
            "role": "user",
            "content": [{
                "type": "image_url",
                "image_url": {"url": f"data:image/jpeg;base64,{image_base64}"}
            }]
        }],
        "max_tokens": 4096,
        "temperature": 0.1,
    }
    
    # 发送请求
    response = requests.post(api_url, json=payload)
    if response.status_code == 200:
        return response.json()['choices'][0]['message']['content']
    else:
        raise Exception(f"API调用失败: {response.status_code} - {response.text}")

# 使用示例
result = ocr_api_call("example.jpg")
print(result)

4.3 批量处理示例

如果你需要处理大量图片,可以使用以下批量处理脚本:

import os
import concurrent.futures
from tqdm import tqdm

def batch_process_images(image_folder, output_folder, api_url):
    """
    批量处理文件夹中的所有图片
    
    Args:
        image_folder: 图片文件夹路径
        output_folder: 输出文件夹路径
        api_url: API地址
    """
    # 创建输出文件夹
    os.makedirs(output_folder, exist_ok=True)
    
    # 获取所有图片文件
    image_extensions = ['.jpg', '.jpeg', '.png', '.bmp']
    image_files = [
        f for f in os.listdir(image_folder)
        if os.path.splitext(f)[1].lower() in image_extensions
    ]
    
    print(f"找到 {len(image_files)} 张图片待处理")
    
    # 使用线程池并行处理
    with concurrent.futures.ThreadPoolExecutor(max_workers=4) as executor:
        futures = []
        for image_file in image_files:
            input_path = os.path.join(image_folder, image_file)
            output_path = os.path.join(output_folder, f"{os.path.splitext(image_file)[0]}.txt")
            futures.append(executor.submit(process_single_image, input_path, output_path, api_url))
        
        # 显示进度
        for future in tqdm(concurrent.futures.as_completed(futures), total=len(futures)):
            try:
                future.result()
            except Exception as e:
                print(f"处理失败: {e}")

def process_single_image(input_path, output_path, api_url):
    """处理单张图片并保存结果"""
    result = ocr_api_call(input_path, api_url)
    with open(output_path, 'w', encoding='utf-8') as f:
        f.write(result)

# 使用示例
batch_process_images("./input_images", "./output_texts", "http://localhost:8000/v1/chat/completions")

5. 实战应用案例

5.1 文档数字化处理

假设你有一批纸质文档需要数字化,可以按照以下流程操作:

  1. 扫描文档:使用扫描仪将纸质文档扫描为图片,建议设置分辨率为300DPI
  2. 图片预处理:确保图片清晰、端正,避免过度阴影或反光
  3. 批量处理:使用上面的批量处理脚本自动识别所有图片
  4. 结果校对:对识别结果进行快速校对和修正
# 文档数字化完整示例
def digitize_documents(scanned_folder, output_folder):
    """
    完整文档数字化流程
    """
    print("启动文档数字化流程...")
    
    # 1. 检查图片质量
    print("检查图片质量...")
    for img_file in os.listdir(scanned_folder):
        img_path = os.path.join(scanned_folder, img_file)
        with Image.open(img_path) as img:
            width, height = img.size
            if width < 500 or height < 500:
                print(f"警告: {img_file} 分辨率过低,可能影响识别效果")
    
    # 2. 批量处理
    print("开始文字识别...")
    batch_process_images(scanned_folder, output_folder, "http://localhost:8000/v1/chat/completions")
    
    # 3. 生成处理报告
    generate_report(output_folder)
    
    print("文档数字化完成!")

def generate_report(output_folder):
    """生成处理报告"""
    txt_files = [f for f in os.listdir(output_folder) if f.endswith('.txt')]
    total_chars = 0
    
    for txt_file in txt_files:
        with open(os.path.join(output_folder, txt_file), 'r', encoding='utf-8') as f:
            content = f.read()
            total_chars += len(content)
    
    report = f"""
    文档数字化处理报告
    ====================
    处理时间: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
    处理文件数: {len(txt_files)}
    总字符数: {total_chars}
    平均每文件: {total_chars//len(txt_files) if txt_files else 0} 字符
    """
    
    with open(os.path.join(output_folder, 'processing_report.txt'), 'w', encoding='utf-8') as f:
        f.write(report)
    
    print(report)

5.2 多语言文档处理

LightOnOCR-2-1B支持11种语言,非常适合处理多语言文档:

def detect_and_process_multilingual(image_path):
    """
    处理多语言文档示例
    """
    # 首先识别文字
    text = ocr_api_call(image_path)
    
    # 简单语言检测(实际应用中可以使用专业语言检测库)
    languages = {
        '中文': ['的', '是', '在', '有', '我'],
        '英文': ['the', 'and', 'of', 'to', 'a'],
        '日文': ['の', 'は', 'に', 'を', 'です'],
        # 可以添加其他语言特征词...
    }
    
    detected_langs = []
    for lang, keywords in languages.items():
        count = sum(text.count(keyword) for keyword in keywords)
        if count > 2:  # 至少出现3个特征词
            detected_langs.append(lang)
    
    print(f"识别文字: {text[:100]}...")
    print(f"检测到语言: {', '.join(detected_langs) if detected_langs else '未知语言'}")
    
    return text, detected_langs

5.3 表格数据提取

对于包含表格的文档,LightOnOCR-2-1B能够很好地保持表格结构:

def extract_table_data(image_path):
    """
    提取图片中的表格数据
    """
    text = ocr_api_call(image_path)
    
    # 简单的表格解析逻辑
    lines = text.split('\n')
    table_data = []
    current_row = []
    
    for line in lines:
        line = line.strip()
        if line:
            # 假设表格单元格由多个空格分隔
            if '  ' in line:
                cells = [cell.strip() for cell in line.split('  ') if cell.strip()]
                if len(cells) > 1:  # 可能是表格行
                    table_data.append(cells)
            else:
                # 单行文本,可能是表格标题或内容
                current_row.append(line)
    
    print("提取到的表格数据:")
    for i, row in enumerate(table_data):
        print(f"行 {i+1}: {row}")
    
    return table_data

6. 性能优化建议

6.1 图片预处理优化

为了获得最佳识别效果,建议对输入图片进行适当的预处理:

def preprocess_image(image_path, output_path=None):
    """
    图片预处理函数
    """
    from PIL import Image, ImageEnhance, ImageFilter
    
    with Image.open(image_path) as img:
        # 转换为RGB
        img = img.convert('RGB')
        
        # 调整大小(最长边不超过1540像素)
        max_size = 1540
        width, height = img.size
        if max(width, height) > max_size:
            scale = max_size / max(width, height)
            new_size = (int(width * scale), int(height * scale))
            img = img.resize(new_size, Image.Resampling.LANCZOS)
        
        # 增强对比度
        enhancer = ImageEnhance.Contrast(img)
        img = enhancer.enhance(1.2)
        
        # 锐化
        img = img.filter(ImageFilter.SHARPEN)
        
        if output_path:
            img.save(output_path, format='JPEG', quality=95)
        
        return img

# 使用预处理
processed_image = preprocess_image('original.jpg', 'processed.jpg')
result = ocr_api_call('processed.jpg')

6.2 批量处理优化

当需要处理大量文档时,可以考虑以下优化策略:

  1. 并行处理:使用多进程或多线程并行处理多个图片
  2. 内存管理:及时清理不再需要的图片数据,避免内存溢出
  3. 错误重试:添加重试机制处理偶尔的网络或处理错误
  4. 进度保存:保存处理进度,支持断点续处理
class BatchOCRProcessor:
    """批量OCR处理器"""
    
    def __init__(self, api_url, max_workers=4, retries=3):
        self.api_url = api_url
        self.max_workers = max_workers
        self.retries = retries
        self.processed_files = set()
        self.load_progress()
    
    def load_progress(self):
        """加载处理进度"""
        try:
            with open('progress.json', 'r') as f:
                self.processed_files = set(json.load(f))
        except FileNotFoundError:
            self.processed_files = set()
    
    def save_progress(self):
        """保存处理进度"""
        with open('progress.json', 'w') as f:
            json.dump(list(self.processed_files), f)
    
    def process_with_retry(self, image_path, output_path):
        """带重试的处理函数"""
        for attempt in range(self.retries):
            try:
                if image_path in self.processed_files:
                    print(f"跳过已处理文件: {image_path}")
                    return True
                
                result = ocr_api_call(image_path, self.api_url)
                with open(output_path, 'w', encoding='utf-8') as f:
                    f.write(result)
                
                self.processed_files.add(image_path)
                self.save_progress()
                return True
                
            except Exception as e:
                print(f"尝试 {attempt + 1} 失败: {e}")
                time.sleep(2 ** attempt)  # 指数退避
        
        return False
    
    def process_batch(self, image_folder, output_folder):
        """处理批量图片"""
        os.makedirs(output_folder, exist_ok=True)
        
        image_files = [
            f for f in os.listdir(image_folder)
            if f.lower().endswith(('.jpg', '.jpeg', '.png', '.bmp'))
        ]
        
        with concurrent.futures.ThreadPoolExecutor(max_workers=self.max_workers) as executor:
            futures = []
            for img_file in image_files:
                input_path = os.path.join(image_folder, img_file)
                output_path = os.path.join(output_folder, f"{os.path.splitext(img_file)[0]}.txt")
                futures.append(executor.submit(self.process_with_retry, input_path, output_path))
            
            # 等待所有任务完成
            results = []
            for future in tqdm(concurrent.futures.as_completed(futures), total=len(futures)):
                results.append(future.result())
        
        success_count = sum(results)
        print(f"处理完成: {success_count}/{len(image_files)} 成功")

7. 常见问题解答

7.1 安装部署问题

Q: 安装过程中出现权限错误怎么办? A: 确保你有足够的权限安装系统包,或者使用虚拟环境安装:

# 使用虚拟环境避免权限问题
python -m venv myenv
source myenv/bin/activate
pip install -r requirements.txt

Q: 模型下载速度很慢怎么办? A: 可以设置镜像源加速下载:

# 设置Hugging Face镜像
export HF_ENDPOINT=https://hf-mirror.com

# 或者使用国内镜像
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

7.2 使用过程中的问题

Q: 识别结果不准确怎么办? A: 尝试以下优化措施:

  1. 确保图片清晰度高、光线均匀
  2. 使用图片预处理功能增强对比度和锐度
  3. 调整图片分辨率(推荐最长边1540像素)
  4. 对于特殊字体或布局,可以尝试微调模型

Q: 处理速度太慢怎么办? A: 考虑以下优化方案:

  1. 使用GPU加速而不是CPU
  2. 调整批量处理大小(batch size)
  3. 使用vLLM推理引擎而不是Transformers
  4. 对图片进行适当压缩(保持清晰度的前提下)

Q: 内存不足错误怎么解决? A: 内存不足时可以考虑:

  1. 减小处理图片的分辨率
  2. 减少批量处理的数量
  3. 使用torch.cuda.empty_cache()清理GPU缓存
  4. 升级硬件配置(推荐至少16GB GPU内存)

7.3 功能扩展问题

Q: 如何支持新的语言? A: LightOnOCR-2-1B已经支持11种语言,如果需要支持更多语言,可以考虑:

  1. 收集目标语言的训练数据
  2. 使用模型提供的微调功能进行适配训练
  3. 或者等待官方发布更多语言版本

Q: 能处理手写文字吗? A: 当前版本主要针对印刷体文字优化,对手写文字的支持有限。如果需要处理手写文字,建议:

  1. 使用专门的手写识别模型
  2. 或者收集手写数据对模型进行微调

8. 总结

通过本教程,你应该已经全面掌握了LightOnOCR-2-1B的安装、配置和使用方法。这个强大的OCR工具以其出色的性能表现和便捷的使用方式,为文档数字化处理提供了优秀的解决方案。

关键要点回顾:

  • 快速部署:使用提供的一键部署脚本,可以在几分钟内完成环境配置
  • 多种使用方式:支持Web界面、命令行工具和API接口,满足不同场景需求
  • 高性能识别:在准确率和处理速度方面都表现出色,支持11种语言
  • 实用功能:提供批量处理、表格提取、多语言支持等实用功能
  • 优化建议:通过图片预处理和并行处理等技术,可以进一步提升处理效率

下一步学习建议:

  1. 尝试处理你自己的文档,熟悉不同

相关推荐

手把手教你用Node.js模拟大麦APP下单请求(含滑块验证处理)

本文详细解析了如何使用Node.js模拟大麦APP下单请求的全流程,包括接口逆向、滑块验证处理和签名算法逆向等关键技术。通过实战案例和代码示例,帮助开发者掌握移动端API调用的核心要素,如动态参数构造、安全验证突破等,提升自动化下单的成功率和效率。

weixin_42569329的博客 355

LightOnOCR-2-1B生产部署:vLLM加速长序列OCR推理实战

光学字符识别(OCR)正从传统规则引擎迈向端到端视觉语言大模型,其核心挑战在于长视觉序列建模与高吞吐低延迟服务化。LightOnOCR-2-1B作为21亿参数的统一架构OCR大模型,突破了检测+识别两阶段范式,但带来显存峰值高、KV cache动态膨胀、输入异构性强等工程瓶颈。vLLM凭借PagedAttention和Continuous Batching机制,天然适配OCR任务中1500+视觉token的长上下文推理,在前缀缓存与显存复用上实现52.9%延迟下降;结合transformers生态定制Ada

Coding 814

SFM(structure from motion 从运动恢复结构)和MVS(multi-view stereo 多视图立体视觉)

主要目的:SFM是重建稀疏点云的,MVS重建的是稠密点云。 输入的数据:SFM是没有标定的数据,而MVS输入的是标定的数据。 为什么SFM无法重建出稠密的点云,但是MVS可以? SFM中我们用来做重建的点是由特征匹配提供的!这些匹配点天生不密集!MVS则几乎对照片中的每个像素点都进行匹配,几乎重建每一个像素点的三维坐标,这样得到的点的密集程度可以较接近图像为我们展示出的清晰度。 SFM和MVS关系 SFM给MVS算好了输入视角的位姿,内参,稀疏点云以及它们的共视关系,MVS再利用这些信息以及彩色图

Vpn_zc的博客 1万+

LightOnOCR-2-1B保姆级教程:从安装到文字提取

本文介绍了如何在星图GPU平台上自动化部署LightOnOCR-2-1B镜像,高效实现多语言文档文字提取。该镜像专为中英文混排表格、模糊日文收据等复杂场景优化,支持Web界面交互与API批量调用,适用于合同审核、发票识别、技术文档数字化等典型OCR应用。

weixin_35762258的博客 799

DataEaseV2.9 本地开发环境搭建与调试指南

本文详细指导如何搭建DataEase V2.9的本地开发环境,涵盖从软件准备、源码获取、数据库初始化到在IDEA中配置、编译和调试的全过程。重点解决了本地运行环境的关键配置与常见问题,帮助开发者高效开启DataEase的定制化开发与二次开发。

weixin_29290863的博客 144

OpenSpec 从入门到精通:AI 时代的最佳 SDD 范式

同样都是「先写规范再写代码」的开源 SDD 框架,OpenSpec(https://github.com/fission-ai/openspec) 展现出了极高的工程性价比,无论是使用 Claude Code、Cursor 还是 Aider,都可以无缝接入 OpenSpec 的规格管理层。这些问题需要人来做判断,AI 做不了这个主。整个流程跑下来,OpenSpec 产出的效果还是令人满意的,一些前期没有考虑到的细节 AI 都补上了,生成的相关文档也有利于开发人员的知识对齐,可以尝试在团队内部推广。

qq_39093474的博客 951

LightOnOCR-2-1B实战教程:使用OpenCV预处理提升模糊文档识别准确率

本文介绍了如何在星图GPU平台上自动化部署LightOnOCR-2-1B镜像,并利用OpenCV进行图像预处理以提升OCR识别效果。通过灰度化、二值化、降噪和锐化等步骤,该方案能有效处理模糊、光照不均的文档图片,显著提升文字提取的准确率,适用于文档数字化、图片文字识别等场景。

weixin_35391606的博客 1003

Vue3实战:企业级应用集成钉钉扫码登录全流程解析

本文详细解析了在Vue3企业级应用中集成钉钉扫码登录的全流程。从钉钉开放平台应用创建与配置,到Vue3前端如何优雅地嵌入并管理扫码组件,再到后端如何安全地处理OAuth 2.0授权码以换取用户信息并完成登录,提供了完整的实战代码与避坑指南。该方案能有效实现安全便捷的单点登录,统一企业身份认证。

weixin_29019241的博客 301

LightOnOCR-2-1B新手指南:从安装到识别的完整流程

本文介绍了如何在星图GPU平台上一键自动化部署LightOnOCR-2-1B镜像,实现高效的多语言文档识别。该镜像支持中英文等11种语言的文字提取,可广泛应用于合同数字化、表格数据转换和学术论文内容提取等场景,大幅提升文档处理效率。

weixin_42174098的博客 355

数字电路实验避坑指南:如何正确搭建主从JK触发器测试电路(附Proteus仿真)

本文详细解析了主从JK触发器的工作原理及实验搭建指南,重点解决了常见的Catching Problem现象,并提供了Proteus仿真优化方案。通过元器件选型、电路连接步骤和常见错误排查,帮助读者正确搭建测试电路,确保数字电路实验的稳定性和可靠性。

weixin_30790841的博客 472

基于Python的高考志愿辅助填报系统

在实际应用中,系统需要处理更复杂的数据,包括更多的高校和专业信息、更详细的录取规则、以及用户的历史选择等。系统需要提供用户友好的界面,让考生输入自己的信息和偏好,然后通过后端的模型计算出推荐的志愿列表。此外,系统还应该提供一些个性化的服务,如根据考生的输入动态调整推荐策略、保存用户的填报历史和偏好等。特征可能包括考生的分数、所在省份、文理科类别、专业偏好、高校的地理位置、排名、专业的就业前景等。3. **推荐逻辑**:根据用户的分数和专业偏好,结合历史录取数据,使用简单的算法来推荐可能录取的高校和专业。

coder_wwwdy的博客 1987

LightOnOCR-2-1B部署教程:WSL2环境下Windows主机部署LightOnOCR-2-1B

本文介绍了如何在星图GPU平台上自动化部署LightOnOCR-2-1B镜像,实现高效的多语言OCR文字识别。用户可通过该平台快速搭建识别系统,应用于文档数字化、图片文字提取等场景,显著提升信息处理效率。

weixin_30533301的博客 251

缺陷检测:使用PatchCore训练自己的数据集

必须包含有训练图片(无缺陷图片)、测试图片(缺陷图片)和ground_truth,并且ground_truth必须与对应图片的名称相同。同上一篇结果一样,我的输出为原始图片大小,但是不知道是不是因为图片不是正方形的,导致训练结果不好。编写一个脚本,重新规划数据集的路径规则,但是我稍微写复杂了一点,使用了类来操作。第二种(复杂):编写一个自己的Dataset,参考。第一种(简单):将数据集路径规则改成项目中。返回的必须是一个字典类型,可以阅读。本人此次使用的是第一种方法。运行时,参数部分直接输入。

xiaoxTai的博客 6488

LightOnOCR-2-1B部署教程:Ansible自动化部署LightOnOCR-2-1B集群

本文介绍了如何在星图GPU平台上自动化部署LightOnOCR-2-1B镜像,快速构建高可用OCR集群。依托平台能力,用户可一键完成多节点GPU环境适配、模型下载与服务启停,典型应用于合同、发票、收据等文档的批量文本提取与结构化输出,显著提升企业文档智能化处理效率。

weixin_33431149的博客 304

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

LightOnOCR-2-1B实战教程:curl命令调试API + Python requests封装调用

本文介绍了如何在星图GPU平台上自动化部署LightOnOCR-2-1B镜像,实现高效的多语言OCR文字识别。通过该平台,用户可以快速搭建服务并利用Python API调用,轻松从图片中提取多语言文本,适用于文档数字化、表格识别等场景,提升信息处理效率。

weixin_32312889的博客 762

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

LightOnOCR-2-1B快速上手:从安装到识别的完整教程

本文介绍了如何在星图GPU平台上一键自动化部署LightOnOCR-2-1B镜像,实现高效的多语言OCR文字识别。该镜像支持11种语言,能够快速从扫描文档或图片中提取文字内容,适用于文档数字化、表格信息提取等办公自动化场景,显著提升文本处理效率。

weixin_35762258的博客 447

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

LightOnOCR-2-1B保姆级教程:从安装到API调用的完整指南

本文介绍了如何在星图GPU平台上自动化部署LightOnOCR-2-1B镜像,快速构建高精度OCR服务。该镜像专为真实办公场景优化,支持中英等11种语言及复杂版式(如发票、含公式PDF),可实现3秒内精准提取可编辑文本,广泛应用于财务票据识别、科研文献解析等典型任务。

weixin_28746213的博客 113

LightOnOCR-2-1B保姆级教程:从安装到实战应用

本文介绍了如何在星图GPU平台上自动化部署LightOnOCR-2-1B镜像,高效实现高精度多语言文档OCR识别。该镜像专为真实业务场景优化,可精准提取中英文混排表格、手写发票及含数学公式的科研PDF,并一键导出结构化文本与LaTeX公式,广泛应用于合同审查、电商说明书处理与学术论文数字化。

weixin_36277197的博客 256

LightOnOCR-2-1B部署案例:高校AI课程实验平台——LightOnOCR-2-1B OCR实训项目

本文介绍了如何在星图GPU平台上自动化部署LightOnOCR-2-1B镜像,以构建高校AI课程实验平台。该平台简化了OCR模型的部署流程,学生可通过其完成图片文字识别实训项目,例如快速准确地从包含复杂表格的图片中提取中英文混合文字。

weixin_34413326的博客 976

LightOnOCR-2-1B新手入门:从安装到识别的完整流程

本文介绍了如何在星图GPU平台上自动化部署LightOnOCR-2-1B镜像,实现高精度多语言文档识别。该镜像开箱即用,支持中英混排表格、数学公式及11国语言的结构化提取,典型应用于发票解析、合同条款抽取和科研论文OCR等办公场景,大幅提升文档处理效率。

weixin_32673065的博客 451

LightOnOCR-2-1B镜像部署教程:Windows WSL2环境下LightOnOCR-2-1B运行指南

本文介绍了如何在星图GPU平台自动化部署LightOnOCR-2-1B镜像,实现高效的多语言OCR文字识别。该镜像能够快速从扫描文档、图片或表格中提取精准文本,支持中英文等11种语言,显著提升文档数字化和信息处理效率。

weixin_42576804的博客 29

LightOnOCR-2-1B部署案例:Kubernetes集群中LightOnOCR-2-1B服务编排

本文介绍了如何在星图GPU平台上自动化部署LightOnOCR-2-1B镜像,实现高效的多语言OCR服务。该平台简化了部署流程,用户可快速搭建服务,应用于自动化处理发票、合同等文档图片中的文字识别场景,显著提升信息录入效率。

weixin_33419305的博客 638

LightOnOCR-2-1B实战教程:OCR结果后处理——正则清洗+JSON Schema校验

本文介绍了如何在星图GPU平台上自动化部署LightOnOCR-2-1B镜像,实现高效的OCR文字识别与后处理。通过正则表达式清洗和JSON Schema校验,该方案能有效提升发票、名片等文档的结构化信息提取质量,适用于财务报销、商务信息数字化等典型场景。

weixin_42451850的博客 1026

LightOnOCR-2-1B保姆级教程:从安装到文字识别

本文介绍了如何在星图GPU平台自动化部署LightOnOCR-2-1B镜像,实现高效的多语言文字识别。该镜像支持11种语言,可快速从图片中提取文本内容,适用于文档数字化、图片文字提取等常见场景,提升信息处理效率。

weixin_30415591的博客 413

LightOnOCR-2-1B保姆级教程:从安装到文字识别的完整流程

本文介绍了如何在星图GPU平台上自动化部署LightOnOCR-2-1B镜像,高效实现高精度多语言文档文字识别。该镜像开箱即用,支持端到端识别含表格、公式及中英混排的扫描件与照片,典型应用于发票处理、合同文本提取和学术资料数字化等场景。

weixin_35755823的博客 584

LightOnOCR-2-1B保姆级教程:从安装到API调用全流程

本文介绍了如何在星图GPU平台上自动化部署LightOnOCR-2-1B镜像,实现高精度多语言文档OCR识别。该镜像开箱即用,支持中英日等11种语言及复杂版式(如表格、公式),典型应用于发票识别、合同文本提取与科研截图解析,大幅提升非结构化图像转结构化文本的效率。

weixin_33557333的博客 313
上一篇: AcousticSense AI效果实录:Jazz萨克斯即兴中微分音程在频谱上的亚赫兹级偏移
下一篇: Janus-Pro-7B部署教程:开源可部署+GPU算力适配,中小开发者友好
一不小心就来了
博客等级 码龄7年 2485粉丝 3462原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址