91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 195KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-13
  • 語言: Python
  • 標簽: Yolo??

資源簡介

使用TensorFlow 實現 Yolo_v1 的功能,變成語言是使用 Python3,變成環境是 Win10/Ubuntu 16.04 + TensorFlow1.4 + OpenCV 3.3,最后實現了對照片和視頻的實時檢測功能。具體原理參考了 Yolo_v1 的論文以及我的博客。

資源截圖

代碼片段和文件信息

import?tensorflow?as?tf
import?numpy?as?np
import?os
import?cv2
import?argparse
import?yolo.config?as?cfg
from?yolo.yolo_net?import?YOLONet
from?utils.timer?import?Timer


class?Detector(object):

????def?__init__(self?net?weight_file):
????????self.net?=?net
????????self.weights_file?=?weight_file

????????self.classes?=?cfg.CLASSES
????????self.num_class?=?len(self.classes)
????????self.image_size?=?cfg.IMAGE_SIZE
????????self.cell_size?=?cfg.CELL_SIZE
????????self.boxes_per_cell?=?cfg.BOXES_PER_CELL
????????self.threshold?=?cfg.THRESHOLD
????????self.iou_threshold?=?cfg.IOU_THRESHOLD
????????self.boundary1?=?self.cell_size?*?self.cell_size?*?self.num_class
????????self.boundary2?=?self.boundary1?+?self.cell_size?*?self.cell_size?*?self.boxes_per_cell

????????self.sess?=?tf.Session()
????????self.sess.run(tf.global_variables_initializer())

????????print(‘Restoring?weights?from:?‘?+?self.weights_file)
????????self.saver?=?tf.train.Saver()
????????self.saver.restore(self.sess?self.weights_file)

????def?draw_result(self?img?result):
????????for?i?in?range(len(result)):
????????????x?=?int(result[i][1])
????????????y?=?int(result[i][2])
????????????w?=?int(result[i][3]?/?2)
????????????h?=?int(result[i][4]?/?2)
????????????cv2.rectangle(img?(x?-?w?y?-?h)?(x?+?w?y?+?h)?(0?255?0)?2)
????????????cv2.rectangle(img?(x?-?w?y?-?h?-?20)
??????????????????????????(x?+?w?y?-?h)?(125?125?125)?-1)
????????????cv2.putText(img?result[i][0]?+?‘?:?%.2f‘?%?result[i][5]?(x?-?w?+?5?y?-?h?-?7)
????????????????????????cv2.FONT_HERSHEY_SIMPLEX?0.5?(0?0?0)?1? cv2.LINE_AA)

????def?detect(self?img):
????????img_h?img_w?_?=?img.shape
????????inputs?=?cv2.resize(img?(self.image_size?self.image_size))
????????inputs?=?cv2.cvtColor(inputs?cv2.COLOR_BGR2RGB).astype(np.float32)
????????inputs?=?(inputs?/?255.0)?*?2.0?-?1.0
????????inputs?=?np.reshape(inputs?(1?self.image_size?self.image_size?3))

????????result?=?self.detect_from_cvmat(inputs)[0]

????????for?i?in?range(len(result)):
????????????result[i][1]?*=?(1.0?*?img_w?/?self.image_size)
????????????result[i][2]?*=?(1.0?*?img_h?/?self.image_size)
????????????result[i][3]?*=?(1.0?*?img_w?/?self.image_size)
????????????result[i][4]?*=?(1.0?*?img_h?/?self.image_size)

????????return?result

????def?detect_from_cvmat(self?inputs):
????????net_output?=?self.sess.run(self.net.logits
???????????????????????????????????feed_dict={self.net.images:?inputs})
????????results?=?[]
????????for?i?in?range(net_output.shape[0]):
????????????results.append(self.interpret_output(net_output[i]))

????????return?results

????def?interpret_output(self?output):
????????probs?=?np.zeros((self.cell_size?self.cell_size
??????????????????????????self.boxes_per_cell?self.num_class))
????????class_probs?=?np.reshape(output[0:self.boundary1]?(self.cell_size?self.cell_size?self.num_class))
????????scales?=?np.reshape(output[sel

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-12-14?17:09??yolo_tensorflow-master\
?????文件??????????12??2017-09-29?21:01??yolo_tensorflow-master\.gitignore
?????目錄???????????0??2017-12-14?20:33??yolo_tensorflow-master\.idea\
?????目錄???????????0??2017-12-11?19:06??yolo_tensorflow-master\.idea\inspectionProfiles\
?????文件?????????675??2017-12-08?12:40??yolo_tensorflow-master\.idea\inspectionProfiles\Project_Default.xml
?????文件?????????339??2017-12-08?11:02??yolo_tensorflow-master\.idea\misc.xml
?????文件?????????296??2017-12-08?11:02??yolo_tensorflow-master\.idea\modules.xml
?????文件?????????186??2017-12-11?10:24??yolo_tensorflow-master\.idea\other.xml
?????文件???????49583??2017-12-14?20:33??yolo_tensorflow-master\.idea\workspace.xml
?????文件?????????398??2017-12-08?11:03??yolo_tensorflow-master\.idea\yolo_tensorflow-master.iml
?????目錄???????????0??2017-12-08?12:29??yolo_tensorflow-master\data\
?????目錄???????????0??2017-12-15?14:27??yolo_tensorflow-master\data\pascal_voc\
?????目錄???????????0??2017-12-15?14:28??yolo_tensorflow-master\data\weights\
?????文件?????????306??2017-09-29?21:01??yolo_tensorflow-master\download_data.sh
?????文件????????1067??2017-09-29?21:01??yolo_tensorflow-master\LICENSE
?????文件?????????709??2017-09-29?21:01??yolo_tensorflow-master\README.md
?????目錄???????????0??2017-09-29?21:01??yolo_tensorflow-master\test\
?????文件????????7870??2017-12-14?17:09??yolo_tensorflow-master\test.py
?????文件???????58495??2017-09-29?21:01??yolo_tensorflow-master\test\cat.jpg
?????文件??????113880??2017-09-29?21:01??yolo_tensorflow-master\test\person.jpg
?????文件????????6382??2017-12-08?13:25??yolo_tensorflow-master\train.py
?????目錄???????????0??2017-12-08?12:29??yolo_tensorflow-master\utils\
?????文件????????5814??2017-12-08?12:29??yolo_tensorflow-master\utils\pascal_voc.py
?????文件????????1130??2017-09-29?21:01??yolo_tensorflow-master\utils\timer.py
?????文件???????????0??2017-09-29?21:01??yolo_tensorflow-master\utils\__init__.py
?????目錄???????????0??2017-12-08?12:29??yolo_tensorflow-master\utils\__pycache__\
?????文件????????4824??2017-12-08?12:29??yolo_tensorflow-master\utils\__pycache__\pascal_voc.cpython-36.pyc
?????文件????????1266??2017-12-08?11:07??yolo_tensorflow-master\utils\__pycache__\timer.cpython-36.pyc
?????文件?????????171??2017-12-08?11:07??yolo_tensorflow-master\utils\__pycache__\__init__.cpython-36.pyc
?????目錄???????????0??2017-12-14?19:39??yolo_tensorflow-master\yolo\
?????文件????????1156??2017-12-08?13:11??yolo_tensorflow-master\yolo\config.py
............此處省略6個文件信息

評論

共有 條評論