
為了這個問題,我從 Stack Overflow 參考了這個平台。
我正在嘗試遵循如何使用 TensorFlow 和 Flask 建構物件偵測 API影片(在 YouTube 上)。
我克隆了 GitHub 儲存庫,然後下載了權重檔案。我還創建了一個虛擬環境python 3.6.0
(因為 Python 3.9.2 由於與文件中的 TensorFlow 版本 2.2 不相容而給出錯誤requirements.txt
)。
但是,當我嘗試使用以下命令加載權重時,
python load_weights.py
我收到這個錯誤,
檔案“load_weights.py”,第 4 行,位於 <module> 中 從 yolov3_tf2.models 導入 YoloV3、YoloV3Tiny 回溯(最近一次呼叫最後一次): 檔案“load_weights.py”,第 4 行,位於 <module> 中 從 yolov3_tf2.models 導入 YoloV3、YoloV3Tiny 檔案“E:\Example4\Object-Detection-API\yolov3_tf2\models.py”,第 23 行,位於 <module> 中 從.utils導入broadcast_iou 檔案“E:\Example4\Object-Detection-API\yolov3_tf2\utils.py”,第 5 行,位於 <module> 中 從seaborn導入color_palette 檔案“E:\Example4\Object-Detection-API\venv\lib\site-packages\seaborn\__init__.py”,第 2 行,位於 <module> 中 from .rcmod import * # noqa: F401,F403 檔案“E:\Example4\Object-Detection-API\venv\lib\site-packages\seaborn\rcmod.py”,第 5 行,位於 <module> 中 將 matplotlib 導入為 mpl 檔案“E:\Example4\Object-Detection-API\venv\lib\site-packages\matplotlib\__init__.py”,第 107 行,位於 <module> 中 從 。導入cbook、rcsetup 檔案“E:\Example4\Object-Detection-API\venv\lib\site-packages\matplotlib\rcsetup.py”,第 28 行,位於 <module> 中 從 matplotlib.fontconfig_pattern 導入 parse_fontconfig_pattern 檔案“E:\Example4\Object-Detection-API\venv\lib\site-packages\matplotlib\fontconfig_pattern.py”,第 15 行,位於 <module> 中 來自 pyparsing 匯入(文字、零或更多、可選、正規表示式、StringEnd、 檔案“E:\Example4\Object-Detection-API\venv\lib\site-packages\pyparsing\__init__.py”,第 130 行,位於 <module> 中 __版本__ = __版本資訊__.__版本__ AttributeError:“version_info”物件沒有屬性“__version__”
像往常一樣,重要的部分在最後;請注意,最後一行是標題中顯示的錯誤。我試圖在 Stack Overflow 和網路上的其他地方找到這個(使用 Google 搜尋),但找不到任何對我有用的東西。
一個答案通過 encubos 到python 庫 pyparsing 中的未知版本
Stack Overflow 上告訴我要更改 pyparsing
庫。
我使用命令檢查了 pyparsing 版本pip show pyparsing
,它顯示了以下結果,
WARNING: Ignoring invalid distribution -ensorflow (e:\hassan\example4\object-detection-api\venv\lib\site-packages)
Name: pyparsing
Version: 3.0.7
Summary: Python parsing module
Home-page: https://github.com/pyparsing/pyparsing/
Author: Paul McGuire
Author-email: [email protected]
License: MIT License
Location: e:\example4\object-detection-api\venv\lib\site-packages
Requires:
Required-by: matplotlib
之後我嘗試使用命令安裝 pyparsing 版本 3.0.7
pip install pyparsing==3.0.7
然而,我收到了這樣的消息,
Requirement already satisfied: pyparsing==3.0.7 in e:\example4\object-detection-api\venv\lib\site-packages (3.0.7)
WARNING: You are using pip version 21.3.1; however, version 22.0.3 is available.
You should consider upgrading via the 'E:\Example4\Object-Detection-API\venv\Scripts\python.exe -m pip install --upgrade pip' command.
我也嘗試卸載pyparsing並再次安裝指定版本,但問題仍然存在。
另一個解決方案建議我也安裝tensorflow-gpu
GitHub 儲存庫上給的,
pip install -r requirements-gpu.txt
我嘗試過這個;然而,這也行不通。我還嘗試卸載並再次安裝 TensorFlow,但相同的錯誤仍然存在。
我還嘗試使用這個來升級我的 pip,
python -m pip install --upgrade pip
這向我傳達了這樣的訊息:
Requirement already satisfied: pip in e:\hassan\semester 8\research\example4\object-detection-api\venv\lib\site-packages (21.3.1)
然而,最後它仍然說有新版本可用(但它不會安裝它,我不知道什麼原因)。
WARNING: You are using pip version 21.3.1; however, version 22.0.3 is available.
You should consider upgrading via the 'E:\Example4\Object-Detection-API\venv\Scripts\python.exe -m pip install --upgrade pip' command.
我該如何解決這個version
錯誤?