标签 paddleocr 下的文章

安装 cuda

  • 查看 nvidia 最高支持多少版本的 cuda
nvidia-smi.exe

+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 560.94                 Driver Version: 560.94         CUDA Version: 12.6     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                  Driver-Model | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce RTX 4060 Ti   WDDM  |   00000000:01:00.0  On |                  N/A |
| 30%   30C    P8              4W /  160W |     654MiB /   8188MiB |      2%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

安装 Miniconda

这样随便一个 cmd 都能执行 conda 命令了

创建并使用 conda 环境

// 创建
conda create --name paddleocr python=3.9 -y
// 使用
conda activate paddleocr 


// 退出
conda deactivate 
// 删除 
conda remove --name paddleocr --all

环境准备

  • 需要确认 python 的版本是否满足要求,使用以下命令确认是 3.9/3.10/3.11/3.12/3.13

    python --version
  • 需要确认 pip 的版本是否满足要求,要求 pip 版本为 20.2.2 或更高版本

    python -m pip --version
  • 需要确认 Python 和 pip 是 64bit,并且处理器架构是 x86\_64(或称作 x64、Intel 64、AMD64)架构。下面的第一行输出的是"64bit",第二行输出的是"x86\_64"、"x64"或"AMD64"即可:

    python -c "import platform;print(platform.architecture()[0]);print(platform.machine())"
  • Windows 暂不支持 NCCL,分布式等相关功能
  • 默认提供的安装包需要计算机支持 MKL, Intel 芯片都支持 MKL

根据版本进行安装

我刚才安装的是 12.6 所以我要下载的也是 12.6,这是我在我的项目里面使用了 conda activate paddleocr 进入了环境之后才执行的

 python -m pip install paddlepaddle-gpu==3.1.0 -i https://www.paddlepaddle.org.cn/packages/stable/cu126/

安装 paddleocr

 pip install paddleocr

测试一下

paddleocr ocr -i https://paddle-model-ecology.bj.bcebos.com/paddlex/imgs/demo_image/general_ocr_002.png --use_doc_orientation_classify False --use_doc_unwarping False --use_textline_orientation False

结果:

{'res': {'input_path': 'C:/Users/Administrator/.paddlex/predict_input/general_ocr_002.png', 'page_index': None, 'model_settings': {'use_doc_preprocessor': True, 'use_textline_orientation': False}, 'doc_preprocessor_res': {'input_path': None, 'page_index': None, 'model_settings': {'use_doc_orientation_classify': False, 'use_doc_unwarping': False}, 'angle': -1}, 'dt_polys': array([[[152,  22],
        ...,
        [153,  77]],

       ...,

       [[ 99, 455],
        ...,
        [ 99, 480]]], dtype=int16), 'text_det_params': {'limit_side_len': 64, 'limit_type': 'min', 'thresh': 0.3, 'max_side_limit': 4000, 'box_thresh': 0.6, 'unclip_ratio': 1.5}, 'text_type': 'general', 'textline_orientation_angles': array([-1, ..., -1]), 'text_rec_score_thresh': 0.0, 'rec_texts': ['登机牌', 'BOARDING', 'PASS', '日期DATE', '舱位', 'CLASS', '序号', 'SERIALNO.', '座位号', 'SEAT NO.', '航班FLIGHT', 'MU 2379 03DEC', 'W', '035', '始发地', 'FROM', '登机口', 'GATE', '登机时间', 'BDT', '目的地TO', '福州', 'TAIYUAN', 'G11', 'FUZHOU', '身份识别IDNO.', '姓名NAME', 'ZHANGQIWEI', '票号TKTNO.', '张祺伟', '票价FARE', 'ETKT7813699238489/1', '登机口于起飞前1O分钟关闭GATESCLOSE1OMINUTESBEFORE DEPARTURETIME'], 'rec_scores': array([0.9971087 , ..., 0.97327828]), 'rec_polys': array([[[152,  22],
        ...,
        [153,  77]],

       ...,

       [[ 99, 455],
        ...,
        [ 99, 480]]], dtype=int16), 'rec_boxes': array([[152, ...,  77],
       ...,
       [ 99, ..., 480]], dtype=int16)}}