NameError:未定义名称“SSD_FEATURE_EXTRACTOR_CLASS_MAP”

问题描述

链接 Roboflow: https://blog.roboflow.com/train-a-tensorflow2-object-detection-model/

我正在使用 RobotFlow 的 https://colab.research.google.com/drive/1sLqFKVV94wm-lglFq_0kGo2ciM0kecWD#scrollTo=7Vz2vJeCCyZR&uniqifier=1 来检测图像,但这是一个错误

我使用的系统要求: Ubuntu 20.04 张量流 2 ssd_mobilenet_v2_fpnlite_640x640_coco17_tpu-8

我遇到bug的命令代码

import pathlib

filenames = list(pathlib.Path(work_dir + '/training/').glob('*.index'))

filenames.sort()
print(filenames)

#recover our saved model
pipeline_config = pipeline_file
#generally you want to put the last ckpt from training in here
model_dir = str(filenames[-1]).replace('.index','')
configs = config_util.get_configs_from_pipeline_file(pipeline_config)
model_config = configs['model']
detection_model = model_builder.build(
      model_config=model_config,is_training=False)

# Restore checkpoint
ckpt = tf.compat.v2.train.Checkpoint(
      model=detection_model)
ckpt.restore(os.path.join(str(filenames[-1]).replace('.index','')))


def get_model_detection_function(model):
  """Get a tf.function for detection."""

  @tf.function
  def detect_fn(image):
    """Detect objects in image."""

    image,shapes = model.preprocess(image)
    prediction_dict = model.predict(image,shapes)
    detections = model.postprocess(prediction_dict,shapes)

    return detections,prediction_dict,tf.reshape(shapes,[-1])

  return detect_fn

detect_fn = get_model_detection_function(detection_model)

如何修复那个错误

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...