基于百度飞桨paddle的paddlepaddle2.4.2等系列项目的运行

news/2024/11/8 16:10:26 标签: 百度, paddlepaddle, paddle

PPASR

必看!!!

PaddleSpeech == develop --> PaddlePaddle == 2.5.0/2.5.1
PaddleSpeech <= 1.4.1 --> PaddlePaddle <= 2.4.2

1.创建虚拟环境 

conda create --name test python=3.10

2.激活环境,安装ppasr的paddlepaddle>paddlepaddle2.4.2

conda activate test

conda install paddlepaddle>paddlepaddle==2.4.2 --channel https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/Paddle/

安装jupyter notebook

pip install jupyter notebook
jupyter notebook --version 

注意jupyter7.x以后不支持插件

可以选择安装6.x

此处提供链接参考

【jupyter notebook】中插件 nbextensions 安装失败分析与解决方法_modulenotfounderror: no module named 'notebook.nbe-CSDN博客

3.运行Jupyter Notebook

启动  默认端口启动 在终端中输入以下命令:

jupyter notebook 执行命令之后,在终端中将会显示一系列notebook的服务器信息,同时浏览器将会自动启动Jupyter Notebook。

浏览器地址栏中默认地将会显示:http://localhost:8888。其中,“localhost”指的是本机,“8888”则是端口号。

4.退出Jupyter Notebook

想要彻底退出Jupyter Notebook,需要关闭它的服务器。只需要在它启动的终端上按: Mac用户:control c Windows用户:ctrl c

5.项目运行

front

nmp i
npm run dev

back

激活python的test虚拟环境

运行routes.py

/opt/anaconda3/envs/test/bin/python /Users/lin/Desktop/ppasr/back/api/routes.py 
/opt/anaconda3/envs/test/lib/python3.10/site-packages/setuptools/sandbox.py:14: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  import pkg_resources
/opt/anaconda3/envs/test/lib/python3.10/site-packages/pkg_resources/__init__.py:2832: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
  declare_namespace(pkg)
[nltk_data] Error loading averaged_perceptron_tagger: <urlopen error
[nltk_data]     [Errno 61] Connection refused>
[nltk_data] Error loading cmudict: <urlopen error [Errno 61]
[nltk_data]     Connection refused>
 * Serving Flask app 'routes'
 * Debug mode: on
[2024-11-07 19:58:01,777] [    INFO] _internal.py:97 - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on http://127.0.0.1:5000
[2024-11-07 19:58:01,777] [    INFO] _internal.py:97 - Press CTRL+C to quit
[2024-11-07 19:58:01,779] [    INFO] _internal.py:97 -  * Restarting with stat
/opt/anaconda3/envs/test/lib/python3.10/site-packages/setuptools/sandbox.py:14: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  import pkg_resources
/opt/anaconda3/envs/test/lib/python3.10/site-packages/pkg_resources/__init__.py:2832: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
  declare_namespace(pkg)
[nltk_data] Error loading averaged_perceptron_tagger: <urlopen error
[nltk_data]     [Errno 61] Connection refused>
[nltk_data] Error loading cmudict: <urlopen error [Errno 61]
[nltk_data]     Connection refused>
[2024-11-07 19:58:14,412] [ WARNING] _internal.py:97 -  * Debugger is active!
[2024-11-07 19:58:14,431] [    INFO] _internal.py:97 -  * Debugger PIN: 104-557-696
[2024-11-07 19:58:45,657] [ WARNING] logging.py:46 - 'ernie-bot' will be deprecated in the future. Please use 'ernie-3.5' instead.
2024-11-07 19:58:47
Inserted user with ID: 42
[2024-11-07 19:58:47,968] [    INFO] _internal.py:97 - 127.0.0.1 - - [07/Nov/2024 19:58:47] "POST /getpolish HTTP/1.1" 200 -
[2024-11-07 19:59:05,542] [ WARNING] logging.py:46 - 'ernie-bot' will be deprecated in the future. Please use 'ernie-3.5' instead.
2024-11-07 19:59:07
Inserted user with ID: 43
[2024-11-07 19:59:07,859] [    INFO] _internal.py:97 - 127.0.0.1 - - [07/Nov/2024 19:59:07] "POST /getpolish HTTP/1.1" 200 -
[2024-11-07 20:04:23,860] [    INFO] _internal.py:97 - 127.0.0.1 - - [07/Nov/2024 20:04:23] "POST /readImage HTTP/1.1" 200 -
[2024/11/07 20:04:21] ppocr DEBUG: Namespace(help='==SUPPRESS==', use_gpu=False, use_xpu=False, use_npu=False, ir_optim=True, use_tensorrt=False, min_subgraph_size=15, precision='fp32', gpu_mem=500, gpu_id=0, image_dir=None, page_num=0, det_algorithm='DB', det_model_dir='/Users/lin/.paddleocr/whl/det/ch/ch_PP-OCRv4_det_infer', det_limit_side_len=960, det_limit_type='max', det_box_type='quad', det_db_thresh=0.3, det_db_box_thresh=0.6, det_db_unclip_ratio=1.5, max_batch_size=10, use_dilation=False, det_db_score_mode='fast', det_east_score_thresh=0.8, det_east_cover_thresh=0.1, det_east_nms_thresh=0.2, det_sast_score_thresh=0.5, det_sast_nms_thresh=0.2, det_pse_thresh=0, det_pse_box_thresh=0.85, det_pse_min_area=16, det_pse_scale=1, scales=[8, 16, 32], alpha=1.0, beta=1.0, fourier_degree=5, rec_algorithm='SVTR_LCNet', rec_model_dir='/Users/lin/.paddleocr/whl/rec/ch/ch_PP-OCRv4_rec_infer', rec_image_inverse=True, rec_image_shape='3, 48, 320', rec_batch_num=6, max_text_length=25, rec_char_dict_path='/Users/lin/.local/lib/python3.10/site-packages/paddleocr/ppocr/utils/ppocr_keys_v1.txt', use_space_char=True, vis_font_path='./doc/fonts/simfang.ttf', drop_score=0.5, e2e_algorithm='PGNet', e2e_model_dir=None, e2e_limit_side_len=768, e2e_limit_type='max', e2e_pgnet_score_thresh=0.5, e2e_char_dict_path='./ppocr/utils/ic15_dict.txt', e2e_pgnet_valid_set='totaltext', e2e_pgnet_mode='fast', use_angle_cls=True, cls_model_dir='/Users/lin/.paddleocr/whl/cls/ch_ppocr_mobile_v2.0_cls_infer', cls_image_shape='3, 48, 192', label_list=['0', '180'], cls_batch_num=6, cls_thresh=0.9, enable_mkldnn=False, cpu_threads=10, use_pdserving=False, warmup=False, sr_model_dir=None, sr_image_shape='3, 32, 128', sr_batch_num=1, draw_img_save_dir='./inference_results', save_crop_res=False, crop_res_save_dir='./output', use_mp=False, total_process_num=1, process_id=0, benchmark=False, save_log_path='./log_output/', show_log=True, use_onnx=False, output='./output', table_max_len=488, table_algorithm='TableAttn', table_model_dir=None, merge_no_span_structure=True, table_char_dict_path=None, layout_model_dir=None, layout_dict_path=None, layout_score_threshold=0.5, layout_nms_threshold=0.5, kie_algorithm='LayoutXLM', ser_model_dir=None, re_model_dir=None, use_visual_backbone=True, ser_dict_path='../train_data/XFUND/class_list_xfun.txt', ocr_order_method=None, mode='structure', image_orientation=False, layout=True, table=True, ocr=True, recovery=False, use_pdf2docx_api=False, invert=False, binarize=False, alphacolor=(255, 255, 255), lang='ch', det=True, rec=True, type='ocr', ocr_version='PP-OCRv4', structure_version='PP-StructureV2')
[2024/11/07 20:04:23] ppocr DEBUG: dt_boxes num : 3, elapsed : 0.7359390258789062
[2024/11/07 20:04:23] ppocr DEBUG: cls num  : 3, elapsed : 0.029176712036132812
[2024/11/07 20:04:23] ppocr DEBUG: rec_res num  : 3, elapsed : 0.3469219207763672
[0.998357892036438, 0.9924399852752686, 0.9858253002166748]
[[[[421.0, 391.0], [549.0, 391.0], [549.0, 419.0], [421.0, 419.0]], ('Mashiro', 0.998357892036438)], [[[443.0, 423.0], [525.0, 420.0], [526.0, 449.0], [444.0, 451.0]], ('最棒了', 0.9924399852752686)], [[[470.0, 455.0], [500.0, 455.0], [500.0, 480.0], [470.0, 480.0]], (':P', 0.9858253002166748)]]
OCR结果图保存在../static/images/default/ocrOut/comment.png
​
文本信息:
[[[[421.0, 391.0], [549.0, 391.0], [549.0, 419.0], [421.0, 419.0]], ('Mashiro', 0.998357892036438)], [[[443.0, 423.0], [525.0, 420.0], [526.0, 449.0], [444.0, 451.0]], ('最棒了', 0.9924399852752686)], [[[470.0, 455.0], [500.0, 455.0], [500.0, 480.0], [470.0, 480.0]], (':P', 0.9858253002166748)]]
Mashiro 最棒了 :P
2024-11-07 20:04:23
Inserted user with ID: 44
[2024-11-07 20:05:13,273] [    INFO] _internal.py:97 - 127.0.0.1 - - [07/Nov/2024 20:05:13] "GET /getalldata HTTP/1.1" 200 -
{[{'id': 44, 'content': 'Mashiro 最棒了 :P', 'date': '2024-11-07 20:04:23'}]}
[2024-11-07 20:24:49,648] [    INFO] - Already cached /Users/lin/.paddlenlp/models/bert-base-chinese/bert-base-chinese-vocab.txt
[2024-11-07 20:24:49,665] [    INFO] - tokenizer config file saved in /Users/lin/.paddlenlp/models/bert-base-chinese/tokenizer_config.json
[2024-11-07 20:24:49,666] [    INFO] - Special tokens file saved in /Users/lin/.paddlenlp/models/bert-base-chinese/special_tokens_map.json
Building prefix dict from the default dictionary ...
[2024-11-07 20:24:59,661] [   DEBUG] __init__.py:113 - Building prefix dict from the default dictionary ...
Dumping model to file cache /var/folders/jr/2mlw59_j35bbnxrjc7xpz3lr0000gn/T/jieba.cache
[2024-11-07 20:25:00,301] [   DEBUG] __init__.py:146 - Dumping model to file cache /var/folders/jr/2mlw59_j35bbnxrjc7xpz3lr0000gn/T/jieba.cache
Loading model cost 0.686 seconds.
[2024-11-07 20:25:00,347] [   DEBUG] __init__.py:164 - Loading model cost 0.686 seconds.
Prefix dict has been built successfully.
[2024-11-07 20:25:00,347] [   DEBUG] __init__.py:166 - Prefix dict has been built successfully.
2221
2024-11-07 20:25:01
Inserted user with ID: 45
[2024-11-07 20:25:01,476] [    INFO] _internal.py:97 - 127.0.0.1 - - [07/Nov/2024 20:25:01] "POST /tts HTTP/1.1" 200 -

浏览器:

http://localhost:5173/


http://www.niftyadmin.cn/n/5744123.html

相关文章

LeetCode :150. 逆波兰表达式求值(含求后缀表达式和中缀转后缀表达式)

目录 题目描述: 代码: 拓展: 中缀表达式转后缀表达式代码: 题目描述: 给你一个字符串数组 tokens &#xff0c;表示一个根据 逆波兰表示法 表示的算术表达式。 请你计算该表达式。返回一个表示表达式值的整数。 注意&#xff1a; 有效的算符为 、-、* 和 / 。每个操作数…

【手撕排序2】快速排序

&#x1f343; 如果觉得本系列文章内容还不错&#xff0c;欢迎订阅&#x1f6a9; &#x1f38a;个人主页:小编的个人主页 &#x1f380; &#x1f389;欢迎大家点赞&#x1f44d;收藏⭐文章 ✌️ &#x1f91e; &#x1f91f; &#x1f918; &#x1f919; &#x1f448; &…

Linux(ubuntu) 部署xinference

注:在此前提我已经准备好了环境 - 文章中大部分命令我都会有说明 进阶命令就需要友友们在研究了 miniconda 安装 gpu 显卡驱动安装 xinference使用命令什么的我就不放了官方文档中很简单易懂 xinference 官方文档地址 注&#xff1a;此文章不叙述docker版安装(docker安装很简单…

Gradle命令编译Android Studio工程项目并签名

文章目录 gradlew命令gradlew编译debug apkgradlew编译release apkapksigner签名apkgradlew注意事项 gradlew命令 gradlew 是一个脚本文件&#xff0c;它允许你在没有全局安装 Gradle 的情况下运行 Gradle 构建。这个脚本在多平台上可用&#xff0c;对于 Windows 系统来说是 g…

笔记整理—linux驱动开发部分(6)platform平台总线

与前文提到的usb、IIC、PCI总线不同&#xff0c;platform总线是一种虚拟抽象的总线&#xff0c;不存在物理层面上的一个名为platform的总线。 cup与外部设备通信有两种方法&#xff0c;地址总线或接口&#xff08;32位范围是0~2^32-1&#xff09;&#xff1b;专用接口连接&…

深度学习经典模型之Network in Network

1 Network in Network 1.1 模型介绍 ​ Network In Network (NIN)是由 M i n L i n Min Lin MinLin等人提出&#xff0c;在CIFAR-10和CIFAR-100分类任务中达到当时的最好水平&#xff0c;因其网络结构是由三个多层感知机堆叠而被成为NIN [ 5 ] ^{[5]} [5]。NIN以一种全新的角…

【华为机试题】 [Python] 贪心的商人

代码 # 其实就是贪心算法求每个商品的最大利润&#xff0c;最后再和商品数相乘就好了 from unittest.mock import patchclass Solution:def func(self, number, days, item_max_num, item_price):max_money 0for i in range(number):max_money item_max_num[i] * self.compu…

大数据数据存储层MemSQL, HBase与HDFS

以下是对 MemSQL、HBase 和 HDFS 的详细介绍,这些工具在分布式数据存储和处理领域有着重要作用。 1. MemSQL MemSQL(现称为 SingleStore)是一种分布式内存数据库,兼具事务处理(OLTP)和分析处理(OLAP)的能力,专为高性能实时数据处理设计。 1.1 核心特点 内存优先存储…