DataGym.ai
Search…
Getting Started
Manage your Projects and data with Python

Description

You can use our Python API Wrapper to easily access and manage your Projects, Datasets, Images and labeled data from your own Python projects or Jupyter Notebooks. This documentation will guide you through the installation process and provides you with some common use cases.
Latest Release: v0.2 on April 6, 2020.
Upgrade your datagym package with pip install --upgrade datagym

Prerequisites

Python Version: Ensure you have one of the following Python versions installed - Python 3.6, 3.7, 3.8
DataGym Account: If you haven't got a DataGym account yet, please Sign Up
Initial Project: Setup your first Project and/or label some images in your Dummy Project
API Token: In order to access your Dummy Project via our Python API you need to create an API Token
After finishing the initial preparations as described above, we have our first Dummy Project and some labeled images to work with in this tutorial. Feel free to mix in some of your own Projects and labeled data if you already used DataGym.

Step 1: Package Installation

The DataGym Python API can easily be installed from the Python Package Index (PyPI) via pip. Therefore, you only have to execute the following command on your machine:
1
[email protected]:~$ pip install datagym
Copied!

Step 2: Create a Client

In order to connect to your Projects you have to import and initialize the API Client from the datagym package. Just put in your API Key into the Client and you're good to go!
1
from datagym import Client
2
3
client = Client(api_key="<YOUR_API_KEY>")
Copied!
The Client object is the gateway to the data from your DataGym account. You can use the Client to get your Projects, Datasets, Images, and labeled data.

Step 3: Fetch your Projects

You can fetch all your Projects including their connected Datasets in a single line.
1
projects = client.get_projects()
Copied!
This may raise an API Exception with the Message: ´Forbidden.´. If you see see this error, please sign into your DataGym account and check if your API Token is valid.
Use-Case: If you want to inspect your Projects you can simply write a little script to print a report.
1
for project in projects:
2
print("\n\n{}".format(70*"="))
3
4
print(f'{"Project:":<15} {project.name}')
5
print(f'{"Description:":<15} {project.short_description}')
6
print(f'{"Datasets:":<15} {len(project.datasets)}')
7
8
for dataset in project.datasets:
9
print("\n{}".format(40*"-"))
10
11
print(f'{"Dataset:":<15} {dataset.name}')
12
print(f'{"Description:":<15} {dataset.short_description}')
13
print(f'{"Images:":<15} {len(dataset.images)}')
Copied!
Your output could look like this:
output:
1
======================================================================
2
Project: Cats
3
Description: Labeling Cats Task
4
Datasets: 1
5
6
----------------------------------------
7
Dataset: Cats from Pixabay
8
Description: Just too many cats
9
Images: 2330
10
11
12
======================================================================
13
Project: Dummy_Project
14
Description: A project that helps to track cars from an arial drone
15
Datasets: 1
16
17
----------------------------------------
18
Dataset: Dummy_Dataset_One
19
Description: None
20
Images: 10
Copied!
That's it, now you are connected to your DataGym account. You can use the Client to easily access your labeled data, Projects, Datasets, and images. Follow the next pages of this documentation to explore the possibilities of DataGym's Python API!
Visit and copy our Jupyter Notebooks to get a comprehensive overview of the functionality.