我正在尝试按照这里的教程使用mediapipe训练tensorflow lite对象检测模型。
我使用 Anaconda 按照此处所述设置环境。
我在 Windows 上使用 Pycharm 和以下软件包:
Python 3.10.13
Tensorflow 2.10.1
Mediapipe 0.9.0.1
Mediapipe-model-maker 0.1.0.2
我尝试运行代码,但我什至没有通过 import 语句。
import os
import json
import tensorflow as tf
import matplotlib.pyplot as plt
from matplotlib import patches, text, patheffects
from collections import defaultdict
import math
#the line below seems to be the issue
from mediapipe_model_maker import object_detector
assert tf.__version__.startswith('2')
我收到以下错误:
from mediapipe_model_maker import object_detector
ImportError: cannot import name 'object_detector' from 'mediapipe_model_maker' (C:\Users\username\Anaconda3\envs\object_detection_mediapipe\lib\site-packages\mediapipe_model_maker\__init__.py)
我在here找到了关于同一问题的帖子,并尝试了建议的操作,但错误仍然存在。
所以我按照上面错误消息的路径查看
__init__.py
文件。
它只有以下内容,比我预期的要少,这就是我分享它的原因(不一定是问题的根源):
#content of the __init__.py file \Anaconda3\envs\object_detection_mediapipe\lib\site-packages\mediapipe_model_maker\__init__.py
from mediapipe_model_maker.python.core.utils import quantization
from mediapipe_model_maker.python.vision import image_classifier
from mediapipe_model_maker.python.vision import gesture_recognizer
from mediapipe_model_maker.python.text import text_classifier
因此,如果有人知道如何解决该错误,我将非常感激!