小编Iya*_*man的帖子

od_graph_def = tf.GraphDef() AttributeError: 模块“tensorflow”没有属性“GraphDef”

我有一台 mac,我使用的是 tensorflow 2.0、python 3.7。我正在关注为实时应用程序创建对象检测模型的教程。但我收到以下错误:

“下载/模型/研究/object_detection/object_detection_tutorial.py”,第 43 行,在 od_graph_def = tf od_graph_def = tf.GraphDef()

AttributeError: 模块“tensorflow”没有属性“GraphDef”

下面是教程链接:

我检查了环境,我已经在 anaconda 中有 tensorflow 环境

import tensorflow as tf
import zipfile

from collections import defaultdict
from io import StringIO
from matplotlib import pyplot as plt
from PIL import Image

sys.path.append("..")
from object_detection.utils import ops as utils_ops


from utils import label_map_util

from utils import visualization_utils as vis_util

MODEL_NAME = 'ssd_mobilenet_v1_coco_2017_11_17'
MODEL_FILE = MODEL_NAME + '.tar.gz'
DOWNLOAD_BASE = 'http://download.tensorflow.org/models/object_detection/'

PATH_TO_CKPT = MODEL_NAME + '/frozen_inference_graph.pb'

PATH_TO_LABELS …
Run Code Online (Sandbox Code Playgroud)

import tensorflow object-detection-api

28
推荐指数
2
解决办法
5万
查看次数

OpenCV(4.1.0)错误:(-215:断言失败)

我正在关注本教程系列:https://www.youtube.com/watch? v=A4K6D_gx2Iw&list=PLQVvvaa0QuDfhTox0AjmQ6tvTgMBZBEXN&index=6

当我尝试通过预测在程序外部使用模型时,出现以下错误:错误:OpenCV(4.1.0) /Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/resize。 cpp:3718:错误:(-215:断言失败)!函数“调整大小”中的 ssize.empty()

加载模型时的代码如下:

import cv2
import tensorflow as tf

CATEGORIES = ["Dog", "Cat"]
    import cv2
import tensorflow as tf

CATEGORIES = ["Dog", "Cat"]

def prepare(filepath):
    IMG_SIZE = 50
    img_array = cv2.imread(filepath, cv2.IMREAD_GRAYSCALE)
    #return img_array.reshape(-1, IMG_SIZE, IMG_SIZE, 1)

    new_array = cv2.resize(img_array, (IMG_SIZE, IMG_SIZE))
    return new_array.reshape(-1, IMG_SIZE, IMG_SIZE, 1)
#
model = tf.keras.models.load_model('iyad')
#
predication = model.predict([prepare("Dog.jpg")])

print(predication)
Run Code Online (Sandbox Code Playgroud)

python-3.x tensorflow

6
推荐指数
1
解决办法
4万
查看次数