> ## Documentation Index
> Fetch the complete documentation index at: https://wb-21fd5541-docs-2626.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Integrate W&B with YOLOX to track object detection model training, log metrics, and visualize detection results.

# YOLOX

[YOLOX](https://github.com/Megvii-BaseDetection/YOLOX) is an anchor-free version of YOLO for object detection. You can use the YOLOX W\&B integration to turn on logging of metrics related to training, validation, and the system, and to interactively validate predictions with a single command-line argument.

This guide shows you how to authenticate with W\&B, install the integration, and enable W\&B logging when you train a YOLOX object detection model so you can track metrics and inspect predictions in the W\&B UI.

## Sign up and create an API key

An API key authenticates your machine to W\&B. You can generate an API key from your user profile.

<Note>
  For a more streamlined approach, go to [User Settings](https://wandb.ai/settings) and create an API key. Copy the API key immediately and save it in a secure location such as a password manager.
</Note>

1. Click your user profile icon in the upper right corner.
2. Select **User Settings**, then scroll to the **API Keys** section.

## Install the `wandb` library and log in

To install the `wandb` library locally and log in:

<Tabs>
  <Tab title="Command line">
    1. Set the `WANDB_API_KEY` [environment variable](/models/track/environment-variables/) to your API key. Replace values enclosed in `<>` with your own:

       ```bash theme={null}
       export WANDB_API_KEY=<your_api_key>
       ```

    2. Install the `wandb` library and log in.

       ```shell theme={null}
       pip install wandb

       wandb login
       ```
  </Tab>

  <Tab title="Python">
    ```bash theme={null}
    pip install wandb
    ```

    ```python theme={null}
    import wandb
    wandb.login()
    ```
  </Tab>

  <Tab title="Python notebook">
    ```notebook theme={null}
    !pip install wandb

    import wandb
    wandb.login()
    ```
  </Tab>
</Tabs>

## Log metrics

With the `wandb` library installed and your machine authenticated, you can enable W\&B logging from the YOLOX training script.

Use the `--logger wandb` command-line argument to turn on logging with `wandb`. Optionally, you can also pass all of the arguments that [`wandb.init()`](/models/ref/python/functions/init) expects. Prepend each argument with `wandb-`.

`num_eval_imges` controls the number of validation set images and predictions that W\&B logs to tables for model evaluation.

Replace the following placeholders before you run the command:

* `<project-name>`: The name of your W\&B project.
* `<entity>`: Your W\&B entity (username or team name).
* `<run-name>`: A name for this training run.
* `<run-id>`: A unique identifier for this run.
* `<save-dir>`: The directory where YOLOX saves checkpoints and logs.
* `<num-images>`: The number of validation images to log.
* `<bool>`: Whether to log checkpoints (`true` or `false`).

```shell theme={null}
# Log in to W&B
wandb login

# Call your YOLOX training script with the wandb logger argument
python tools/train.py .... --logger wandb \
                wandb-project <project-name> \
                wandb-entity <entity> \
                wandb-name <run-name> \
                wandb-id <run-id> \
                wandb-save_dir <save-dir> \
                wandb-num_eval_imges <num-images> \
                wandb-log_checkpoints <bool>
```

## Example

After your training run starts, YOLOX streams training, validation, and system metrics to your W\&B project, where you can compare runs and inspect predictions. See the following example for what a populated dashboard looks like.

See the [example dashboard with YOLOX training and validation metrics](https://wandb.ai/manan-goel/yolox-nano/runs/3pzfeom).

<Frame>
  <img src="https://mintcdn.com/wb-21fd5541-docs-2626/XhmnNyiZ55KfxLZn/images/integrations/yolox_example_dashboard.png?fit=max&auto=format&n=XhmnNyiZ55KfxLZn&q=85&s=a0ea753c9a88e8f39df34df3a092c408" alt="YOLOX training dashboard" width="3114" height="2394" data-path="images/integrations/yolox_example_dashboard.png" />
</Frame>

If you have questions or issues about this W\&B integration, open an issue in the [YOLOX repository](https://github.com/Megvii-BaseDetection/YOLOX).
