4. Manage data with the AML Dashboard¶
4.1. Background¶
The AML Dashboard is a web-based tool that allows users to interact with the AML framework.
This tutorial showcases the data collection step of an AML model training process using the AML Dashboard.
4.2. Prerequisites¶
Ensure you have installed the AML Dashboard using one of the following methods:
For more information, check the AML Dashboard Interfaces and AML Dashboard Usage sections.
4.3. Running the demo¶
To run the necessary components for collecting data using the AML Dashboard, follow these steps:
4.3.1. Start the backend server¶
Navigate to the
backenddirectory.
cd backend
Load the AML-IP environment.
source /AML-IP/install/setup.bash
Start the server:
python3 server.py
4.3.2. Start the AML Dashboard¶
Navigate to the
frontend/aml_dashboarddirectory.
cd frontend/aml_dashboard
Start the AML Dashboard:
npm run dev
Access the dashboard at http://localhost:5173/.
4.4. Collecting data¶
There are several options available for dataset creation:
Webcam: Record instances using the webcam.
Navigate to the
Data Managementtab on the AML Dashboard.Choose
Sensorsfrom the drop-down menu in the Choose the model for the training set section.In the webcam section, toggle the
activate videobutton to enable the webcam.Introduce a label for the class that will be recorded in the Instance label section.
Press the
Hold to record instancesbutton in the Capture instances to the training set section to start recording data.
Standard dataset: Load a standard dataset from the system.
Navigate to the
Data Managementtab on the AML Dashboard.Choose a dataset from the drop-down menu in the Choose the model for the training set section.
Click on the
Load datasetbutton to load the dataset.
Custom dataset: Load a custom dataset.
Navigate to the
Data Managementtab on the AML Dashboard.Choose ‘Custom’ from the drop-down menu in the Choose the model for the training set section.
Click on the
Load datasetbutton to load the custom dataset.A popup will appear, allowing you to select the desired dataset from your local machine.
Warning
The custom dataset must be a json file in the correct format.
To create the dataset in the desired format, the code snippet below can be used as a reference:
def save_in_format(images, labels):
"""
Function that formats the data to be saved in the required format.
Arguments:
images: List of images. Each image is a one-dimensional list.
labels: List of labels. Each label is an integer.
returns: Formatted data
"""
def generate_data_uri(image):
"""
Convert a 2D image list or array to a PNG data URI.
"""
# Convert the list to a NumPy array for processing
image_len = len(image)
one_side = int(math.sqrt(image_len))
image_array = np.array(image, dtype=np.uint8).reshape(one_side, one_side)
img = Image.fromarray(image_array, mode="L") # Create a PIL image from the array
buffered = io.BytesIO()
img.save(buffered, format="PNG") # Save the image to the buffer in PNG format
img_data = buffered.getvalue()
data_uri = f"data:image/png;base64,{base64.b64encode(img_data).decode('utf-8')}"
return data_uri
combined_data = list(zip(images, labels))
sampled_data = random.sample(combined_data, 100)
sampled_images, sampled_labels = zip(*sampled_data)
# Prepare the data in the required format
formatted_data = {
"total": len(images),
"limit": 1000,
"skip": 0,
"instances": [
{
"datasetName": "training2-set-models", # This must be kept as is
"x": image, # The image must be a one-dimensional list
"thumbnail": generate_data_uri(image),
"y": label, # The label must be numeric
"id": idx,
}
for idx, (image, label) in enumerate(zip(sampled_images, sampled_labels))
]
}
return formatted_data