Epigos offers an API that allows you to upload dataset to your projects. This API is accessible within the Epigos Python SDK.

You’ll need to Create an API Key to Authentication with Epigos AI.

Managing Projects

To manage projects, you can use the Project class:

project()

Retrieves a project from Epigos AI and returns the Project class that can be used to upload datasets.

# Load project
project = client.project("project_id")
print(project)

Upload dataset

You have the option to upload images alongside annotations suitable for tasks such as object detection and classification.

upload()

You can upload a single image along with its annotation to the project. Currently supported annotation formats are Pascal VOC and YOLO.

ParamTypeDescription
image_pathstringPath or directory to images to upload.
annotation_pathstringOptional path to annotation file to annotate the image. For image classification, this will be used as class label if use_folder_as_class_name is false.
batch_namestringName of batch to upload to within project. Defaults to sdk-upload.
box_formatstringFormat of annotation to upload. Options are (pascal_voc, yolo). Defaults to pascal_voc.
labels_mapdictOptional Epigos AI label ID to class name mapping. Usefull to skip creating labels if it’s already created in Epigos AI.
yolo_labels_mapdictOptional class ID to label name mapping for YOLO annotations. Used to map numeric YOLO label ID’s to actual class names.
batch_idstringOptional batch ID if batch is already created in Epigos AI. If not provided, batch_name is used to create/retrieve a batch from Epigos AI.
use_folder_as_class_nameboolOptional flag to indicate whether to use parent folder name of image is class label for image classification dataset.

Upload file for image classification

record = project.upload(
  "path/to/image.jpg",
  use_folder_as_class_name=True,
)
print(record)

Upload image with Pascal VOC annotation

record = project.upload(
  "path/to/image.jpg",
  annotation_path="path/to/image.xml",
  box_format="pascal_voc"
)
print(record)

Upload image with YOLO annotation

record = project.upload(
  "path/to/image.jpg",
  annotation_path="path/to/image.txt",
  box_format="yolo"
)
print(record)

upload_dataset()

You can upload an entire dataset folder to the project. This is useful when you have multiple images with annotations in a directory.

ParamTypeDescription
data_dirstringPath to directory containing images and annotations to upload.
batch_namestringName of batch to upload to within project. Defaults to sdk-upload.
box_formatstringFormat of annotation to upload. Options are (pascal_voc, yolo). Defaults to pascal_voc.
labels_mapdictOptional Epigos AI label ID to class name mapping. Useful to skip creating labels if it’s already created in Epigos AI.
yolo_labels_mapdictOptional class ID to label name mapping for YOLO annotations. Used to map numeric YOLO label ID’s to actual class names.
batch_idstringOptional batch ID if batch is already created in Epigos AI. If not provided, batch_name is used to create/retrieve a batch from Epigos AI.
use_folder_as_class_nameboolOptional flag to indicate whether to use parent folder name of image is class label for image classification dataset.
annotation_dir_namestringDirectory name containing annotations. Defaults is labels
config_filestringYOLO dataset configuration file name. Only used when box_format is yolo. Defaults is data.yaml
num_workersintegerNumber of cpu workers to use for uploading. Defaults to 4

Upload image classification directory

records = project.upload_dataset(
  "path/to/folder",
)
print(tuple(records))

Upload Pascal VOC annotation dataset

records = project.upload_dataset(
  "path/to/folder",
  box_format="pascal_voc"
)
print(tuple(records))

Upload YOLO annotation dataset

records = project.upload_dataset(
  "path/to/folder",
  box_format="yolo"
)
print(tuple(records))

Checkout the code on Github