1 Star 0 Fork 1

钟龙申/yolo_v3_逐行注释

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
image_demo.py 1.43 KB
一键复制 编辑 原始数据 按行查看 历史
import cv2
import numpy as np
import core.utils as utils
import tensorflow as tf
from PIL import Image
return_elements = ["input/input_data:0", "pred_sbbox/concat_2:0", "pred_mbbox/concat_2:0", "pred_lbbox/concat_2:0"]
pb_file = "./yolov3_cast.pb"
image_path = "./docs/images/212.png"
num_classes = 3
input_size = 1024
graph = tf.Graph()
original_image = cv2.imread(image_path)
# original_image = cv2.cvtColor(original_image, cv2.COLOR_BGR2RGB)
original_image_size = original_image.shape[:2]
image_data = utils.image_preporcess(np.copy(original_image), [input_size, input_size])
image_data = image_data[np.newaxis, ...]
return_tensors = utils.read_pb_return_tensors(graph, pb_file, return_elements)
with tf.Session(graph=graph) as sess:
pred_sbbox, pred_mbbox, pred_lbbox = sess.run(
[return_tensors[1], return_tensors[2], return_tensors[3]],
feed_dict={ return_tensors[0]: image_data})
pred_bbox = np.concatenate([np.reshape(pred_sbbox, (-1, 5 + num_classes)),
np.reshape(pred_mbbox, (-1, 5 + num_classes)),
np.reshape(pred_lbbox, (-1, 5 + num_classes))], axis=0)
bboxes = utils.postprocess_boxes(pred_bbox, original_image_size, input_size, 0.3)
bboxes = utils.nms(bboxes, 0.45, method='nms')
show_image=cv2.cvtColor(original_image,cv2.COLOR_BGR2RGB)
image = utils.draw_bbox(show_image, bboxes)
image = Image.fromarray(image)
image.show()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/zhonglongshen/tensorflow-yolov3-cast.git
[email protected]:zhonglongshen/tensorflow-yolov3-cast.git
zhonglongshen
tensorflow-yolov3-cast
yolo_v3_逐行注释
master

搜索帮助