资源简介
使用keras版yolov3绘制loss曲线程序。将该文件替换掉原工程中的train.py,运行即可。
代码片段和文件信息
“““
Retrain the YOLO model for your own dataset.
“““
import time
import numpy as np
import keras.backend as K
from keras.layers import Input Lambda
from keras.models import Model
from keras.optimizers import Adam
from keras.callbacks import TensorBoard ModelCheckpoint ReduceLROnPlateau EarlyStopping
from yolo3.model import preprocess_true_boxes yolo_body tiny_yolo_body yolo_loss
from yolo3.utils import get_random_data
import keras
import matplotlib.pyplot as plt
# 构建绘图模块
class LossHistory(keras.callbacks.Callback):
def on_train_begin(self logs={}):
self.losses = {‘batch‘: [] ‘epoch‘: []}
self.accuracy = {‘batch‘: [] ‘epoch‘: []}
self.val_loss = {‘batch‘: [] ‘epoch‘: []}
self.val_acc = {‘batch‘: [] ‘epoch‘: []}
def on_batch_end(self batch logs={}):
self.losses[‘batch‘].append(logs.get(‘loss‘))
self.accuracy[‘batch‘].append(logs.get(‘acc‘))
self.val_loss[‘batch‘].append(logs.get(‘val_loss‘))
self.val_acc[‘batch‘].append(logs.get(‘val_acc‘))
if int(time.time()) % 5 == 0:
self.draw_loss(self.losses[‘batch‘] ‘loss‘ ‘train_batch‘)
self.draw_loss_50(self.losses[‘batch‘] ‘loss‘ ‘train_batch_50‘)
self.draw_loss_100(self.losses[‘batch‘] ‘loss‘ ‘train_batch_100‘)
self.draw_loss_200(self.losses[‘batch‘] ‘loss‘ ‘train_batch_200‘)
self.draw_loss_500(self.losses[‘batch‘] ‘loss‘ ‘train_batch_500‘)
self.draw_loss_1000(self.losses[‘batch‘] ‘loss‘ ‘train_batch_1000‘)
self.draw_p(self.accuracy[‘batch‘] ‘acc‘ ‘train_batch‘)
self.draw_p(self.val_loss[‘batch‘] ‘loss‘ ‘val_batch‘)
self.draw_p(self.val_acc[‘batch‘] ‘acc‘ ‘val_batch‘)
def on_epoch_end(self batch logs={}):
self.losses[‘epoch‘].append(logs.get(‘loss‘))
self.accuracy[‘epoch‘].append(logs.get(‘acc‘))
self.val_loss[‘epoch‘].append(logs.get(‘val_loss‘))
self.val_acc[‘epoch‘].append(logs.get(‘val_acc‘))
if int(time.time()) % 5 == 0:
self.draw_loss(self.losses[‘epoch‘] ‘loss‘ ‘train_epoch‘)
self.draw_loss_50(self.losses[‘batch‘] ‘loss‘ ‘train_batch_50‘)
self.draw_loss_100(self.losses[‘batch‘] ‘loss‘ ‘train_batch_100‘)
self.draw_loss_200(self.losses[‘batch‘] ‘loss‘ ‘train_batch_200‘)
self.draw_loss_500(self.losses[‘batch‘] ‘loss‘ ‘train_batch_500‘)
self.draw_loss_1000(self.losses[‘batch‘] ‘loss‘ ‘train_batch_500‘)
self.draw_p(self.accuracy[‘epoch‘] ‘acc‘ ‘train_epoch‘)
self.draw_p(self.val_loss[‘epoch‘] ‘loss‘ ‘val_epoch‘)
self.draw_p(self.val_acc[‘epoch‘] ‘acc‘ ‘val_epoch‘)
def draw_p(self lists label type):
plt.figure()
plt.plot(range(len(lists)) lists ‘r‘ label=label)
#plt.ylim((0 150))
plt.ylabel(label)
plt.xlabel(type)
plt.legend(loc=“upper right“)
plt.sa
- 上一篇:可视化函数绘图计算器
- 下一篇:信息隐藏——Python语言幻方置乱实现图片预处理
相关资源
- 绘制yolov3 P-R曲线的脚本draw_pr_py3.py
- 指静脉识别,keras,CNN
- BSTestRunner.pypython3
- LSTM股价预测(python).zip
- python3.dll——python3.5.2
- leveldb-windows-python3.6编译版
- python3+wxpython图书馆管理系统
- keras库对Kaggle竞赛猫狗图像分类卷积神
- turtle库官方说明全译本python37
- 纯python3.5代码实现逻辑回归的二分类
- 纯python3.5实现多变量线性回归附数据
- Python3爬虫入门到精通课程视频附软件
- 续Python3.x+Pyqt5实现主窗体里QToolBox导航
- Python3.x+Pyqt5实现主窗体里的工具栏,
- Python3.x+Pyqt5实现界面左侧树形导航栏
- Python3.x+Pyqt5实现绘图界面MainWindow类型
- Python3.x+Pyqt5实现界面和逻辑分离案例
- GRU神经网络 Python代码
- 某网Python3.6电商实战VueDjango.zip
- python3程序开发指南(第二版)与课后
- python37_d.lib文件
- Python3爬虫-v2
- 基于Python3.6和Opencv3的活动轮廓模型
- python3 网络爬虫 多线程 无限爬网址
- Yolov3所需数据预处理python文件
- python3实现sqlserver数据库和文件异地备
- python3.x实现智联招聘网站岗位信息爬
- HTMLTestRunner-基于python3-日志显示-截图
- 使用python3.6+sqlite3 创建数据库并实现
- python3 网络爬虫实战
评论
共有 条评论