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

Update Weights & Biases Integration + Add Prediction Visualization for Object Detection #1010

Merged
merged 45 commits into from
Jun 5, 2023

Conversation

soumik12345
Copy link
Contributor

@soumik12345 soumik12345 commented May 15, 2023

Changes made in this PR

Log inference results to Weights & Biases

Fixes #953

Optionally log inference results for object detection in Weights & Biases dashboard using bounding-box image overlays.

This PR adds an optional parameter visualize_on_wandb to ImagesDetectionPrediction.show() which when set to True would log the predictions using the bounding-box image overlays in the Weights & Biases dashboard of the user.

Here's a sample code:

from super_gradients.training import models
from super_gradients.common.object_names import Models

import wandb

# Initialize Weights & Biases run
wandb.init(project="yolo-nas", entity="geekyrakshit")

net = models.get(Models.YOLO_NAS_S, pretrained_weights="coco")
prediction = net.predict([
    "https://cdn.autonomous.ai/static/upload/images/common/upload/20210919/5-Desk-Setup-with-a-Laptop--Monitor-Ideas-for-2021_10f89201411b.jpg",
    "https://p.imgci.com/db/PICTURES/CMS/352000/352019.jpg",
    "https://p.imgci.com/db/PICTURES/CMS/352200/352298.jpg",
    "https://www.encirclephotos.com/wp-content/uploads/Laos-Ban-Pak-Ou-Man-Riding-Asian-Elephant-1440x961.jpg"
])
prediction.show(visualize_on_wandb=True)

This would log the images to be visualized in a media panel in a Weights & Biases dashboard.

👇 Here's how the results would look

Here's a video of how to interact with the bounding-box overlay interface on Weights & Biases 👇

Screen.Recording.2023-05-09.at.6.24.17.PM.mov

Update WandBSGLogger

Fixes #980
Fixes #1008

  • WandBSGLogger will now call wandb.init() only if it has not been called earlier.
  • Save model checkpoints versioned with Weights & Biases checkpoints.
  • Add an additional parameter sync_tensorboard to WandBSGLogger that automatically syncs TensorBoard with the wandb run.

👇 Here's a sample training code that works with the changes made in this PR

👇 Here's a sample Weights & Biases Run demonstrating the features

👇 Tensorboard instance synced with Weights & Biases Run

👇 Lineage of Model Checkpoints

@dagshub
Copy link

dagshub bot commented May 15, 2023

@BenSpex
Copy link

BenSpex commented May 16, 2023

+1 would love to see WandB integration

@soumik12345
Copy link
Contributor Author

Hi @BloodAxe
Can you please take a look at this PR?

Copy link
Collaborator

@ofrimasad ofrimasad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the code contribution.
The wandb boxes feature looks awesome.

I am not sure I understand the need for Artifact. How is that different from uploading a file to the experiment using wandb.save? Will it be linked to the experiment?

please find my comments regarding the code placement, naming, documentation and some questions inline.

requirements.txt Outdated Show resolved Hide resolved
src/super_gradients/wandb/__init__.py Outdated Show resolved Hide resolved
src/super_gradients/wandb/artifacts.py Outdated Show resolved Hide resolved
src/super_gradients/wandb/artifacts.py Outdated Show resolved Hide resolved
src/super_gradients/wandb/log_predictions.py Outdated Show resolved Hide resolved
src/super_gradients/common/sg_loggers/wandb_sg_logger.py Outdated Show resolved Hide resolved
src/super_gradients/common/sg_loggers/wandb_sg_logger.py Outdated Show resolved Hide resolved
src/super_gradients/common/sg_loggers/wandb_sg_logger.py Outdated Show resolved Hide resolved
src/super_gradients/wandb/log_predictions.py Outdated Show resolved Hide resolved
src/super_gradients/wandb/log_predictions.py Outdated Show resolved Hide resolved
@soumik12345
Copy link
Contributor Author

I am not sure I understand the need for Artifact. How is that different from uploading a file to the experiment using wandb.save? Will it be linked to the experiment?

Hi @ofrimasad
W&B Artifacts can be thought of as a versioned directory that is either an input of a run or an output of a run. Artifacts can be used to not only store and version your datasets and model checkpoints but logging your models as artifacts enables you to use W&B Model Registry.

Artifacts and runs form a directed graph because a given W&B run can use another run’s output artifact as input. You do not need to define pipelines ahead of time. Weights and Biases will create the DAG for you when you use and log artifacts.

(Sample YOLO-NAS Checkpoint Artifact | Sample YOLO-NAS Checkpoint Lineage)

For more information about exploring an artifacts graph, you can check Explore and traverse artifact graphs.

Copy link
Collaborator

@ofrimasad ofrimasad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that you still kept the option to init wandb from outside the logger.
In that case please add a warning that will be presented if the run was initialized from outside the logger.
"The wandb run was initialized from outside of the WandbSGLogger. This means that SG cannot control the run ID to which this session will be logged. The current run id is: {run.id}"

Thanks

Copy link
Collaborator

@ofrimasad ofrimasad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use the common logging behavior of SG

src/super_gradients/common/sg_loggers/wandb_sg_logger.py Outdated Show resolved Hide resolved
@soumik12345
Copy link
Contributor Author

Hi @ofrimasad is there any more changes we need to make as part of this PR?

Copy link
Collaborator

@ofrimasad ofrimasad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ofrimasad
Copy link
Collaborator

Thank you for the code contribution @soumik12345. :)
I apologize for the delayed review.

@soumik12345
Copy link
Contributor Author

Thanks a lot for your reviews @ofrimasad ❤️

@ofrimasad ofrimasad merged commit e5e3167 into Deci-AI:master Jun 5, 2023
1 check passed
@soumik12345 soumik12345 deleted the soumik12345/wandb-logging branch June 6, 2023 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants