W&B dict copy to fix change bug (#12779)

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
Ben Pikus 2024-05-17 09:52:54 -07:00 committed by GitHub
parent 06ff89b404
commit e26036d965
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -100,7 +100,7 @@ def _plot_curve(
def _log_plots(plots, step): def _log_plots(plots, step):
"""Logs plots from the input dictionary if they haven't been logged already at the specified step.""" """Logs plots from the input dictionary if they haven't been logged already at the specified step."""
for name, params in plots.items(): for name, params in plots.copy().items(): # shallow copy to prevent plots dict changing during iteration
timestamp = params["timestamp"] timestamp = params["timestamp"]
if _processed_plots.get(name) != timestamp: if _processed_plots.get(name) != timestamp:
wb.run.log({name.stem: wb.Image(str(name))}, step=step) wb.run.log({name.stem: wb.Image(str(name))}, step=step)