question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Weight & Biases support

See original GitHub issue

🚀 Feature

Adding support for wandb library

Motivation

W&B is one of the most advanced and feature-rich experiment tracking tools. It would be great to have support in detectron2. Great example: https://app.wandb.ai/syllogismos/keras-retinanet

Pitch

I implemented it in my own project as wanbb_writer.py module

import wandb
from detectron2.utils.events import (
    EventWriter,
    get_event_storage,
)


class WAndBWriter(EventWriter):
    """
    Write all scalars to a wandb tool.
    """

    def __init__(self, window_size: int = 20):
        self._window_size = window_size

    def write(self):
        storage = get_event_storage()
        for k, v in storage.latest_with_smoothing_hint(self._window_size).items():
            wandb.log({f"{k}": v}, step=storage.iter)

        if len(storage.vis_data) >= 1:
            for img_name, img, step_num in storage.vis_data:
                self._writer.add_image(img_name, img, step_num)
            storage.clear_images()

    def close(self):
        pass

and add this class as one of the writer here https://github.com/facebookresearch/detectron2/blob/master/tools/plain_train_net.py#L136

If someone finds this feature useful as I do, I would be happy to send a PR with W&B writer and tests for it.

cc: @cvphelps

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:12
  • Comments:8

github_iconTop GitHub Comments

8reactions
ppwwyyxxcommented, Jan 31, 2020

I suppose wandb will be enabled by just adding import wandb; wandb.init(sync_tensorboard=True) to your code. It doesn’t look like we need to do anything for it.

AP curves will be available if you set TEST.EVAL_PERIOD.

2reactions
marcosterlandcommented, Feb 10, 2021

Probably something has changes meanwhile, but the example of @truskovskiyk doesn’t work for me. Below is my adaptation, which works with v0.3. I’ve noticed W&B has issues with / in the metric names.

class WAndBWriter(EventWriter):
    """
    Write all scalars to a wandb tool.
    """

    def __init__(self, window_size: int = 20):
        self._window_size = window_size

    def write(self):
        storage = get_event_storage()
        stats = {}
        for k, v in storage.latest_with_smoothing_hint(self._window_size).items():
            stats[k.replace("/", "-")] = v[0]
        wandb.log(stats, step=storage.iter)

        if len(storage._vis_data) >= 1:
            for img_name, img, step_num in storage._vis_data:
                self._writer.add_image(img_name, img, step_num)
            storage.clear_images()

    def close(self):
        pass
Read more comments on GitHub >

github_iconTop Results From Across the Web

Weights & Biases – Developer tools for ML
Our mission is to build the best tools for machine learning. Use W&B for experiment tracking, dataset versioning, and collaborating on ML projects....
Read more >
Stop Weight Bias
With your help, we can build a better world, free of weight bias, where everyone is treated with dignity and respect. The time...
Read more >
Weight Bias - Obesity Action Coalition
Weight bias is negative attitudes, beliefs, judgments, stereotypes, and discriminatory acts aimed at individuals simply because of their weight. It can be overt ......
Read more >
Weight bias and support of public health policies - PubMed
A higher total explicit weight bias score increased the odds of supporting primarily less intrusive policies. However, dislike of individuals ...
Read more >
How to Address Weight Bias and Weight Discrimination
People who are overweight or obese may be unfairly stereotyped as lazy, overindulgent and undisciplined, said Michelle Smith, a social worker who specializes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found