You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows系统下如何通过Anaconda本地运行TensorFlow Object Detection API(禁用CMD)

Running TensorFlow Object Detection API via Anaconda on Windows

Hey there! I’ve been in your shoes before—getting the Object Detection API up and running with Anaconda on Windows can feel tricky when Command Prompt isn’t cooperating. Let’s break this down step by step, using only Anaconda’s tools:

Step 1: Open Anaconda Prompt & Activate Your TensorFlow Environment

First, launch the Anaconda Prompt (you’ll find it in your Start Menu under Anaconda3). This is key because it automatically loads all your Anaconda environment configurations, which Command Prompt might not handle properly.

Once it’s open, activate your TensorFlow environment with:

conda activate your-tensorflow-env-name

Replace your-tensorflow-env-name with the actual name of the environment where you installed TensorFlow (e.g., tf2_env).

Step 2: Navigate to Your Object Detection API Directory

Use the cd command to move to the folder where you’ve downloaded/cloned the TensorFlow Object Detection API. For example, if your API is in C:\Projects\tensorflow\models\research\object_detection, run:

cd C:\Projects\tensorflow\models\research\object_detection

Pro tip: You can drag-and-drop the folder directly into the Anaconda Prompt window to auto-fill the path—saves typing errors!

Step 3: Set Up the Required PYTHONPATH

The Object Detection API needs its parent directories added to your Python path to work correctly. In the same Anaconda Prompt session, run these two commands (adjust the paths to match your setup):

set PYTHONPATH=%PYTHONPATH%;C:\Projects\tensorflow\models\research
set PYTHONPATH=%PYTHONPATH%;C:\Projects\tensorflow\models\research\slim

Note: This sets the path temporarily for the current session. If you want it to persist every time you activate the environment, you can add these lines to a activate.bat file in your environment’s Scripts folder (e.g., C:\Users\YourName\anaconda3\envs\your-tensorflow-env-name\Scripts\activate.bat).

Step 4: Verify the Setup

To make sure everything’s working, run the API’s test script. For TensorFlow 2.x, use:

python object_detection/builders/model_builder_tf2_test.py

If you see lines ending with OK, you’re good to go! If you get module-not-found errors, double-check your PYTHONPATH paths and make sure you’re in the correct directory.

Quick Troubleshooting Tips

  • If activating the environment fails: Run conda env list to see all your Anaconda environments and confirm the name.
  • If cd throws an error: Make sure the directory path exists—check for typos in folder names or drive letters.
  • If test script fails: Ensure you’ve installed all required dependencies (like protobuf, pillow, lxml, etc.) in your TensorFlow environment. You can install them with conda install protobuf pillow lxml matplotlib opencv-python.

内容的提问来源于stack exchange,提问作者Abigale Moore

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 04:09:17