# Dataset SDK (Node)

This guide walks through the programmatic steps to build and train a model using the EyePop.ai Node SDK. You’ll learn how to create a dataset, upload and label assets, configure augmentations, and launch training—all using API calls.

Example Code: [Python](https://github.com/eyepop-ai/Labs/tree/main/python/Data%20Ingest%20into%20EyePop.ai%20for%20training) / [Node](https://github.com/eyepop-ai/Labs/tree/main/node/Data%20Ingest)

### 🔧 Getting Started

EyePop.ai offers a Node SDK to make it easy to work with datasets, assets, annotations, and model training.

Install the SDK:

```
npm install --save @eyepop.ai/eyepop
```

Initialize the SDK:

```
import { EyePopClient } from '@eyepop.ai/eyepop';

const client = new EyePopClient({ apiKey: 'YOUR_API_KEY' });
```

***

### 📦 Dataset Creation

A dataset acts as the core container for your model’s training data. It defines the type of model you’re training (object or classification) and includes the labels you’ll be teaching it to recognize.

Example:

```
const dataset = await client.createDataset(
  'Accessories Demo',
  ['eye glasses', 'handbag', 'earrings', 'shoes'], // Labels
  ['object'] // Tags: 'object' for object detection, 'classification' for classification
);
```

***

### 🖼️ Asset Upload

You can upload image files to your dataset. These are the raw assets that will be labeled and used during model training.

Example:

```
const result = await client.uploadAsset(datasetUUID, datasetVersion, file, file.name);
console.log(result.uuid); // Uploaded asset's UUID
```

***

### 🏷️ Asset Labeling

There are two primary ways to label data:

#### 1. Classification

Assign a single label to the entire image.

Example:

```
const classificationLabel = {
  type: 'ground_truth',
  user_review: 'approved',
  annotation: {
    source_width: 1024,
    source_height: 768,
    classes: [
      { classLabel: 'eye glasses' },
    ]
  }
};

await client.updateAssetGroundTruth(assetUUID, datasetUUID, datasetVersion, classificationLabel)
```

#### 2. Object Detection

Label specific regions within the image using bounding boxes.

Example:

```
const objectDetectionLabel = {
  type: 'ground_truth',
  user_review: 'approved',
  annotation: {
    source_width: 1024,
    source_height: 768,
    objects: [
      {
        classLabel: 'handbag',
        x: 100, 
        y: 150, 
        width: 200, 
        height: 100
      }
    ]
  }
};

await client.updateAssetGroundTruth(assetUUID, datasetUUID, datasetVersion, objectDetectionLabel);
```

> ⚠️ Auto-labeling is currently managed internally and is not exposed via API at this time.

***

### 🎛️ Augmentation Configuration (Optional)

Before training, you can configure augmentation parameters like confidence threshold and candidate labels. This helps the model generalize better to new data.

Example:

```
const augmentationIntent = {
         "noise_level": "small",
         "upside_down_ok": true,
         "color_important": true,
         "exists_outdoors": false,
         "weather_allowed": false,
         "rotation_allowed": "medium",
         "occlusion_allowed": false,
         "camera_motion_important": false
}         
```

***

### 🚀 Start Model Training

Once your dataset is ready and labeled, kick off model training. EyePop.ai will automatically choose the appropriate model type (object detection or classification) based on the dataset tags.

Example:

```
const modelData = {
  name: "Accessory Model",
  description: "This is my new model",
  task: 'object_detection', // or 'image_classification'
  pretrained_model_uuid: pretrainedModelUUID, // optional model to start training from - useful for iterative training
  extra_params: {
    trainer: {
      preprocessor: {
        augment_intent: { } // your selected augmentations
      }
    }
  }
};

const model = await client.createModel(datasetUUID, datasetVersion, modelData, true);
console.log(model.uuid); // New model UUID
```

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.eyepop.ai/developer-documentation/self-service-training/dataset-sdk-node.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
