API reference: Detectron2 integration#
You can use a Neptune hook to capture model training metadata during training and validation of detectron2 models.
Captures model training metadata and logs them to Neptune.
||-||(required) An existing run reference, as returned by
||Namespace under which all metadata logged by the Neptune hook will be stored.|
||20||How often NeptuneHook should log metrics (every nth epoch). The value must be greater than zero.
Example: Setting it to
Also applies to checkpoints, if
||Whether to upload the final model checkpoint, whenever it is saved by the Trainer. Expects
||Whether to upload checkpoints whenever they are saved by the Trainer. Expects
Creating a hook that sends the logs to an existing Neptune run object#
If Neptune can't find your project name or API token
As a best practice, you should save your Neptune API token and project name as environment variables:
You can, however, also pass them as arguments when initializing Neptune:
Also works for
API token: In the bottom-left corner, expand the user menu and select Get my API token.
- Project name: in the top-right menu: → Edit project details.
If you haven't registered, you can also log anonymously to a public project (make sure not to publish sensitive data through your code!):
Creating a Neptune run and hook with more options#
In the following example, we set the Trainer to save model checkpoints every 10th epoch. Neptune will upload those checkpoints and metrics at the same interval.
The full project name. For example,
To copy it, navigate to the project settings in the top-right () and select Edit project details.
Additionally, we pass an extra option not to capture the stdout during the run (
capture_stdout=False). For all the keyword arguments you can use, see neptune ≫
Passing a handler to the hook#
To log the metadata to a specific namespace of the run, you can create a namespace handler object and pass that to the hook.
In this case, all the metadata will be logged under the
validation namespace (folder) inside the run.
neptune-detectron2 repo on GitHub