---
updatedAt: 2026-11-05T15:20:18.000Z
agentTools:
  siteIndex: https://docs.jfrog.com/llms.txt
  projectIndex: https://docs.jfrog.com/artifactory/llms.txt
---

# Machine Learning Repositories

Use Machine Learning (ML) Repositories in Artifactory to manage ML models with the same security, governance, and automation you apply to your traditional software packages. Using ML repositories and the FrogML Python library, you can connect AI/ML frameworks with Artifactory as a single source of truth to log, load, and manage models. This unification streamlines deployment, optimization, and governance, helping you scale trusted AI applications. For more information, see <Anchor target="_blank" href="/ai-ml/docs/jfrog-ml-introduction">JFrog ML documentation</Anchor>.

<Callout icon="📘" theme="info">
  **Note**

  Machine Learning is not a package type in Artifactory. Machine Learning repositories provide a repository structure that allows storage of multiple ML package types, like Hugging Face and PyTorch, in one central location. For more information, see <Anchor label="Machine Learning Repository Structure" title="Machine Learning Repository Structure" href="#machine-learning-repository-structure">Machine Learning Repository Structure</Anchor>.
</Callout>

<Image alt="ML_centralized_Storage.png" border={false} src="https://files.readme.io/05de68d8a2e8b403417401077b8332b0c1f4e9ef4116eaa9807dc2cc9c13a22c-uuid-285f8d16-0a63-00cf-5c69-98e83dcc13b2.png" />

Using ML repositories and FrogML in Artifactory provides the following benefits:

* **Secure Storage**: Protect your proprietary information by deploying models and additional resources to Artifactory <Anchor label="local repositories" title="Local Repositories" href="/docs/local-repositories">local repositories</Anchor>, giving you fine-grain control of the access to your models.
* **Format-Aware SDK:** Use the FrogML SDK to log and load complete, ready-to-use ML models in several supported formats.
* **Rich Metadata and Search**: Enhance models with rich metadata, including custom properties and automatically extracted attributes. Use the Artifactory Query Language (AQL) to easily search for and manage models based on their metadata.
* **Easy Collaboration**: Manage and share ML models with teammates alongside all your other application dependencies in a single system.

## Get Started with Machine Learning

To get started working with Machine Learning, complete the following main steps:

1. <Anchor label="Create a Machine Learning Repository" title="Create a Machine Learning Repository" href="#create-a-machine-learning-repository">Create a Machine Learning Repository</Anchor>
2. <Anchor label="Connect FrogML to Artifactory" title="Connect FrogML to Artifactory" href="#connect-frogml-to-artifactory">Connect FrogML to Artifactory</Anchor>
3. Log and load <Anchor label="file-based models" title="File-Based Models" href="#file-based-models">file-based models</Anchor> and <Anchor label="format-aware models" title="Format-Aware Models" href="#format-aware-models">format-aware models</Anchor> using the FrogML Library
   <Image border={false} src="https://files.readme.io/7576c09a2516f779ef2facb9755d05217fb1b67eb19624d1b3d50bb00510ad04-uuid-1a16b5bb-0509-2bd5-4f21-0e5e7d29f7ab.png" />

## Create a Machine Learning Repository

This topic describes how to create a Machine Learning repository. This is required before logging and loading Machine Learning models. Artifactory supports local repositories for Machine Learning models, allowing you to store and share first- and second-party packages with your organization. To learn about local ML repository structure in Artifactory, see <Anchor label="Machine Learning Repository Structure" title="Machine Learning Repository Structure" href="#machine-learning-repository-structure">Machine Learning Repository Structure</Anchor>.

For more information on JFrog repositories, see [Repository Management](https://docs.jfrog.com/artifactory/docs/repository-management).

**Prerequisite**: You need Admin or Project Admin permissions in Artifactory to create a repository. If you don't have Admin permissions, the option will not be available.

**To create a Machine Learning repository**:

1. In the **Administration** tab, click **Repositories | Create a Repository**.

   <Image alt="CreateAnsibleLocal1.png" border={false} src="https://files.readme.io/86dcb2937b6963a7fcd18c117046b623b25a6891c9df1dae56b0edd1d9e371be-uuid-150a8120-f9d2-512f-26bd-974e95a567b0.png" />
2. Select the **Local** repository type.
3. Select the **Machine Learning** package type.
4. In the **Repository Key** field, type a meaningful name for the repository. For example, `ml-local`. For more information on local repositories and their settings, see [Local Repositories](https://docs.jfrog.com/artifactory/docs/local-repositories).
5. Click **Create Repository**. The repository is created and the **Repositories** window is displayed.

## Connect FrogML to Artifactory

The FrogML SDK library is a Python tool designed to streamline the Machine Learning (ML) models and associated artifacts stored in JFrog Artifactory. With FrogML, you can upload and download models seamlessly and efficiently. FrogML is the main SDK library for JFrog ML. For more information, see [Explore JFrog AI/ML](/ai-ml/docs/explore-jfrog-ai-ml).

**Prerequisite**: Before connecting FrogML to Artifactory, you must have an existing Machine Learning repository in Artifactory. For more information, see [Create a Machine Learning Repository](#create-a-machine-learning-repository).

**To connect FrogML to Artifactory:**

1. Run the following command to install the FrogML SDK:

   ```
   pip install frogml
   ```
2. Run the following command to authenticate FrogML against Artifactory:

   ```
   export JF_ACCESS_TOKEN=<AUTH_TOKEN>
   export JF_URL=https://[JFrogPlatformURL]
   ```

   Where:

   * `<AUTH_TOKEN>`: Your Artifactory access token
   * `[JFrogPlatformURL]`: The URL of your JPD

   For example:

   ```
   export JF_ACCESS_TOKEN=ajK2m4p6N8r9TbuFvWxYz1C3E5G7H9JtywzZ55JCAwpHhTZsOr7Uv-L7oeCKZ3y
   export JF_URL=https://company.jfrog.io
   ```

<Callout icon="📘" theme="info">
  **Note**

  You can also use JFrog Set me up to copy the snippet populated with your token and environment. For more information, see <Anchor label="Use Artifactory Set Me Up for Configuring Package Manager Clients" title="Use Artifactory Set Me Up for Configuring Package Manager Clients" href="/docs/use-artifactory-set-me-up-for-configuring-package-manager-clients">Use Artifactory Set Me Up for Configuring Package Manager Clients</Anchor>.
</Callout>

**Next steps:**

Log and load ML models:

* [File-Based Models](#file-based-models)
* <Anchor label="Format-Aware Models" title="Format-Aware Models" href="#format-aware-models">Format-Aware Models</Anchor>

For more information about FrogML, see the [JFrog ML](/ai-ml/docs/getting-started-ai-ml) documentation.

## File-Based Models

File-based machine learning models are managed as opaque containers with no specific knowledge of the internal format. This approach offers universal flexibility, but requires that you determine and manage the exact dependencies and code required to successfully load and execute the model.

Artifactory ML repositories support the file types `.cbm`, `.pretrained_model`, `.onnx`, `.pkl`, `.pth`, and `.joblib`.

The following topics provide information about working with file-based models in Artifactory:

* <Anchor label="Log File-Based Models" title="Log File-Based Models" href="#log-file-based-models">Log File-Based Models</Anchor>
* <Anchor label="Load File-Based Models" title="Load File-Based Models" href="#load-file-based-models">Load File-Based Models</Anchor>

Artifactory also supports several format-aware model types. For more information, see <Anchor label="Format-Aware Models" title="Format-Aware Models" href="#format-aware-models">Format-Aware Models</Anchor>.

### Log File-Based Models

This is a universal, format-agnostic method for loading file-based models. The model must be a single file and cannot be a directory of files. For information about logging format-aware file types, see <Anchor label="Format-Aware Models" title="Format-Aware Models" href="#format-aware-models">Format-Aware Models</Anchor>.

You can upload a single model file to a Machine Learning repository using the `frogml.log_model()` function. This function uses [checksum-based storage](/installation/docs/checksum-based-storage). Artifactory calculates a checksum for each file and uploads it only if the file does not already exist in the repository.

After uploading the model, FrogML generates a file named `model-manifest.json`, which contains the model name and its related files and dependencies.

**To log machine learning models:**

Run the following command:

```
import frogml
frogml.files.log_model(
   source_path="<MODEL_FILE>",
   repository="<REPO_NAME>",
   model_name="<MODEL_NAME>",
   version="<MODEL_VERSION>", #optional
   properties = {"<KEY1>": "<VALUE1>"}, # optional
   dependencies = ["<MODEL_DEPENDENCIES>"], # optional
   code_dir = "<CODE_PATH>", # optional
   parameters = {"<HYPERPARAM_NAME>": "<VALUE>"}, # optional
   metrics = {"<METRIC_NAME>": "<VALUE>"}, # optional
   predict_file = "<PREDICT_PATH>", # optional
)
```

<Callout icon="❗️" theme="error">
  **Important**

  The parameters `code_dir`, `dependencies`, and `predict_file` must be provided as a complete set. You must specify all of them or none at all.
</Callout>

Where:

* `<MODEL_FILE>`: The local path to the model file you want to upload
* `<REPO_NAME>`: The name of the target repository in Artifactory
* `<MODEL_NAME>`: The unique name of the model
* `<MODEL_VERSION>` (Optional): The version of the model you want to upload. If version is not specified, the current timestamp is used
* `<KEY1>` and `<VALUE1>` (Optional): Properties key pair values to add searchable metadata to the model (optional). Separate multiple key pairs with a comma
* `<MODEL_DEPENDENCIES>` (Optional): Dependencies required to run the model, in one of the following formats:

  * A list of specific package requirements, for example `["catboost==1.2.5", "scikit-learn==1.3.2"]`
  * A path to a single `requirements.txt` , `pyproject.toml`, or `conda.yml` package manager file
  * A two-item list containing paths to the Poetry files `pyproject.toml` and `poetry.lock`
* `<CODE_PATH>` (Optional): The path to the directory containing the source code
* `<HYPERPARAM_NAME>` and `<VALUE>` (Optional): Hyperparameters used to train the model
* `<METRIC_NAME>` and `<VALUE>` (Optional): Metrics key pair values to add searchable numeric metadata to the model. Separate multiple key pairs with a comma
* `<PREDICT_PATH>` (Optional): The path to a script that defines how to make predictions with the model.

For example:

```
import frogml

frogml.files.log_model(
   source_path="./models/prod_churn_model_v1.4.rds",
   repository="ml-local",
   model_name="ranger-randomforest-classifier",
   version="1.4",
   properties={
       "framework": "R",
       "r-version": "4.4.1",
       "algorithm-package": "ranger",
       "model-type": "binary-classifier",
       "trained-by": "data-science-team"
   },
   metrics={"validation-auc": 0.89},
)
```

<Callout icon="📘" theme="info">
  **Note**

  You can also use JFrog Set me up to copy the snippet populated with your token and environment. For more information, see <Anchor label="Use Artifactory Set Me Up for Configuring Package Manager Clients" title="Use Artifactory Set Me Up for Configuring Package Manager Clients" href="/docs/use-artifactory-set-me-up-for-configuring-package-manager-clients">Use Artifactory Set Me Up for Configuring Package Manager Clients</Anchor>.
</Callout>

### Load File-Based Models

Run the following command:

```
import frogml
from pathlib import Path

loaded_model: Path = frogml.files.load_model(
    repository="<REPO_NAME>",
    model_name="<MODEL_NAME>",
    version="<MODEL_VERSION>",
    target_path="<PATH_TO_FOLDER>" # optional
)
```

Where:

* `<REPO_NAME>`: The name of the repository where the model is stored
* `<MODEL_NAME>`: The unique name of the target model
* `<MODEL_VERSION>`: The target version of the model you want to load
* `<PATH_TO_FOLDER>` (Optional): The path to the local directory where you want to save the model's files

For example:

```
import frogml
from pathlib import Path

loaded_model: Path = frogml.files.load_model(
    repository="ml-local",
    model_name="ranger-randomforest-classifier",
    version="1.4",
    target_path="./downloaded_models"
)
```

<Callout icon="📘" theme="info">
  **Note**

  You can also use JFrog Set me up to copy the snippet populated with your token and environment. For more information, see <Anchor label="Use Artifactory Set Me Up for Configuring Package Manager Clients" title="Use Artifactory Set Me Up for Configuring Package Manager Clients" href="/docs/use-artifactory-set-me-up-for-configuring-package-manager-clients">Use Artifactory Set Me Up for Configuring Package Manager Clients</Anchor>.
</Callout>

## Format-Aware Models

Format-aware models load directly into a ready-to-use object in your Python script, with all dependencies and associated code included. FrogML supports these format-aware model types:

* <Anchor label="CatBoost" title="CatBoost" href="#catboost">CatBoost</Anchor>
* <Anchor label="Hugging Face" title="Hugging Face" href="#hugging-face">Hugging Face</Anchor>
* <Anchor label="ONNX" title="ONNX" href="#onnx">ONNX</Anchor>
* <Anchor label="PyTorch" title="PyTorch" href="#pytorch">PyTorch</Anchor>
* <Anchor label="scikit-learn" title="scikit-learn" href="#scikit-learn">scikit-learn</Anchor>

For information about working with a model type not listed here, see <Anchor label="File-Based Models" title="File-Based Models" href="#file-based-models">File-Based Models</Anchor>.

### CatBoost

This section contains information about working with CatBoost models in Artifactory:

* <Anchor label="Log CatBoost Models" title="Log CatBoost Models" href="#log-catboost-models">Log CatBoost Models</Anchor>
* <Anchor label="Load CatBoost Models" title="Load CatBoost Models" href="#load-catboost-models">Load CatBoost Models</Anchor>

#### Log CatBoost Models

Run the following command:

```
import frogml

repository = "<REPO_NAME>"
name = "<MODEL_NAME>"
version = "<MODEL_VERSION>" # optional
properties = {"<KEY1>": "<VALUE1>"} # optional
dependencies = ["<MODEL_DEPENDENCIES>"] # optional
code_dir = "<CODE_PATH>" # optional
parameters = {"<HYPERPARAM_NAME>": "<VALUE>"} # optional
metrics = {"<METRIC_NAME>": "<VALUE>"} # optional
predict_file = "<PREDICT_PATH>" # optional
catboost_model = get_catboost_model()

frogml.catboost.log_model(
    model=catboost_model,
    repository=repository,
    model_name=name,
    version=version,
    properties=properties,
    dependencies=dependencies,
    code_dir=code_dir,
    parameters=parameters,
    metrics=metrics,
    predict_file=predict_file,
)
```

<Callout icon="❗️" theme="error">
  **Important**

  The parameters `code_dir`, `dependencies`, and `predict_file` must be provided as a complete set. You must specify all of them or none at all.
</Callout>

Where:

* `<REPO_NAME>`: The name of the Artifactory repository where the model is stored
* `<MODEL_NAME>`: The unique name of the model you want to download
* `<MODEL_VERSION>` (Optional): The version of the model you want to upload. If version is not specified, the current timestamp is used
* `<KEY1>` and `<VALUE1>` (Optional): Properties key pair values to add searchable string-based tags or metadata to the model. Separate multiple key pairs with a comma
* `<MODEL_DEPENDENCIES>` (Optional): Dependencies required to run the model, in one of the following formats:

  * A list of specific package requirements, for example `["catboost==1.2.5", "scikit-learn==1.3.2"]`
  * A path to a single `requirements.txt` , `pyproject.toml`, or `conda.yml` package manager file
  * A two-item list containing paths to the `pyproject.toml` and `poetry.lock` files
* `<CODE_PATH>` (Optional): The path to the directory containing the source code
* `<HYPERPARAM_NAME>` and `<VALUE>` (Optional): Hyperparameters used to train the model
* `<METRIC_NAME>` and `<VALUE>` (Optional): Metrics key pair values to add searchable numeric metadata to the model. Separate multiple key pairs with a comma
* `<PREDICT_PATH>` (Optional): The path to a script that defines how to make predictions with the model.

For example:

```
import frogml

repository = "ml-local"
name = "churn_classifier_v2"
version = "2.0"
properties = {"training_dataset": "processed_data_v4.csv"}
dependencies = ["catboost==1.2.5", "scikit-learn==1.3.2", "pandas==2.2.0"]
metrics = {
    "accuracy": 0.92, 
    "f1_score": 0.88, 
}
code_dir = "src/training/"
predict_file = "src/training/predict.py"
catboost_model = get_catboost_model()

frogml.catboost.log_model(
    model=catboost_model,
    repository=repository,
    model_name=name,
    version=version,
    properties=properties,
    dependencies=dependencies,
    metrics=metrics,
    code_dir=code_dir,
)
```

#### Load CatBoost Models

Run the following command:

```
import frogml

repository = "<REPO_NAME>"
name = "<MODEL_NAME>"
version = "<MODEL_VERSION>"

catboost_deserialized_model = frogml.catboost.load_model(
    repository=repository,
    model_name=name,
    version=version,
)
```

Where:

* `<REPO_NAME>`: The name of the Artifactory repository where the model is stored
* `<MODEL_NAME>`: The unique name of the model you want to download
* `<MODEL_VERSION>`: The version number of the model you want to load

For example:

```
import frogml

repository = "ml-local"
name = "churn_classifier_v2"
version = "2.0"

catboost_deserialized_model = frogml.catboost.load_model(
    repository=repository,
    model_name=name,
    version=version,
)
```

### Hugging Face

This section contains information about working with Hugging Face models in Machine Learning repositories in Artifactory:

* <Anchor label="Log Hugging Face Models" title="Log Hugging Face Models" href="#log-hugging-face-models">Log Hugging Face Models</Anchor>
* <Anchor label="Load Hugging Face Models" title="Load Hugging Face Models" href="#load-hugging-face-models">Load Hugging Face Models</Anchor>

Artifactory also supports Hugging Face repositories, which work natively with the Hugging Face Hub library and CLI. For more information, see <Anchor label="Hugging Face Repositories" title="Hugging Face Repositories" href="/docs/hugging-face-repositories">Hugging Face Repositories</Anchor>.

#### Log Hugging Face Models

Run the following command:

```
import frogml

repository = "<REPO_NAME>"
name = "<MODEL_NAME>"
version = "<MODEL_VERSION>" # optional
properties = {"<KEY1>": "<VALUE1>"} # optional
dependencies = ["<MODEL_DEPENDENCIES>"] # optional
code_dir = "<CODE_PATH>" # optional
parameters = {"<HYPERPARAM_NAME>": "<VALUE>"} # optional
metrics = {"<METRIC_NAME>": "<VALUE>"} # optional
predict_file = "<PREDICT_PATH>" # optional
model = get_huggingface_model() 
tokenizer = get_huggingface_tokenizer()

frogml.huggingface.log_model(
    model=model,
    tokenizer=tokenizer,
    repository=repository,
    model_name=name,
    version=version,
    properties=properties,
    dependencies=dependencies,
    code_dir=code_dir,
    parameters=parameters,
    metrics=metrics,
    predict_file=predict_file,
)
```

<Callout icon="❗️" theme="error">
  **Important**

  The parameters `code_dir`, `dependencies`, and `predict_file` must be provided as a complete set. You must specify all of them or none at all.
</Callout>

Where:

* `<REPO_NAME>`: The name of the Artifactory repository where the model is stored
* `<MODEL_NAME>`: The unique name of the model you want to download
* `<MODEL_VERSION>`: The version of the model you want to upload. If version is not specified, the current timestamp is used
* `<KEY1>` and `<VALUE1>`: Key pair values to add searchable metadata to the model. Separate multiple key pairs with a comma
* `<MODEL_DEPENDENCIES>` (Optional): Dependencies required to run the model, in one of the following formats:

  * A list of specific package requirements, for example `["catboost==1.2.5", "scikit-learn==1.3.2"]`
  * A path to a single `requirements.txt` , `pyproject.toml`, or `conda.yml` package manager file
  * A two-item list containing paths to the `pyproject.toml` and `poetry.lock` files
* `<CODE_PATH>`: The path to the directory containing the source code
* `<HYPERPARAM_NAME>` and `<VALUE>` (Optional): Hyperparameters used to train the model
* `<METRIC_NAME>` and `<VALUE>` (Optional): Key pair values to add searchable numeric metadata to the model. Separate multiple key pairs with a comma
* `<PREDICT_PATH>` (Optional): The path to a script that defines how to make predictions with the model.

For example:

```
import frogml

repository = "ml-local"
name = "sentiment-analyzer"
version = "1.2.0"
properties = {
    "base_model": "distilbert-base-uncased-finetuned-sst-2-english",
    "dataset": "SST-2 (Stanford Sentiment Treebank)", 
    "accuracy": 0.93
}
dependencies = ["environment.yaml"]
code_dir = "src/fine_tuning/"
predict_file = "src/fine_tuning/predict.py"
model = get_huggingface_model() 
tokenizer = get_huggingface_tokenizer()

frogml.huggingface.log_model(
    model=model,
    tokenizer=tokenizer,
    repository=repository,
    model_name=name,
    version=version,
    properties=properties,
    dependencies=dependencies,
    code_dir=code_dir,
)
```

#### Load Hugging Face Models

Run the following command:

```
import frogml

repository = "<REPO_NAME>"
name = "<MODEL_NAME>"
version = "<MODEL_VERSION>"

huggingface_deserialized_model = frogml.huggingface.load_model(
    repository=repository,
    model_name=name,
    version=version,
)
```

Where:

* `<REPO_NAME>`: The name of the Artifactory repository where the model is stored
* `<MODEL_NAME>`: The unique name of the model you want to download
* `<MODEL_VERSION>`: The version number of the model you want to load

For example:

```
import frogml

repository = "ml-local"
name = "sentiment-analyzer"
version = "1.2.0"

huggingface_deserialized_model = frogml.huggingface.load_model(
    repository=repository,
    model_name=name,
    version=version,
)
```

### ONNX

This section contains information about working with ONNX models in Artifactory:

* <Anchor label="Log ONNX Models" title="Log ONNX Models" href="#log-onnx-models">Log ONNX Models</Anchor>
* <Anchor label="Load ONNX Models" title="Load ONNX Models" href="#load-onnx-models">Load ONNX Models</Anchor>

#### Log ONNX Models

Run the following command:

```
import frogml

repository = "<REPO_NAME>"
name = "<MODEL_NAME>"
version = "<MODEL_VERSION>" # optional
properties = {"<KEY1>": "<VALUE1>"} # optional
dependencies = ["<MODEL_DEPENDENCIES>"] # optional
code_dir = "<CODE_PATH>" # optional
parameters = {"<HYPERPARAM_NAME>": "<VALUE>"} # optional
metrics = {"<METRIC_NAME>": "<VALUE>"} # optional
predict_file = "<PREDICT_PATH>" # optional
onnx_model = get_onnx_model()

frogml.onnx.log_model(
    model=onnx_model,
    repository=repository,
    model_name=name,
    version=version,
    properties=properties,
    dependencies=dependencies,
    code_dir=code_dir,
    parameters=parameters,
    metrics=metrics,
    predict_file=predict_file,
)
```

<Callout icon="❗️" theme="error">
  **Important**

  The parameters `code_dir`, `dependencies`, and `predict_file` must be provided as a complete set. You must specify all of them or none at all.
</Callout>

Where:

* `<REPO_NAME>`: The name of the Artifactory repository where the model is stored
* `<MODEL_NAME>`: The unique name of the model you want to download
* `<MODEL_VERSION>` (Optional): The version of the model you want to upload. If version is not specified, the current timestamp is used
* `<KEY1>` and `<VALUE1>` (Optional): Key pair values to add searchable string-based tags or metadata to the model. Separate multiple key pairs with a comma
* `<MODEL_DEPENDENCIES>` (Optional): Dependencies required to run the model, in one of the following formats:

  * A list of specific package requirements, for example `["catboost==1.2.5", "scikit-learn==1.3.2"]`
  * A path to a single `requirements.txt` , `pyproject.toml`, or `conda.yml` package manager file
  * A two-item list containing paths to the `pyproject.toml` and `poetry.lock` files
* `<CODE_PATH>` (Optional): The path to the directory containing the source code
* `<HYPERPARAM_NAME>` and `<VALUE>` (Optional): Hyperparameters used to train the model
* `<METRIC_NAME>` and `<VALUE>` (Optional): Key pair values to add searchable numeric metadata to the model. Separate multiple key pairs with a comma
* `<PREDICT_PATH>` (Optional): The path to a script that defines how to make predictions with the model.

For example:

```
import frogml

repository = "ml-local"
name = "yolo-object-detector"
version = "1.2.0"
properties = {
    "source_framework": "PyTorch",
    "precision": "FP16"
}
dependencies = ["torch==2.2.0", "onnx==1.16.0"]
code_dir = "src/conversion_scripts/"
predict_file = "src/conversion_scripts/predict.py"
onnx_model = get_onnx_model()

frogml.onnx.log_model(
    model=onnx_model,
    repository=repository,
    model_name=name,
    version=version,
    properties=properties,
    dependencies=dependencies,
    code_dir=code_dir,
)
```

#### Load ONNX Models

Run the following command:

```
import frogml

repository = "<REPO_NAME>"
name = "<MODEL_NAME>"
version = "<MODEL_VERSION>"

onnx_deserialized_model = frogml.onnx.load_model(
    repository=repository,
    model_name=name,
    version=version,
)
```

Where:

* `<REPO_NAME>`: The name of the Artifactory repository where the model is stored
* `<MODEL_NAME>`: The unique name of the model you want to download
* `<MODEL_VERSION>`: The version number of the model you want to load

For example:

```
import frogml

repository = "ml-local"
name = "yolo-object-detector"
version = "1.2.0"

onnx_deserialized_model = frogml.onnx.load_model(
    repository=repository,
    model_name=name,
    version=version,
)
```

### PyTorch

This section contains information about working with PyTorch models in Artifactory:

* <Anchor label="Log PyTorch Models" title="Log PyTorch Models" href="#log-pytorch-models">Log PyTorch Models</Anchor>
* <Anchor label="Load PyTorch Models" title="Load PyTorch Models" href="#load-pytorch-models">Load PyTorch Models</Anchor>

#### Log PyTorch Models

Run the following command:

```
import frogml
import torch.nn as nn

repository = "<REPO_NAME>"
name = "<MODEL_NAME>"
version = "<MODEL_VERSION>" # optional
properties = {"<KEY1>": "<VALUE1>"} # optional
dependencies = ["<MODEL_DEPENDENCIES>"] # optional
code_dir = "<CODE_PATH>" # optional
parameters = {"<HYPERPARAM_NAME>": "<VALUE>"} # optional
metrics = {"<METRIC_NAME>": "<VALUE>"} # optional
predict_file = "<PREDICT_PATH>" # optional

class Classifier(nn.Module):
    def __init__(self):
        super().__init__()
        self.hidden1 = nn.Linear(8, 12)
        self.act1 = nn.ReLU()
        self.hidden2 = nn.Linear(12, 8)
        self.act2 = nn.ReLU()
        self.output = nn.Linear(8, 1)
        self.act_output = nn.Sigmoid()

    def forward(self, x):
        x = self.act1(self.hidden1(x))
        x = self.act2(self.hidden2(x))
        x = self.act_output(self.output(x))
        return x

frogml.pytorch.log_model(
    model=Classifier(),
    repository=repository,
    model_name=name,
    version=version,
    properties=properties,
    dependencies=dependencies,
    code_dir=code_dir,
    parameters=parameters,
    metrics=metrics,
    predict_file=predict_file,
)
```

<Callout icon="❗️" theme="error">
  **Important**

  The parameters `code_dir`, `dependencies`, and `predict_file` must be provided as a complete set. You must specify all of them or none at all.
</Callout>

Where:

* `<REPO_NAME>`: The name of the Artifactory repository where the model is stored
* `<MODEL_NAME>`: The unique name of the model you want to download
* `<MODEL_VERSION>` (Optional): The version of the model you want to upload. If version is not specified, the current timestamp is used
* `<KEY1>` and `<VALUE1>` (Optional): Properties key pair values to add searchable string-based tags or metadata to the model. Separate multiple key pairs with a comma
* `<MODEL_DEPENDENCIES>` (Optional): Dependencies required to run the model, in one of the following formats:

  * A list of specific package requirements, for example `["catboost==1.2.5", "scikit-learn==1.3.2"]`
  * A path to a single `requirements.txt` , `pyproject.toml`, or `conda.yml` package manager file
  * A two-item list containing paths to the `pyproject.toml` and `poetry.lock` files
* `<CODE_PATH>` (Optional): The path to the directory containing the source code
* `<HYPERPARAM_NAME>` and `<VALUE>` (Optional): Hyperparameters used to train the model
* `<METRIC_NAME>` and `<VALUE>` (Optional): Metrics key pair values to add searchable numeric metadata to the model. Separate multiple key pairs with a comma
* `<PREDICT_PATH>` (Optional): The path to a script that defines how to make predictions with the model.

For example:

```
import frogml
import torch
import torch.nn as nn

repository = "ml-local"
name = "sales-lead-classifier"
version = "1.2.0"
code_dir = "src/training_scripts/"
properties = {"data-sensitivity": "confidential"}
dependencies = [f"torch==2.2.0", "pandas==1.2.3"]

parameters = {
    "learning_rate": 0.001,
    "epochs": 50,
    "batch_size": 32,
}

metrics = {
    "validation_loss": 0.253,
    "validation_accuracy": 0.915
}

predict_file = "src/training_scripts/predict.py"

class Classifier(nn.Module):
    def __init__(self):
        super().__init__()
        self.hidden1 = nn.Linear(8, 12)
        self.act1 = nn.ReLU()
        self.hidden2 = nn.Linear(12, 8)
        self.act2 = nn.ReLU()
        self.output = nn.Linear(8, 1)
        self.act_output = nn.Sigmoid()

    def forward(self, x):
        x = self.act1(self.hidden1(x))
        x = self.act2(self.hidden2(x))
        x = self.act_output(self.output(x))
        return x

trained_model = Classifier()

frogml.pytorch.log_model(
    model=trained_model,
    repository=repository,
    model_name=name,
    version=version,
    properties=properties,
    dependencies=dependencies,
    code_dir=code_dir,
    parameters=parameters,
    metrics=metrics,
)
```

#### Load PyTorch Models

Run the following command:

```
import frogml

repository = "<REPO_NAME>"
name = "<MODEL_NAME>"
version = "<MODEL_VERSION>"

model = frogml.pytorch.load_model(
    repository=repository,
    model_name=name,
    version=version,
)
```

Where:

* `<REPO_NAME>`: The name of the Artifactory repository where the model is stored
* `<MODEL_NAME>`: The unique name of the model you want to download
* `<MODEL_VERSION>`: The version number of the model you want to load

For example:

```
import frogml

repository = "ml-local"
name = "sales-lead-classifier"
version = "1.2.0"

model = frogml.pytorch.load_model(
    repository=repository,
    model_name=name,
    version=version,
)
```

### scikit-learn

This section contains information about working with scikit-learn models in Artifactory:

* <Anchor label="Log scikit-learn Models" title="Log scikit-learn Models" href="#log-scikit-learn-models">Log scikit-learn Models</Anchor>
* <Anchor label="Load scikit-learn Models" title="Load scikit-learn Models" href="#load-scikit-learn-models">Load scikit-learn Models</Anchor>

#### Log scikit-learn Models

Run the following command:

```
import frogml

repository = "<REPO_NAME>"
name = "<MODEL_NAME>"
version = "<MODEL_VERSION>" # optional
properties = {"<KEY1>": "<VALUE1>"} # optional
dependencies = ["<MODEL_DEPENDENCIES>"] # optional
code_dir = "<CODE_PATH>" # optional
parameters = {"<HYPERPARAM_NAME>": "<VALUE>"} # optional
metrics = {"<METRIC_NAME>": "<VALUE>"} # optional
predict_file = "<PREDICT_PATH>" # optional
joblib_model = get_scikit_learn()

frogml.scikit_learn.log_model(
    model=joblib_model,
    repository=repository,
    model_name=name,
    version=version,
    properties=properties,
    dependencies=dependencies,
    code_dir=code_dir,
    parameters=parameters,
    metrics=metrics,
    predict_file=predict_file,
)
```

<Callout icon="❗️" theme="error">
  **Important**

  The parameters `code_dir`, `dependencies`, and `predict_file` must be provided as a complete set. You must specify all of them or none at all.
</Callout>

Where:

* `<REPO_NAME>`: The name of the Artifactory repository where the model is stored
* `<MODEL_NAME>`: The unique name of the model you want to download
* `<MODEL_VERSION>` (Optional): The version of the model you want to upload. If version is not specified, the current timestamp is used
* `<KEY1>` and `<VALUE1>` (Optional): Properties key pair values to add searchable string-based tags or metadata to the model. Separate multiple key pairs with a comma
* `<MODEL_DEPENDENCIES>` (Optional): Dependencies required to run the model, in one of the following formats:

  * A list of specific package requirements, for example `["catboost==1.2.5", "scikit-learn==1.3.2"]`
  * A path to a single `requirements.txt` , `pyproject.toml`, or `conda.yml` package manager file
  * A two-item list containing paths to the `pyproject.toml` and `poetry.lock` files
* `<CODE_PATH>` (Optional): The path to the directory containing the source code
* `<HYPERPARAM_NAME>` and `<VALUE>` (Optional): Hyperparameters used to train the model
* `<METRIC_NAME>` and `<VALUE>` (Optional): Metrics key pair values to add searchable numeric metadata to the model. Separate multiple key pairs with a comma
* `<PREDICT_PATH>` (Optional): The path to a script that defines how to make predictions with the model.

For example:

```
import frogml

repository = "ml-local"
name = "customer-churn-predictor"
version = "1.2.0"
properties = {"feature_set_version": "v3"}
dependencies = ["scikit-learn==1.4.2", "pandas==2.2.2"]
code_dir = "src/training/"
predict_file = "src/training/predict.py"
joblib_model = get_scikit_learn()

frogml.scikit_learn.log_model(
    model=joblib_model,
    repository=repository,
    model_name=name,
    version=version,
    properties=properties,
    dependencies=dependencies,
    code_dir=code_dir,
)
```

#### Load scikit-learn Models

Run the following command:

```
import frogml

repository = "<REPO_NAME>"
name = "<MODEL_NAME>"
version = "<MODEL_VERSION>"

scikit_learn_deserialized_model = frogml.scikit_learn.load_model(
    repository=repository,
    model_name=name,
    version=version,
)
```

Where:

* `<REPO_NAME>`: The name of the Artifactory repository where the model is stored
* `<MODEL_NAME>`: The unique name of the model you want to download
* `<MODEL_VERSION>`: The version number of the model you want to load

For example:

```
import frogml

repository = "ml-local"
name = "customer-churn-predictor"
version = "1.2.0"

scikit_learn_deserialized_model = frogml.scikit_learn.load_model(
    repository=repository,
    model_name=name,
    version=version,
)
```

## Additional Machine Learning Information

The following pages provide additional information about using Machine Learning repositories in Artifactory:

* <Anchor label="Get Model Information" title="Get Model Information" href="#get-model-information">Get Model Information</Anchor>
* <Anchor label="Machine Learning Repository Structure" title="Machine Learning Repository Structure" href="#machine-learning-repository-structure">Machine Learning Repository Structure</Anchor>
* [`predict.py` File Requirements](#predictpy-file-requirements)

## Get Model Information

Run the following command:

```
import frogml

repository = "<REPO_NAME>"
name = "<MODEL_NAME>"
version = "<MODEL_VERSION>"

model_information = frogml.<FORMAT>.get_model_info(
    repository=repository,
    model_name=name,
    version=version,
)
```

Where:

* `<REPO_NAME>`: The name of the repository where the model is located
* `<MODEL_NAME>`: The unique name of the model
* `<MODEL_VERSION>`: The target version of the model
* `<FORMAT>`: The format of the model, which must be one of the following values:

  * `catboost`
  * `files`
  * `huggingface`
  * `onnx`
  * `pytorch`
  * `scikit_learn`

  For example:

  ```
  import frogml

  repository = "ml-local"
  name = "sentiment-analyzer"
  version = "1.2.0"

  model_information = frogml.huggingface.get_model_info(
      repository=repository,
      model_name=name,
      version=version,
  )
  ```

## Machine Learning Repository Structure

The FrogML repository structure for local repositories is as follows:

```
├── ${REPOSITORY_NAME}
    └── models
        └── ${MODEL_NAME}
            └── ${MODEL_VERSION}
                ├── model-manifest.json
                ├── model/
                    ├── file1
                    └── file2
                └── code/
                    ├── code.zip
                    └── requirements.txt
```

## predict.py File Requirements

When providing a `predict.py` file for any `log_model` function, the file must meet these requirements:

* **File Name**: The file must be named `predict.py`.
* **File Location**: `predict.py` must reside within the `code_dir` directory hierarchy. This includes being a direct child of `code_dir` or in any of its subdirectories.
* **Function Signature**: Must contain a function with the exact signature `def predict (<param1>, <param2> **kwargs>)`

  * Signature must start with `def predict(` and end with `**kwargs)`
  * Signature must have exactly two parameters between `predict(` and `**kwargs)`
  * Each parameter must contain at least one non-whitespace character and cannot contain a comma
  * Flexible whitespace is allowed around keywords, parentheses, and commas

## Limitations of Machine Learning Repositories in Artifactory

The following are the limitations of Machine Learning repositories in Artifactory:

* **Xray Scanning**: Xray scanning for ML resources is not supported.

## Frequently Asked Questions

This section provides answers to frequently asked questions about Machine Learning repositories.

<Accordion title="FAQs" icon="plus">

  ##### Q: How do I create a Machine Learning repository?

  **A:** Create a local repository and select the **Machine Learning** package type. For more information, see [Create a Machine Learning Repository](#create-a-machine-learning-repository).

  ##### Q: What is the difference between file-based models and format-aware models?

  **A:** File-based models are stored as opaque files, and you manage the code and dependencies needed to run them. Format-aware models load as a ready-to-use Python object through FrogML for CatBoost, Hugging Face, ONNX, PyTorch, and scikit-learn. For more information, see [File-Based Models](#file-based-models) and [Format-Aware Models](#format-aware-models).

  ##### Q: What permissions do I need before I create a Machine Learning repository?

  **A:** You need Admin or Project Admin permissions in Artifactory. Without those permissions, the create option isn't available. For more information, see [Create a Machine Learning Repository](#create-a-machine-learning-repository).

  ##### Q: What are the requirements for the predict.py file?

  **A:** The file must be named `predict.py`, it must be in the `code_dir` directory or one of its subdirectories, and it must include a `predict` function with the required signature. For more information, see [predict.py File Requirements](#predictpy-file-requirements).

  ##### Q: What are the Xray limitations for Machine Learning repositories?

  **A:** Xray scanning for Machine Learning resources isn't supported. For more information, see [Limitations of Machine Learning Repositories in Artifactory](#limitations-of-machine-learning-repositories-in-artifactory).
</Accordion>

## Related Topics

* [Get Started with AI/ML in JFrog](/ai-ml/docs/getting-started-ai-ml)
* [JFrog ML](/ai-ml/docs/jfrog-ml-introduction)
* [Local Repositories](https://docs.jfrog.com/artifactory/docs/local-repositories)
* [Repository Management](https://docs.jfrog.com/artifactory/docs/repository-management)