Skip to content

Commit

Permalink
Add VS Code Extension (ultralytics#15027)
Browse files Browse the repository at this point in the history
Co-authored-by: UltralyticsAssistant <[email protected]>
Co-authored-by: Ultralytics Assistant <[email protected]>
Co-authored-by: Glenn Jocher <[email protected]>
  • Loading branch information
4 people authored Aug 26, 2024
1 parent 391dc72 commit 848c5cd
Show file tree
Hide file tree
Showing 7 changed files with 339 additions and 19 deletions.
2 changes: 2 additions & 0 deletions docs/en/integrations/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ Welcome to the Ultralytics Integrations page! This page provides an overview of

- [NCNN](ncnn.md): Developed by [Tencent](http://www.tencent.com/), NCNN is an efficient neural network inference framework tailored for mobile devices. It enables direct deployment of AI models into apps, optimizing performance across various mobile platforms.

- [VS Code](vscode.md): An extension for VS Code that provides code snippets for accelerating development workflows with Ultralytics and also for anyone looking for examples to help learn or get started with Ultralytics.

### Export Formats

We also support a variety of model export formats for deployment in different environments. Here are the available formats:
Expand Down
276 changes: 276 additions & 0 deletions docs/en/integrations/vscode.md

Large diffs are not rendered by default.

53 changes: 35 additions & 18 deletions docs/en/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,24 +321,25 @@ Ultralytics allows users to easily modify their settings. Changes can be perform

The table below provides an overview of the settings available for adjustment within Ultralytics. Each setting is outlined along with an example value, the data type, and a brief description.

| Name | Example Value | Data Type | Description |
| ------------------ | --------------------- | --------- | ---------------------------------------------------------------------------------------------------------------- |
| `settings_version` | `'0.0.4'` | `str` | Ultralytics _settings_ version (different from Ultralytics [pip](https://pypi.org/project/ultralytics/) version) |
| `datasets_dir` | `'/path/to/datasets'` | `str` | The directory where the datasets are stored |
| `weights_dir` | `'/path/to/weights'` | `str` | The directory where the model weights are stored |
| `runs_dir` | `'/path/to/runs'` | `str` | The directory where the experiment runs are stored |
| `uuid` | `'a1b2c3d4'` | `str` | The unique identifier for the current settings |
| `sync` | `True` | `bool` | Whether to sync analytics and crashes to HUB |
| `api_key` | `''` | `str` | Ultralytics HUB [API Key](https://hub.ultralytics.com/settings?tab=api+keys) |
| `clearml` | `True` | `bool` | Whether to use ClearML logging |
| `comet` | `True` | `bool` | Whether to use [Comet ML](https://bit.ly/yolov8-readme-comet) for experiment tracking and visualization |
| `dvc` | `True` | `bool` | Whether to use [DVC for experiment tracking](https://dvc.org/doc/dvclive/ml-frameworks/yolo) and version control |
| `hub` | `True` | `bool` | Whether to use [Ultralytics HUB](https://hub.ultralytics.com) integration |
| `mlflow` | `True` | `bool` | Whether to use MLFlow for experiment tracking |
| `neptune` | `True` | `bool` | Whether to use Neptune for experiment tracking |
| `raytune` | `True` | `bool` | Whether to use Ray Tune for hyperparameter tuning |
| `tensorboard` | `True` | `bool` | Whether to use TensorBoard for visualization |
| `wandb` | `True` | `bool` | Whether to use Weights & Biases logging |
| Name | Example Value | Data Type | Description |
| ------------------ | --------------------- | --------- | -------------------------------------------------------------------------------------------- |
| `settings_version` | `'0.0.4'` | `str` | Ultralytics _settings_ version (different from Ultralytics [pip] version) |
| `datasets_dir` | `'/path/to/datasets'` | `str` | The directory where the datasets are stored |
| `weights_dir` | `'/path/to/weights'` | `str` | The directory where the model weights are stored |
| `runs_dir` | `'/path/to/runs'` | `str` | The directory where the experiment runs are stored |
| `uuid` | `'a1b2c3d4'` | `str` | The unique identifier for the current settings |
| `sync` | `True` | `bool` | Whether to sync analytics and crashes to HUB |
| `api_key` | `''` | `str` | Ultralytics HUB [API Key] |
| `clearml` | `True` | `bool` | Whether to use [ClearML] logging |
| `comet` | `True` | `bool` | Whether to use [Comet ML] for experiment tracking and visualization |
| `dvc` | `True` | `bool` | Whether to use [DVC for experiment tracking] and version control |
| `hub` | `True` | `bool` | Whether to use [Ultralytics HUB] integration |
| `mlflow` | `True` | `bool` | Whether to use [MLFlow] for experiment tracking |
| `neptune` | `True` | `bool` | Whether to use [Neptune] for experiment tracking |
| `raytune` | `True` | `bool` | Whether to use [Ray Tune] for hyperparameter tuning |
| `tensorboard` | `True` | `bool` | Whether to use [TensorBoard] for visualization |
| `wandb` | `True` | `bool` | Whether to use [Weights & Biases] logging |
| `vscode_msg` | `True` | `bool` | When VS Code terminal detected, enables prompt to download [Ultralytics-Snippets] extension. |

As you navigate through your projects or experiments, be sure to revisit these settings to ensure that they are optimally configured for your needs.

Expand Down Expand Up @@ -424,3 +425,19 @@ yolo train data=coco8.yaml model=yolov8n.pt epochs=10 lr0=0.01
```

Check out the full [CLI Guide](usage/cli.md) to explore more commands and usage examples.

<!-- Article Links -->

[Ultralytics HUB]: https://hub.ultralytics.com
[API Key]: https://hub.ultralytics.com/settings?tab=api+keys
[pip]: https://pypi.org/project/ultralytics/
[DVC for experiment tracking]: https://dvc.org/doc/dvclive/ml-frameworks/yolo
[Comet ML]: https://bit.ly/yolov8-readme-comet
[Ultralytics HUB]: https://hub.ultralytics.com
[ClearML]: ./integrations/clearml.md
[MLFlow]: ./integrations/mlflow.md
[Neptune]: https://neptune.ai/
[Tensorboard]: ./integrations/tensorboard.md
[Ray Tune]: ./integrations/ray-tune.md
[Weights & Biases]: ./integrations/weights-biases.md
[Ultralytics-Snippets]: ./integrations/vscode.md
4 changes: 4 additions & 0 deletions docs/en/reference/utils/__init__.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,8 @@ keywords: Ultralytics, utils, TQDM, Python, ML, Machine Learning utilities, YOLO

## ::: ultralytics.utils.url2file

<br><br><hr><br>

## ::: ultralytics.utils.vscode_msg

<br><br>
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ nav:
- Kaggle: integrations/kaggle.md
- JupyterLab: integrations/jupyterlab.md
- IBM Watsonx: integrations/ibm-watsonx.md
- VS Code: integrations/vscode.md
- HUB:
- hub/index.md
- Web:
Expand Down
6 changes: 6 additions & 0 deletions ultralytics/cfg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
DEFAULT_CFG,
DEFAULT_CFG_DICT,
DEFAULT_CFG_PATH,
IS_VSCODE,
LOGGER,
RANK,
ROOT,
Expand All @@ -25,6 +26,7 @@
checks,
colorstr,
deprecation_warn,
vscode_msg,
yaml_load,
yaml_print,
)
Expand Down Expand Up @@ -834,6 +836,10 @@ def entrypoint(debug=""):
# Show help
LOGGER.info(f"💡 Learn more at https://docs.ultralytics.com/modes/{mode}")

# Recommend VS Code extension
if IS_VSCODE and SETTINGS.get("vscode_msg", True):
LOGGER.info(vscode_msg())


# Special modes --------------------------------------------------------------------------------------------------------
def copy_default_cfg():
Expand Down
16 changes: 15 additions & 1 deletion ultralytics/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
PYTHON_VERSION = platform.python_version()
TORCH_VERSION = torch.__version__
TORCHVISION_VERSION = importlib.metadata.version("torchvision") # faster than importing torchvision
IS_VSCODE = os.environ.get("TERM_PROGRAM", False) == "vscode"
HELP_MSG = """
Examples for running Ultralytics:
Expand Down Expand Up @@ -1046,7 +1047,7 @@ class SettingsManager(dict):
version (str): Settings version. In case of local version mismatch, new default settings will be saved.
"""

def __init__(self, file=SETTINGS_YAML, version="0.0.4"):
def __init__(self, file=SETTINGS_YAML, version="0.0.5"):
"""Initializes the SettingsManager with default settings and loads user settings."""
import copy
import hashlib
Expand Down Expand Up @@ -1077,6 +1078,7 @@ def __init__(self, file=SETTINGS_YAML, version="0.0.4"):
"raytune": True,
"tensorboard": True,
"wandb": True,
"vscode_msg": True,
}
self.help_msg = (
f"\nView settings with 'yolo settings' or at '{self.file}'"
Expand Down Expand Up @@ -1152,6 +1154,18 @@ def url2file(url):
return Path(clean_url(url)).name


def vscode_msg(ext="ultralytics.ultralytics-snippets") -> str:
"""Display a message to install Ultralytics-Snippets for VS Code if not already installed."""
path = (USER_CONFIG_DIR.parents[2] if WINDOWS else USER_CONFIG_DIR.parents[1]) / ".vscode/extensions"
obs_file = path / ".obsolete" # file tracks uninstalled extensions, while source directory remains
installed = any(path.glob(f"{ext}*")) and ext not in (obs_file.read_text("utf-8") if obs_file.exists() else "")
return (
f"{colorstr('VS Code:')} view Ultralytics VS Code Extension ⚡ at https://docs.ultralytics.com/integrations/vscode"
if not installed
else ""
)


# Run below code on utils init ------------------------------------------------------------------------------------

# Check first-install steps
Expand Down

0 comments on commit 848c5cd

Please sign in to comment.