-
Notifications
You must be signed in to change notification settings - Fork 639
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
log_graph = True
for tensorboard logger doesn't show model graph.
#240
Comments
@samet-akcay could you please take a look at this issue? |
FYI, also added Any pointer? |
@innat The part about logging images is not documented well. To log images to tensorboard, you need to set |
@ashwinvaidya17 thanks for the info. I've missed the Regarding the model graph, can you please point out what's wrong with the above approach? |
@ashwinvaidya17 I tested with
And I think it would be nice if we can show models layers activation maps. For example: in patch core, the backbone is wide-resnet with layers 2 and 3. How about showcasing their activation maps. |
@innat, it will be addressed with #227 .
We could discuss this. Perhaps this could be optional, so the user would be able to access when needed. |
Yes. It should be optional. It will be helpful for debugging purposes. |
Sorry, I've limited experience in pytorch. In keras, we can use keras.callbacks.TensorBoard this convenient callback handles most of the cases, like plot graphs, histograms, images, etc. Could u please share any references where I can find examples regarding tensorboard logging in pytorch-lighting? I found this, but a bit confusing to me. |
Edit: I have moved the for loop after trainer.fit so that it works with Patchcore for logger in loggers:
if isinstance(logger, AnomalibWandbLogger):
# NOTE: log graph gets populated only after one backward pass. This won't work for models which do not
# require training such as Padim
logger.watch(model, log_graph=True, log="all")
elif isinstance(logger, AnomalibTensorBoardLogger):
logger._log_graph = True
logger.log_graph(model, input_array=torch.ones((1, 3, 256,256))) So your train method should look like this def train():
"""Train an anomaly classification or segmentation model based on a provided configuration file."""
args = get_args()
config = get_configurable_parameters(model_name=args.model, config_path=args.config)
if config.project.seed != 0:
seed_everything(config.project.seed)
datamodule = get_datamodule(config)
model = get_model(config)
loggers = get_logger(config)
callbacks = get_callbacks(config)
trainer = Trainer(**config.trainer, logger=loggers, callbacks=callbacks)
trainer.fit(model=model, datamodule=datamodule)
for logger in loggers:
if isinstance(logger, AnomalibWandbLogger):
# NOTE: log graph gets populated only after one backward pass. This won't work for models which do not
# require training such as Padim
logger.watch(model, log_graph=True, log="all")
elif isinstance(logger, AnomalibTensorBoardLogger):
logger._log_graph = True
logger.log_graph(model, input_array=torch.ones((1, 3, 256,256)))
# load best model from checkpoint before evaluating
load_model_callback = LoadModelCallback(weights_path=trainer.checkpoint_callback.best_model_path)
trainer.callbacks.insert(0, load_model_callback)
trainer.test(model=model, datamodule=datamodule) Not sure if this is what you wanted. Also, to access other methods provided by tensorboard you can access |
@ashwinvaidya17 Thanks a lot, it's really helpful. I'm currently out of my workplace, will check soon. |
Describe the bug
I wanted to show the computational graph of the
patchcore
model and for that I enableproject.logger: tensorboard
and setlog_graph = True
Now, when I finished training, I run the tensorboard and under the
GRAPHS
tag, it showed nothing.To Reproduce
Steps to reproduce the behavior:
patchcore
config file and set `logger: tensorboard'working/anomaly_detection_engine/anomalib/anomalib/utils/loggers/__init__.py
and setlog_graph=True
Expected behavior
Screenshots
Hardware and Software Configuration
Additional context
add_image
function of the tensorboard callback, doesn't write any image on the tensorboard either.The text was updated successfully, but these errors were encountered: