Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error using Visdom as exp. tracking system for image-segmentation #215

Open
idkwid2022 opened this issue Aug 24, 2022 · 4 comments
Open

Comments

@idkwid2022
Copy link

idkwid2022 commented Aug 24, 2022

Describe the bug

AttributeError: 'VisdomLogger' object has no attribute 'writer'

Expected result

No error.

Reproduction

Please see line 137, src/templates/template-vision-segmentation/vis.py.
logger.writer.add_image is for tensorboard, no?

logger.writer.add_image

Steps to reproduce

Choose template for vision-segmentation
Choose Visdom for exp. tracking system.

@vfdev-5
Copy link
Member

vfdev-5 commented Aug 26, 2022

@idkwid2022 thanks for raising this issue. You are right this line :

logger.writer.add_image(
tag=tag,
img_tensor=grid_pred_gt,
global_step=global_step,
dataformats="HWC",
)

is working only with TensorBoard. Would you like to suggest a fix ?

Quick fix could be just to make sure that this code :

# Log validation predictions as images
# We define a custom event filter to log less frequently the images (to reduce storage size)
# - we plot images with masks of the middle validation batch
# - once every 3 validations and
# - at the end of the training
def custom_event_filter(_, val_iteration):
c1 = val_iteration == len(dataloader_eval) // 2
c2 = trainer.state.epoch % 3 == 0
c2 |= trainer.state.epoch == config.max_epochs
return c1 and c2
# Image denormalization function to plot predictions with images
mean = (0.485, 0.456, 0.406)
std = (0.229, 0.224, 0.225)
img_denormalize = partial(denormalize, mean=mean, std=std)
exp_logger.attach(
evaluator,
log_handler=predictions_gt_images_handler(
img_denormalize_fn=img_denormalize,
n_images=15,
another_engine=trainer,
prefix_tag="validation",
),
event_name=Events.ITERATION_COMPLETED(
event_filter=custom_event_filter
),
)

is executed only if exp_logger is TensorBoard.

Another fix could be to find some common method we could call with all supported exp tracking systems...

@idkwid2022
Copy link
Author

@vfdev-5 I don't think I have qualification for any suggestion, I'm a total newbie in this.

If I may, I think it should be like in image classification template since the logger options is the same for every template (template-vision-classification/utils.py, line 213, function setup_exp_logging) other option is to disable the loggers other than tensorboard, but that's a bummer isn't it?

Anyhow, I kinda did make it run on my notebook, but I forgot which lines I changed. The main change is on vis.py, line 137:

logger.vis.image(grid_pred_gt.transpose(2,0,1), win=tag, opts=dict(title=tag))

But that's just to make it run only on visdom. So maybe like this:

#::: if (it.logger === 'tensorboard') { :::#
        logger.writer.add_image(
            tag=tag,
            img_tensor=grid_pred_gt,
            global_step=global_step,
            dataformats="HWC",
        )
#::: } else if (it.logger === 'visdom') { :::#
        logger.vis.image(grid_pred_gt.transpose(2,0,1), win=tag, opts=dict(title=tag))
#::: } :::#

Like on image classification template? I don't know about the other logging system. I'm sorry I can't be much of a help.

@vfdev-5
Copy link
Member

vfdev-5 commented Aug 27, 2022

@idkwid2022 no problems about your qualifications.
I agree with your suggestion for tb and visdom only if/else branches. For others we can update later if there's a requirement.
I have to check classification template but I do not remember if we were logging any images there...

@idkwid2022
Copy link
Author

I meant about how the classification template deals with different loggers. I have not use the template, so I don't know if it logs images.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants