Giter Site home page Giter Site logo

yolov3_watermark's Introduction

keras-YOLOv3 水印检测模型。在开源的YOLOv3模型基础上,修改部分参数。

测试结果(test)

模型训练

1. 数据准备

  • train_image_folder <= 训练图片文件夹.

  • train_annot_folder <= 训练图片标注文件夹,VOC格式.

  • valid_image_folder <= 验证图片文件夹.

  • valid_annot_folder <= 验证图片标注文件夹,VOC格式.

其中,图片与标注的名字一一对应,如图片名000001.jpg,对应标注文件名为000001.xml。当验证集不提供时,默认将训练集进行划分,训练集:验证集 = 4:1

2. 编辑配置文件

The configuration file is a json file, which looks like this:

{
    "model" : {
        "min_input_size":       288,
        "max_input_size":       448,
        "anchors":              [23,22, 41,89, 46,35, 81,44, 97,31, 101,65, 126,53, 168,37, 242,52],
        "labels":               ["watermark"]   # 指定需要检测的目标类别
    },

    "train": {
        "train_image_folder":   "/home/keras-yolo3/watermark/images/",     # 训练图片路径
        "train_annot_folder":   "/home/keras-yolo3/watermark/annotations/",  # 训练图片对应标注
        "cache_name":           "watermark.pkl",                                       # 生成anchors时会生成
        "pretrained_weights":   "backend.h5",                                    # 预训练权重
        "train_times":          1,                                                     # 每个epoch训练集训练次数
        "batch_size":           8,
        "learning_rate":        1e-4,
        "nb_epochs":            30,
        "warmup_epochs":        3,
        "ignore_thresh":        0.6,                                                   # 低于此阈值,训练时认为box中无目标
        "gpus":                  "1",
        "grid_scales":          [1,1,1],
        "obj_scale":            7,
        "noobj_scale":          1,
        "xywh_scale":           1,
        "class_scale":          1,

        "tensorboard_dir":      "logs",
        "saved_weights_name":   "weights.h5",
        "debug":                true
    } ,

    "valid": {
        "valid_image_folder":   "",
        "valid_annot_folder":   "",
        "cache_name":           ""
    },
    "pred":{
        "obj_thresh":    0.5,          # 预测时包含物体阈值
        "nms_thresh":    0.45,         # 预测时非极大值抑制阈值
        "net_h":         416,
        "net_w":         416,
        "output_mode":    "no_wm" 
}
}

labels中包含的目标名将会被作为检测目标

Download pretrained weights for backend at:

链接: https://pan.baidu.com/s/1OXoMWlL3MS7i1tc1AYssiw 密码: nutd

3. 生成acchors

python gen_anchors.py -c config.json 将命令行输出的anchors替换config.json配置里的anchors

4. 开始训练,后台运行

nohup python train.py -c config.json &

当验证集loss在3个连续epoch中未下降时训练停止。

检测

python predict.py -c config.json -i /image_path/ 默认将检测出带水印结果放到output/下,无水印结果方法non_output/下。

百度网盘 提取码: ij4h

Evaluation

python evaluate.py -c config.json

yolov3_watermark's People

Contributors

bobo-y avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.