导入错误:无法从“object_detection.builders”(未知位置)导入名称“model_builder”

问题描述 投票:0回答:2

我有一个错误

Traceback (most recent call last):
  File "c:/Users/User/Documents/Projects/Tensorflow/models/research/object_detection/builders/model_builder_tf2_test.py", line 24, in <module>
    from object_detection.builders import model_builder
ImportError: cannot import name 'model_builder' from 'object_detection.builders' (unknown location) 

我的文件夹中有init 我正在通过 cmd 运行 model_builder_tf2_test.py 并发生此错误

文件脚本

import unittest

import tensorflow.compat.v1 as tf

from google.protobuf import text_format
from object_detection.builders import model_builder
from object_detection.builders import model_builder_test
from object_detection.core import losses
from object_detection.models import center_net_resnet_feature_extractor
from object_detection.protos import center_net_pb2
from object_detection.protos import model_pb2
from object_detection.utils import tf_version
python tensorflow importerror
2个回答
1
投票

此位置需要位于

PATH
,所以请尝试以下操作:

import sys
sys.path.append('path/to/Tensorflow/models/research')

0
投票

我在这段代码中遇到了同样的问题:

import matplotlib
import matplotlib.pyplot as plt

import io
import scipy.misc
import numpy as np
from six import BytesIO
from PIL import Image, ImageDraw, ImageFont

from object_detection.utils import label_map_util
from object_detection.utils import config_util
from object_detection.utils import visualization_utils as viz_utils
from object_detection.builders import model_builder
%matplotlib inline

错误如下:

在此输入图片描述

© www.soinside.com 2019 - 2024. All rights reserved.