nerfstudio-project / nerfstudio

A collaboration friendly studio for NeRFs
https://docs.nerf.studio
Apache License 2.0
9.18k stars 1.23k forks source link

Custom Logging Wandb #2224

Open jaidevshriram opened 1 year ago

jaidevshriram commented 1 year ago

Is your feature request related to a problem? Please describe. It's currently not clear how to incorporate custom logging for wandb/tensorboard into nerfstudio. The documentation describes how to add a new method but isn't clear on how to add additional logging metrics/images on top the default trainer.

Describe the solution you'd like Some documentation / guidelines on how to incorporate custom logging. Ideally, in my custom trainer, I can simply add statements like logger.log_scalar() or logger.log_image() or something, and have it sync with the other logged items. Clarifying how to specify the global step used in wandb logging may be enough too!

It would also be nice to specify a custom project name + experiment name for the wandb logging.

I guess this is less of a feature request and more of an inquiry. Would appreciate any help on how I can go about achieving the above - looking to get something running on my end more than waiting for an update to the package.

sraza-onshape commented 11 months ago

Hello @jaidevshriram - I've recently started working with this library - I have been thinking about how to approach custom logging also, and I believe I have an idea that can help. I haven't gotten around to implementing it yet, but it'd be good to get early feedback.

To address the first part of this issue, i.e., adding custom logs:

  1. *Use `nerfstudio.utils.writer.put_()methods**: the idea here is that if you're using a custom trainer (presumably by subclassing the defaultTrainerobject in this library), then I think the APIs we have available for logging are found in thewriter` module:

    • put_image()
    • put_scalar()
    • put_dict()
    • put_config() Just based on what I've read of the writer.py and trainer.py modules in this library, those look like the methods we're supposed to use (e.g., in a custom training loop) to log additional metrics of various data types.
  2. Re: Being Able to Specify a Custom Project Name and/or Experiment Name - I haven't thought about this alot yet, but I believe all one would need to do is add new fields to the ExperimentConfig class in this library. Since those fields are set via the args passed to the CLI. So once you run ns-train, the values for those new fields could just be passed in as keyword args. And to configure the underlying wandb run, one would then need to modify the WandbWriter class as needed.

jaidevshriram commented 11 months ago

Yup! After some digging around, I came to those same conclusions too, thanks for writing it down :) Regarding the project name and experiment name, those can be set via the CLI already I think, so I'm just using that at the moment.