使用的paddledetection2.1
想通过修改callbacks.py中的Use VisualDL to log data or image部分实现恢复训练后的折线图的续写,修改LogWriter()方法内的file_name变量没有效果,训练产生的log文件仍是默认名称。
class VisualDLWriter(Callback):
def __init__(self, model):
super(VisualDLWriter, self).__init__(model)
assert six.PY3, "VisualDL requires Python >= 3.5"
try:
from visualdl import LogWriter
except Exception as e:
logger.error('visualdl not found, plaese install visualdl. '
'for example: `pip install visualdl`.')
raise e
self.vdl_writer = LogWriter(
lodir="./log/scalar",
file_name='vdlrecords111.log')
# self.vdl_writer = LogWriter(
# lodir=model.cfg.get('vdl_log_dir', 'vdl_log_dir/scalar'),
# file_name='vdlrecords.111')
self.vdl_loss_step = 0
self.vdl_mAP_step = 0
self.vdl_image_step = 0
self.vdl_image_frame = 0
def on_step_end(self, status):
mode = status['mode']
if dist.get_world_size() < 2 or dist.get_rank() == 0:
if mode == 'train':
training_staus = status['training_staus']
for loss_name, loss_value in training_staus.get().items():
# 折线图LOSS
self.vdl_writer.add_scalar(loss_name, loss_value,
self.vdl_loss_step)
self.vdl_loss_step += 1
elif mode == 'test':
ori_image = status['original_image']
result_image = status['result_image']
# 图片可视化
self.vdl_writer.add_image(
"original/frame_{}".format(self.vdl_image_frame), ori_image,
self.vdl_image_step)
self.vdl_writer.add_image(
"result/frame_{}".format(self.vdl_image_frame),
result_image, self.vdl_image_step)
self.vdl_image_step += 1
# each frame can display ten pictures at most.
if self.vdl_image_step % 10 == 0:
self.vdl_image_step = 0
self.vdl_image_frame += 1
自己想修改self.vdl_writer = LogWriter()方法,file_name='vdlrecords.111'是自己加的,想实现log文件的命名和续写,但是都没效果
2条答案
按热度按时间wydwbb8l1#
您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看 官网API文档 、 常见问题 、 历史Issue 、 AI社区 来寻求解答。祝您生活愉快~
Hi! We've received your issue and please be patient to get responded. We will arrange technicians to answer your questions as soon as possible. Please make sure that you have posted enough message to demo your request. You may also check out the API , FAQ , Github Issue and AI community to get the answer.Have a nice day!
laik7k3q2#
环境:
win10
paddledetection 2.1
paddlepaddle2.2
visualDL2.2.1