PaddleDection部署

部署运行你感兴趣的模型镜像

前言

为毕设做准备,今天学习并安装部署了PaddleDetection。

参考文章:

如何用PaddleDetection做一个完整的目标检测项目 - 知乎 (zhihu.com)icon-default.png?t=N7T8https://zhuanlan.zhihu.com/p/340717675

正文(安装过程中遇到的问题)

1.安装PaddlePaddle

文章中指出要利用利用anaconda创建一个名字叫做paddle-detection的Paddle环境,我好像没有做到,而是直接安装的。

安装链接在参考文章中给出,这里复制过来:

开始使用icon-default.png?t=N7T8https://www.paddlepaddle.org.cn/install/quick需要注意的是,我的计算机没有 NVIDIA® GPU而是集显,需要安装CPU版本的PaddleDetection

最后验证安装

安装链接中给出了如何卸载,这里不做操作,回到参考文章,进行下一步安装COCO-API。

2.安装COCO-API

1 pip install Cython
2 pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI

其中在执行第二个pip命令时,不断出现问题:

C:\Users\86134>pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
  Cloning https://github.com/philferriere/cocoapi.git to c:\users\86134\appdata\local\temp\pip-req-build-agx11kr8
  Running command git clone --filter=blob:none --quiet https://github.com/philferriere/cocoapi.git 'C:\Users\86134\AppData\Local\Temp\pip-req-build-agx11kr8'
  Resolved https://github.com/philferriere/cocoapi.git to commit 2929bd2ef6b451054755dfd7ceb09278f935f7ad
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: pycocotools
  Building wheel for pycocotools (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pycocotools
  Running setup.py clean for pycocotools
  error: subprocess-exited-with-error

  × python setup.py clean did not run successfully.
  │ exit code: 1
  ╰─> [12 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\86134\AppData\Local\Temp\pip-req-build-agx11kr8\PythonAPI\setup.py", line 25, in <module>
          cythonize(ext_modules)
        File "D:\Anaconda3\lib\site-packages\Cython\Build\Dependencies.py", line 1010, in cythonize
          module_list, module_metadata = create_extension_list(
        File "D:\Anaconda3\lib\site-packages\Cython\Build\Dependencies.py", line 845, in create_extension_list
          for file in nonempty(sorted(extended_iglob(filepattern)), "'%s' doesn't match any files" % filepattern):
        File "D:\Anaconda3\lib\site-packages\Cython\Build\Dependencies.py", line 117, in nonempty
          raise ValueError(error_msg)
      ValueError: 'pycocotools/_mask.pyx' doesn't match any files
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed cleaning build dir for pycocotools
Failed to build pycocotools
ERROR: Could not build wheels for pycocotools, which is required to install pyproject.toml-based projects

咨询chart-GPT,给出参考意见:

这里将他给出的Microsoft C++ Build Tools安装链接:

Microsoft C++ Build Tools - Visual Studioicon-default.png?t=N7T8https://visualstudio.microsoft.com/visual-cpp-build-tools/同时上图可看到

后续甚至出现了git环境变量错误的问题,使用everything搜索,发现可能是安装Microsoft C++ Build Tools时,利用Visual Studio Installer同时安装了Visual Studio Community 2022导致,现在看来似乎安装的这两个(一个生成工具,一个community)都没啥用

利用everything找到之前安装的git的安装目录C:\Program Files\Git\bin,重新添加到系统变量即可

Git配置环境变量和结果检测icon-default.png?t=N7T8http://t.csdnimg.cn/nIctD

3.下载PaddleDetection

这里在利用参考文章中第二种方式下载时,不断出现网络连接错误导致下载失败

故直接采用第一种方式下载zip

放在了文件夹:C:\Users\86134\PaddleDetection下

4.安装所需的Python其他依赖库

不同于参考文章中的版本,似乎内容更多了

另外,他开始时使用了activate paddle激活环境,但是我在开头第一步时没有建立

那么我应该是在base环境中,不论如何,继续安装,并且 pip install -r requirements.txt

不断报出一些多个不兼容的依赖项问题,使用命令:

pip install --upgrade mysql-connector-python paddlepaddle tensorflow typeguard typing-extensions

这将尝试升级"mysql-connector-python"、"paddlepaddle"、"tensorflow"、"typeguard"和"typing-extensions"到最新版本,以解决依赖项冲突。

5.确认测试通过

1 set PYTHONPATH=`pwd`:$PYTHONPATH
2 python ppdet/modeling/tests/test_architectures.py

 在执行第二命令时同样出现了运行错误,由于在第一次配置时,直接在解压的文件夹下配置的,可以看到我的路径中含有中文

故我转移了文件夹到C:\Users\86134\PaddleDetection\PaddleDetection-release-2.7,

利用everything找到在C盘的test_architectures.py按照参考文章中的方式添加代码

最后也确实运行出了文章中的结果,给我输出了一个“OK”,表示配置成功。

------------------------------------------------------------------------------------------------------------------------------

set PYTHONPATH=pwd:$PYTHONPATH 是一个设置环境变量 PYTHONPATH 的命令。

在 Python 中,PYTHONPATH 是一个环境变量,用于指定额外的模块搜索路径。当你导入自定义的模块或库时,Python 解释器会在 PYTHONPATH 中指定的路径下搜索相应的模块。

上述命令的含义是将当前目录(使用 pwd 命令获取)添加到 PYTHONPATH 环境变量中,并且保留原有的路径配置。

这个命令通常在运行 Python 脚本之前执行,以确保 Python 解释器可以找到所需的模块或库。通过将当前目录添加到 PYTHONPATH 中,Python 解释器将能够在该目录下搜索并导入你自己编写的模块。

请注意,这个命令在不同的操作系统和命令行环境下可能会有所不同。以上命令是针对类 Unix 系统(如 Linux 或 macOS)的命令行环境使用的。如果你使用的是 Windows 系统,可以尝试使用以下命令:

set PYTHONPATH=%cd%;%PYTHONPATH%

您可能感兴趣的与本文相关的镜像

PaddlePaddle-v3.3

PaddlePaddle-v3.3

PaddlePaddle

PaddlePaddle是由百度自主研发的深度学习平台,自 2016 年开源以来已广泛应用于工业界。作为一个全面的深度学习生态系统,它提供了核心框架、模型库、开发工具包等完整解决方案。目前已服务超过 2185 万开发者,67 万企业,产生了 110 万个模型

<think>好的,我现在需要回答用户关于如何运行PaddleDetection基本架构的教程。首先,我得回顾用户提供的引用内容,确保信息准确。根据引用[4],用户需要克隆仓库,安装依赖。然后,引用[3]提到了目录结构,比如configs、ppdet等文件夹,以及训练脚本的位置。接下来,我应该分步骤说明环境配置、数据集准备、配置选择、训练和验证,最后是推理。需要注意使用中文,并正确应用LaTeX格式,比如变量用$符号包裹。同时,生成相关问题时要围绕PaddleDetection的运行和结构展开。另外,确保引用标识正确添加到对应的步骤末尾,比如环境配置引用[4],目录结构引用[3]。可能还需要提醒用户安装依赖时的注意事项,比如CUDA版本对应PaddlePaddle。最后检查代码块是否正确,路径是否合适,确保用户能顺利执行命令。</think>### PaddleDetection 基本架构运行教程 PaddleDetection 是基于 PaddlePaddle目标检测开发套件,其架构设计模块化,支持快速配置和扩展。以下是运行基本架构的核心步骤: --- #### **1. 环境配置** - **克隆仓库**: ```bash git clone https://github.com/PaddlePaddle/PaddleDetection.git cd PaddleDetection ``` - **安装依赖**: ```bash pip install -r requirements.txt ``` > 注意:需提前安装与 CUDA 版本匹配的 PaddlePaddle 框架[^4]。 --- #### **2. 目录结构解析** 核心目录说明: - **`configs/`**:存放模型配置文件(如 Faster R-CNN、YOLOv3 等)[^3]。 - **`ppdet/`**:包含模型主干网络(Backbone)、检测头(Head)等模块化代码。 - **`tools/`**:提供训练、评估、推理的脚本(如 `train.py`、`eval.py`)。 - **`dataset/`**:数据集存储路径(需按规范组织标注文件)。 --- #### **3. 数据集准备** - 使用 Pascal VOC 或 COCO 格式,将数据按以下结构存放: ``` dataset/ ├── annotations # 标注文件(如 .json 或 .xml) └── images # 图像文件 ``` - 在配置文件中修改数据集路径(如 `configs/datasets/coco.yml`)。 --- #### **4. 选择模型配置** - 从 `configs/` 中选择预设模型(例如 YOLOv3): ```bash # 示例:使用 YOLOv3 配置文件 configs/yolov3/yolov3_darknet53_270e_coco.yml ``` 配置文件定义了网络结构、训练参数和数据集路径[^3]。 --- #### **5. 启动训练** - 使用 `tools/train.py` 脚本: ```bash python tools/train.py -c configs/yolov3/yolov3_darknet53_270e_coco.yml --eval ``` 参数说明: - `-c`:指定配置文件。 - `--eval`:训练中自动评估模型性能[^2]。 --- #### **6. 模型验证** - 使用 `tools/eval.py` 评估模型精度: ```bash python tools/eval.py -c configs/yolov3/yolov3_darknet53_270e_coco.yml -o weights=output/yolov3/best_model ``` --- #### **7. 模型推理** - 使用 `tools/infer.py` 进行单图预测: ```bash python tools/infer.py -c configs/yolov3/yolov3_darknet53_270e_coco.yml \ -o weights=output/yolov3/best_model.pdparams \ --infer_img=test_image.jpg ``` --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值