tf2-keras implement yolov5

Overview

YOLOv5 in tesnorflow2.x-keras

模型测试

  • 训练 COCO2017(val 5k)

  • 检测效果

  • 精度/召回率

Requirements

pip3 install -r requirements.txt

Get start

  1. 训练
python3 train.py
  1. tensorboard
tensorboard --host 0.0.0.0 --logdir ./logs/ --port 8053 --samples_per_plugin=images=40
  1. 查看
http://127.0.0.1:8053
  1. 测试, 修改detect.py里面input_imagemodel_path
python3 detect.py

训练自己的数据

  1. labelme打标自己的数据
  2. 打开data/labelme2coco.py脚本, 修改如下地方
input_dir = '这里写labelme打标时保存json标记文件的目录'
output_dir = '这里写要转CoCo格式的目录,建议建一个空目录'
labels = "这里是你打标时所有的类别名, txt文本即可, 每行一个类, 类名无需加引号"
  1. 执行data/labelme2coco.py脚本会在output_dir生成对应的json文件和图片
  2. 修改train.py文件中coco_annotation_file以及num_class, 注意classes通过CoCoDataGenrator(*).coco.cats[label_id]['name']可获得,由于coco中类别不连续,所以通过coco.cats拿到的数组下标拿到的类别可能不准.
  3. 开始训练, python3 train.py
Comments
  • 关于类别损失计算的问题

    关于类别损失计算的问题

    您好,loss这段不是很理解, https://github.com/yyccR/yolov5_in_tf2_keras/blob/3e6645cbf94d2a1e11c33663e80113daa4590321/loss.py#L142-L152 请问targets最后两位应该是置信度1和最佳的anchor索引吗? https://github.com/yyccR/yolov5_in_tf2_keras/blob/3e6645cbf94d2a1e11c33663e80113daa4590321/loss.py#L288-L293 那这边split出来的true_obj, true_cls应该就是对应的置信度1和最佳的anchor索引吧。 那这个类别损失 https://github.com/yyccR/yolov5_in_tf2_keras/blob/3e6645cbf94d2a1e11c33663e80113daa4590321/loss.py#L356 计算的不是最佳anchor索引吗,是跟obj_mask 有关系吗

    opened by whalefa1I 5
  • sparse_categorical_crossentropy训练时有nan结果

    sparse_categorical_crossentropy训练时有nan结果

    有的数据会在这行出现nan https://github.com/yyccR/yolov5_in_tf2_keras/blob/033a1156c1481f4258bf24a4a8215af39682da94/loss.py#L357 查看了input的is_nan,都正常。而且把sparse_categorical_crossentropy换成binary_crossentropy就好了。 请问这两者在这里计算有差别吗,是否可以进行替换

    opened by whalefa1I 3
  • lebelme2coco处理逻辑有误

    lebelme2coco处理逻辑有误

    我在实际使用您的代码训练自己的数据集时发现,labelme2coco.py 好像缺少对shape_type == "rectangle"时的处理,导致我最后生成的json文件annotations项为空。 以下是labelme2coco.py文件100行到124行代码: ` if shape_type == "polygon": mask = labelme.utils.shape_to_mask( img.shape[:2], points, shape_type ) # cv2.imshow("",np.array(mask, dtype=np.uint8)*255) # cv2.waitKey(0)

                if group_id is None:
                    group_id = uuid.uuid1()
    
                instance = (label, group_id)
                # print(instance)
    
                if instance in masks:
                    masks[instance] = masks[instance] | mask
                else:
                    masks[instance] = mask
                # print(masks[instance].shape)
    
                if shape_type == "rectangle":
                    (x1, y1), (x2, y2) = points
                    x1, x2 = sorted([x1, x2])
                    y1, y2 = sorted([y1, y2])
                    points = [x1, y1, x2, y1, x2, y2, x1, y2]
                if shape_type == "circle": 
                ....
    

    ` 代码永远不会执行到shape_type == "rectangle"或shape_type == "circle"。

    opened by aijialin 2
  • layers.py

    layers.py

    根據ultralytics/yolov5:

    https://github.com/ultralytics/yolov5/blob/63ddb6f0d06f6309aa42bababd08c859197a27af/models/common.py#L70-L73

    這一段程式:

    https://github.com/yyccR/yolov5_in_tf2_keras/blob/46298d7c98073750176d64896ee9dc01b55c5aca/layers.py#L127-L132

    是不是應該改寫成:

        def call(self, inputs, *args, **kwargs):
            y = self.multiheadAttention(self.q(inputs), self.v(inputs), self.k(inputs)) + inputs
            x = self.fc1(x)
            x = self.fc2(x)
            x = x +  y
            return x
    
    opened by AugustusHsu 1
  • What is the mAP on COCO17 val ?

    What is the mAP on COCO17 val ?

    Hi @yyccR, thanks for your repo. I want to know if you can reach the same mAP as in original YOLOV5 (Train on COCO17 train and test on COCO17 val)? And do you have plan to release some pretrained checkpoint ?

    opened by Tyler-D 1
Releases(v1.1)
  • v1.1(Jun 24, 2022)

    v1.1 几个总结:

    • [1]. 调整tf.keras.layers.BatchNormalization的__call__方法中training=True
    • [2]. 新增TFLite/onnx格式导出与验证,详见/data/h5_to_tflite.py, /data/h5_to_onnx.py
    • [3]. 修改backbone网络里batch_size,在训练和测试时需指定,避免tflite导出时FlexOps问题
    • [4]. YoloHead里对类别不再做softmax,直接sigmoid,支持多类别输出
    • [5]. release里的yolov5s-best.h5为kaggle猫狗脸数据集的重新训练权重,训练:测试为8:2,val精度大概如下:

    | class | [email protected] | [email protected]:0.95 | precision | recall | | :-: | :-: | :-: | :-: | :-: | | cat | 0.962680 | 0.672483 | 0.721003 | 0.958333 | | dog | 0.934285 | 0.546893 | 0.770701 | 0.923664 | | total | 0.948482 | 0.609688 | 0.745852 | 0.940999 |

    • [6]. release里的yolov5s-best.tflite为上述yolov5s-best.h5的tflite量化模型,建议用Netron软件打开查看输入输出
    • [7]. release里的yolov5s-best.onnx为上述yolov5s-best.h5的onnx模型,建议用Netron软件打开查看输入输出
    • [8]. android 模型测试效果如下:

    就这样,继续加油!💪🏻💪🏻💪🏻

    Source code(tar.gz)
    Source code(zip)
    yolov5s-best.h5(27.51 MB)
    yolov5s-best.onnx(27.25 MB)
    yolov5s-best.tflite(6.95 MB)
  • v1.0(Jun 21, 2022)

    v1.0 几个总结:

    • [1]. 模型结构总的与 ultralytics/yolov5 v6.0 保持一致
    • [2]. 其中Conv层替换swishRelu
    • [3]. 整体数据增强与 ultralytics/yolov5 保持一致
    • [4]. readme中训练所需的数据集为kaggle公开猫狗脸检测数据集,已放到release列表中
    • [5]. 为什么不训练coco数据集?因为没资源,跑一个coco要很久的,服务器一直都有任务在跑所以没空去跑 - . -
    • [6]. release里的yolov5s-best.h5为上述kaggle猫狗脸数据集的训练权重,训练:测试为8:2,val精度大概如下:

    | class | [email protected] | [email protected]:0.95 | precision | recall | | :-: | :-: | :-: | :-: | :-: | | cat | 0.905156 | 0.584378 | 0.682848 | 0.886555 | | dog | 0.940633 | 0.513005 | 0.724036 | 0.934866 | | total | 0.922895 | 0.548692 | 0.703442 | 0.910710 |

    就这样,继续加油!💪🏻💪🏻💪🏻

    Source code(tar.gz)
    Source code(zip)
    JPEGImages.zip(260.17 MB)
    yolov5s-best.h5(27.51 MB)
Owner
yangcheng
yangcheng
Material for my PyConDE & PyData Berlin 2022 Talk "5 Steps to Speed Up Your Data-Analysis on a Single Core"

5 Steps to Speed Up Your Data-Analysis on a Single Core Material for my talk at the PyConDE & PyData Berlin 2022 Description Your data analysis pipeli

Jonathan Striebel 9 Dec 12, 2022
Si Adek Keras is software VR dangerous object detection.

Si Adek Python Keras Sistem Informasi Deteksi Benda Berbahaya Keras Python. Version 1.0 Developed by Ananda Rauf Maududi. Developed date: 24 November

Ananda Rauf 1 Dec 21, 2021
A PyTorch Reimplementation of TecoGAN: Temporally Coherent GAN for Video Super-Resolution

TecoGAN-PyTorch Introduction This is a PyTorch reimplementation of TecoGAN: Temporally Coherent GAN for Video Super-Resolution (VSR). Please refer to

165 Dec 17, 2022
DCT-Mask: Discrete Cosine Transform Mask Representation for Instance Segmentation

DCT-Mask: Discrete Cosine Transform Mask Representation for Instance Segmentation This project hosts the code for implementing the DCT-MASK algorithms

Alibaba Cloud 57 Nov 27, 2022
利用python脚本实现微信、支付宝账单的合并,并保存到excel文件实现自动记账,可查看可视化图表。

KeepAccounts_v2.0 KeepAccounts.exe和其配套表格能够实现微信、支付宝官方导出账单的读取合并,为每笔帐标记类型,并按月份和类型生成可视化图表。再也不用消费一笔记一笔,每月仅需10分钟,记好所有的帐。 作者: MickLife Bilibili: https://spac

159 Jan 01, 2023
[ICCV'2021] "SSH: A Self-Supervised Framework for Image Harmonization", Yifan Jiang, He Zhang, Jianming Zhang, Yilin Wang, Zhe Lin, Kalyan Sunkavalli, Simon Chen, Sohrab Amirghodsi, Sarah Kong, Zhangyang Wang

SSH: A Self-Supervised Framework for Image Harmonization (ICCV 2021) code for SSH Representative Examples Main Pipeline RealHM DataSet Google Drive Pr

VITA 86 Dec 02, 2022
Fully-automated scripts for collecting AI-related papers

AI-Paper-collector Fully-automated scripts for collecting AI-related papers List of Conferences to crawel ACL: 21-19 (including findings) EMNLP: 21-19

Gordon Lee 776 Jan 08, 2023
TART - A PyTorch implementation for Transition Matrix Representation of Trees with Transposed Convolutions

TART This project is a PyTorch implementation for Transition Matrix Representati

Lee Sael 2 Jan 19, 2022
ConE: Cone Embeddings for Multi-Hop Reasoning over Knowledge Graphs

ConE: Cone Embeddings for Multi-Hop Reasoning over Knowledge Graphs This is the code of paper ConE: Cone Embeddings for Multi-Hop Reasoning over Knowl

MIRA Lab 33 Dec 07, 2022
Code for Universal Semi-Supervised Semantic Segmentation models paper accepted in ICCV 2019

USSS_ICCV19 Code for Universal Semi Supervised Semantic Segmentation accepted to ICCV 2019. Full Paper available at https://arxiv.org/abs/1811.10323.

Tarun K 68 Nov 24, 2022
VisionKG: Vision Knowledge Graph

VisionKG: Vision Knowledge Graph Official Repository of VisionKG by Anh Le-Tuan, Trung-Kien Tran, Manh Nguyen-Duc, Jicheng Yuan, Manfred Hauswirth and

Continuous Query Evaluation over Linked Stream (CQELS) 9 Jun 23, 2022
Fuzzing JavaScript Engines with Aspect-preserving Mutation

DIE Repository for "Fuzzing JavaScript Engines with Aspect-preserving Mutation" (in S&P'20). You can check the paper for technical details. Environmen

gts3.org (<a href=[email protected])"> 190 Dec 11, 2022
[CVPR2021] DoDNet: Learning to segment multi-organ and tumors from multiple partially labeled datasets

DoDNet This repo holds the pytorch implementation of DoDNet: DoDNet: Learning to segment multi-organ and tumors from multiple partially labeled datase

116 Dec 12, 2022
COD-Rank-Localize-and-Segment (CVPR2021)

COD-Rank-Localize-and-Segment (CVPR2021) Simultaneously Localize, Segment and Rank the Camouflaged Objects Full camouflage fixation training dataset i

JingZhang 52 Dec 20, 2022
ENet: A Deep Neural Network Architecture for Real-Time Semantic Segmentation

ENet in Caffe Execution times and hardware requirements Network 1024x512 1280x720 Parameters Model size (fp32) ENet 20.4 ms 32.9 ms 0.36 M 1.5 MB SegN

Timo Sämann 561 Jan 04, 2023
source code of “Visual Saliency Transformer” (ICCV2021)

Visual Saliency Transformer (VST) source code for our ICCV 2021 paper “Visual Saliency Transformer” by Nian Liu, Ni Zhang, Kaiyuan Wan, Junwei Han, an

89 Dec 21, 2022
AI Face Mesh: This is a simple face mesh detection program based on Artificial intelligence.

AI Face Mesh: This is a simple face mesh detection program based on Artificial Intelligence which made with Python. It's able to detect 468 different

Md. Rakibul Islam 1 Jan 13, 2022
Repository for scripts and notebooks from the book: Programming PyTorch for Deep Learning

Repository for scripts and notebooks from the book: Programming PyTorch for Deep Learning

Ian Pointer 368 Dec 17, 2022
Turning pixels into virtual points for multimodal 3D object detection.

Multimodal Virtual Point 3D Detection Turning pixels into virtual points for multimodal 3D object detection. Multimodal Virtual Point 3D Detection, Ti

Tianwei Yin 204 Jan 08, 2023
Easily pull telemetry data and create beautiful visualizations for analysis.

This repository is a work in progress. Anything and everything is subject to change. Porpo Table of Contents Porpo Table of Contents General Informati

Ryan Dawes 33 Nov 30, 2022