Python SDK Reference
Here we will describe every method of the picsellia package
Installation
The first thing you need to do is to download our python package from PyPI, you can install it with pip
Dependencies
Here is the several packages that will be installed along the picsellia package, they are used to perform mathematical operations, array or image manipulations and HTTP requests
numpy>=1.18.5
Pillow>=7.2.0
requests>=2.24.0
scipy>=1.4.1
Client
To connect your code to Picsell.ia, you must initialize our client.
You will be greeted by this nice message (Pierre-Nicolas is my name, you should see your username here, unless you are named Pierre-Nicolas too 👀 ) :
Datalake
You need to instantiate a Datalake object in order to interact with your pictures or datasets.
__init__
If you need to interact with your datalake, you must initialize the Datalake
class.
It is a subclass of the Client.
Arguments:
api_token
(string) Your personal API token (Find it in your profile page 🔥)organization
(string, optional) the name of the organization you want to work with (None default to your organization)
Returns:
None
upload
This upload method allows you to upload your Dataset, (images and annotations or annotations only).
Arguments
name
(string, required) Name of the dataset to be created or fetched if you want to upload only annotationsversion
(string, optionnal) Version of the dataset to be fetched, if None we will fetch the latest created with this name.imgdir
(string, optionnal) Path to the directory of the pictures to upload, leave blank if you just want to upload the annotations.ann_path
(string, required) Path to the annotations files, it can be a directory or a file.ann_format
(string, required) you can upload COCO format, PASCAL-VOC or PICSELLIAtags
(list, optionnal) List of tags to add to the uploaded images, if None tags will be theupload date
.nb_jobs
(int, optionnal) Number of process to use to upload, put nb_jobs=-1 if you want to use all available processes.rectangle
(bool, optionnal) set to True if you want to force to upload bbox annotations when both polygons and bbox are available in your annotation files.
Picture
The picture object allow you to interact with your assets only.
__init__
If you need to interact with your experiments, you must initialize the Picture
class.
It is a subclass of the Datalake
.
Arguments:
api_token
(string) Your personal API token (Find it in your profile page 🔥)organization
(string, optional) the name of the organization you want to work with (None default to your organization)
upload
To upload assets to your lake
Arguments:
filtepath
(string or list) Either onefilepath
pointing to the asset to upload or a list of path.tags
(list, optional) the list of tags to attach to the upload assetssource
(string, optional) Specify the source of the upload, default is "sdk"
list
Returns:
A list containing the pictures objects for your datalake.
fetch
Fetch images with corresponding tags
Parameters:
quantity
(float, optional) the percentage of assets to fetch ( 1 meaning 100%)tags
(list, required) a list of tags used to search in yourDatalake
Returns:
The list of all the fetched assets
status
Once, you have fetched pictures, you can call status method to visualize the number of assets fetched
Return:
delete
Delete the list of pictures
Arguments:
pictures
(list, optional) The list of pictures to delete from your lake, ifnone
will delete the latest fetched pictures.
Returns:
None
add_tags
Add tags to selected pictures
Arguments:
pictures
(list, optional) The list of pictures to selected from your lake, ifnone
will add tags to the last fetched pictures.tags
(list, required) The list of tags to add to the selected pictures
Returns:
None
remove_tags
Remove tags from selected pictures
Arguments:
pictures
(list, optional) The list of pictures to selected from your lake, ifnone
will remove tags from the last fetched pictures.tags
(list, required) The list of tags to delete from the selected pictures
Returns:
None
Dataset
The dataset object allow you to interact with your dataset ( annotations, labels, question and answers ).
__init__
If you need to interact with your experiments, you must initialize the Dataset
class.
It is a subclass of the Datalake
.
Arguments:
api_token
(string) Your personal API token (Find it in your profile page 🔥)organization
(string, optional) the name of the organization you want to work with (None default to your organization)
list
Returns:
A list containing the dataset objects for your account.
fetch
Fetch dataset with its name and version
Parameters:
name
(string, optional) the name of the dataset to fetchversion
(string, optional) the version of the dataset to fetch, if None, the client will fetch latest
Returns:
A Dataset
object relative to the fetched dataset
create
Create a a new dataset and attach pictures to it, to do so you first need to fetch pictures
Parameters:
name
(string, optional) the name ot the dataset to createdescription
(string, optional) the description of the dataset to createprivate
(bool, optional) If True, your dataset will be accessible to anyonepictures
(list, required) The list of pictures to attach to yourdataset
Return:
the id of the created dataset
new_version
Create a a new dataset and attach pictures to it, to do so you first need to fetch pictures
Parameters:
name
(string, optional) the name of the datasetversion
(string, optional) the version name of the dataset to createfrom_version
(string, optional)The origin version for your new version, if None we'll create a new version from the latest versionpictures
(list, required) The list of pictures to attach to your version
Return:
None
create_labels
Sets up the labels (tools for drawing bounding-boxes, polygons...) for your dataset.
Arguments:
name (str, required) name of the label want to set up (e.g. car, bird, plane...)
ann_type (str, required) type of shape that will be used for annotations :
'rectangle': bounding-boxes for object-detection
'polygon': polygons for segmentation
Returns:
None
list_pictures
Get the list of all the images in the fetched dataset
Arguments:
dataset_id (str, optional) id of the dataset (if not fetched)
Returns:
list of Picture
objects
add_data
Add the fetch pictures to a dataset
If you fetched a dataset before, you won't have to specify the name and version of the dataset
Parameters:
name
(string, optional) the name of the datasetversion
(string, optional) the version name of the dataset to fetch if None, we'll takelatest
pictures
(list, required) The list of pictures to attach to add
Return:
None
delete
Delete the a dataset
Arguments:
name
(string, optional) the name of the dataset to deleteversion
(string, optional) the version name of the dataset to delete if None, we'll takelatest
Returns:
None
download
Download all the images from a dataset in a folder
Arguments:
dataset
(str, required) the name of the dataset you want to download written <dataset_name>/<version>folder_name
(str, optional) the name of the folder you want to download the pictures in, defaults to dataset_name/version if None
Returns:
None
add_annotation
Create an annotation for a picture in a dataset (or add objects to existing annotation)
Arguments:
picture_external_url (str, required) the name of the target image
dataset_id (str, optional) leave None if you already fetched a dataset
data (dict, required) annotation data
image_qa (dict, optional) Q&A data for image
Formats:
classification
detection
segmentation
Q&A
Network
Networks are trained architectures that you can either deploy for inference (if available), use to start new experiments and share within your Organization's models.
The Network object
Attributes
model_id
(string) Unique identifier of your modelowner
(hash, user_object) The creator of the modelnetwork_name
(string) The name of your modeldescription
(string) A short description of what your model doestype
(string) The type of application for your model, if you want to perform pre-annotation on Picsellia it has to be one of the following (but you can set your own type otherwise):'detection'
'segmentation'
'classification'
organization
(hash, organization object) The organization under which your model is storedprivate
(boolean) Tells if your model is available for everyone in the public HUB or notframework
(string) The framework used for training'tensorflow1'
'tensorflow2'
'pytorch'
tag
(list) List of tags to identify and sort your modelsfiles
(dict) Dictionary containing the list of files of your modellabels
(dict) Dictionary of the labelmap of your modelbase_parameters
(dict) Dictionary of the base parameters allowing anyone to reproduce the training or iterate with already existing parametersreadme_text
(str) A markdown text containing more information about your model
__init__
If you want to interact with your models, you have to initialize the Network
class.
It is a subclass of the Client
.
Arguments:
api_token
(string) Your personal API tokenorganization
(string, optional) the name of the organization you want to work with (None default to your organization)
list
List of all the models for an organization
By default it will list the models of your own organization but you can specify the name of another organization where you are part of the team.
Returns:
A list containing the models of the chosen organization.
get
This method allows you to retrieve a particular model in order to update it or store some files.
Arguments:
identifier
(string) Either the name or the id of the model you want to retrieve
Returns:
The Network object
create
This methods allows you to create a new Network from the SDK
Attributes:
name (str, required) The name of your Network
type (str, required) the type of your Network, it is the task it performs such as :
'detection', for object detection
'segmentation', for object segmentation
'classification', for image classification
Returns:
Network object
update
This methods allows you to update the properties of a Network from your Organization
You must get or create a network before calling the update method.
Arguments:
**kwargs (required) can be any property from the Network object described in the Network Object.
For example, if you want to update the description of your Network, you code will look like this :
You can update as many properties as you want in one single time.
store
This method allows you to upload a file and save it under your model so you can use it later such as checkpoint files or config files.
Arguments:
name
(string,) the name of the file, please check this page to know about the Picsellia namespacepath
(string, optional) the path to the file you want to uploadzip
(boolean, optional) set to True if you want to zip your file or a folder to an archive before upload
update_thumb
This method allows you to set the image of your choice as the thumbnail displayed on the platform like below.
Arguments:
path
(string) the path to the image file
labels
This methods allows you to set the labelmap of your model.
Arguments:
labels (dict) Dictionary containing your labelmap (index starts at 1 not 0)
Here is the COCO labelmap as example :
Returns:
None
Projects
The Project object
Attributes:
organization
(hash) The parent organization of the projectproject_name
(string) The name of the projectdescription
(string) A brief description of the projectproject_id
(UUID) The unique ID of the projectproject_manager
(hash) The user that created the projectcontributors
(hash) The list of worker objects for contributors of this projectdatasets
(hash) Short dataset objects for datasets attached to the projecttype
(string) Type of the project, you can set it arbitrarilycreation_date
(string) Date of creation of this project
__init__
If you want to interact with your projects, you must initialize the Project class for our client.
Arguments:
api_token
(string) Your personal API Tokenhost
(string) The URL of Picsellia platform, you shouldn't have to change itproject_token
(string) The token of the project you want work with (you can also let None and use get() or create() methods later)
Returns:
None
list
This method allows you to list every project in your organization.
The project list is also stored in the project_list
attribute in the Project object you instantiated so you can access it as shown below 👇
get
This method allows you to retrieve a project so you can perform actions on it later.
Arguments:
name (string) The name of project you want to retrieve
organization (string) The name of the organization the project belongs to, leave "null" to stay in your organization
Returns:
self (The project object)
create
This method allows you to create a new project.
You can't have 2 projects with the same name in your organization, you will have an error if the project already exists.
Arguments:
name
(string, required) The name of the project you want to createorganization
(string, optional) The organization where you want to create the project, leave "null" if you want it to be your organization**kwargs
, can be any attribute of the Project object within the following list :description (string)
type (string)
Returns:
self (the Project
object)
Example:
Here we will create a new project and specify the type in the **kwargs argument
As we can see, it did create a new project called 'new_project' and set the type to 'detection', easy no ?
update
This methods allows you to update some properties of your project
Before calling the update() method, you must have retrieved a project using get() or create() methods.
Arguments:
project_name
(string, optional) the new name wanted for the projectdescription
(string, optional) The description of the projecttype
(string, optional) The type of the project
Returns:
self (the Project
object)
As we can see, we have successfully updated the name and the description of our project !
delete
This method allows you to delete a project.
Before calling the delete() method, you must have retrieved a project using get() or create() methods.
Returns:
None
attach_dataset
This method allows you to attach a dataset from your organization to your project, just like you would do in the platform.
Before calling the attach_dataset() method, you must have retrieved a project using get() or create() methods.
Arguments:
dataset
(string, required) The dataset name and version separated by as '/' : <dataset_name>/<version>
Returns:
None
Experiments
The experiment object
Attributes:
id
(string) Unique identifier for the objectowner
(hash, user object) The creator of the objectname
(string) The name of the experimentdescription
(string) A short description of the experimentstatus
(string) Describes the experiment statedate_created
(date) Date and time at which the object was createdlast_update
(date) Date and time of the last update of the objectlogging
(hash, logging object) The telemetry of the experimentfiles
(list, file-asset object) The files stored for this experimentdata
(list, data-asset object) The data saved for this experiment
__init__
If you need to interact with your experiments, you must initialize the Experiment
class.
It is a subclass of the Client.
It is also used to initialize some class parameters such as project_token
, id
(experiment id) or name
(experiment name), so you don't have to specify them when you call a method of the Experiment class.
If you initialize the Experiment class with the id or name of an experiment or the project token of the project that your experiments belongs, you don't have to fill them when calling any method, they are now attributes of the class instance !
Please note that when calling an Experiment method, you can either specify the id or the name of the experiment, you don't have to enter both.
Arguments:
api_token
(string) Your personal API tokenhost
(string, optional) the URL of Picsell.ia platform, you shouldn't have to change itproject_token
(string, optional) the token of the project you want to focus onid
(string, optional) the id of the experiment you want to work withname
(string, optional) the name of the experiment you want to work withinteractive
(boolean, optional) if set to False, disable all prompt that requires user action
Returns:
None
checkout
This methods allows you to retrieve all the information and assets of an experiment. For more explanation on how this method works, please have a look at this page.
Arguments
id
(string, optional) the id of the experiment you want to work withname
(string, optional) the name of the experiment you want to work withproject_token
(string, optional) the token of the project you want to focus ontree
(boolean, optional) set to True if you want to create training-ready folders (see the training reference)with_files
(boolean, optional), set toTrue
if you want to download all the files of your experimentwith_data
(boolean, optional), set toTrue
if you want to retrieve all data assets from your experiment
Returns:
JSON-like object
list
List all of the experiments related to one project
This method needs to know your project token, you can either fill it when initializing the Experiment
class or you can fill it when calling the method
Arguments:
project_token (string, optional) the the token of the project you want to focus
Returns:
A list containing the experiment objects for your project.
create
Creates a new experiment for a project
The id
parameter is used to iterate from a previous experiment, if you need more details, please look here for an explanation.
Parameters:
name
(string, 60 char max.) the name of your new experimentdescription
(string, 1000 char max., optional) a short description for your experimentprevious
(string, optional) set it to a previous experiment name if you want to iteratedataset
(string, optional) set it to <dataset_name
>/<version
> of the dataset you want to use for your experimentsource
(string, optional) set it to <username
>/<model_name
> to clone the assets of a model from our model HUB or your organization
Returns:
An experiment object with your created experiment
update
From here, in order to run all the following methods, you mst have checkout or created an experiment first.
This methods allows you to update the information of an experiment
Arguments:
**kwargs
name
(string) the new name for your experimentdescription
(string) the new descriptionstatus
(string) the new status
Returns:
The updated experiment object
delete
This method allows you to delete one experiment
Returns:
True if the experiment has been deleted correctly
delete_all
Delete all the experiments for a given project
Arguments:
project_token
(uuid, optional) the project token of the project you want to delete all experiments
Returns:
True if the experiments has been deleted correctly
dl_annotations
Download the annotations JSON for the dataset attached to an experiment
Arguments:
type
(string, required)'all' (default) download all annotations of the dataset
'accepted' download only accepted annotations from the dataset
Returns:
JSON containing all of the annotations in the COCO format, the JSON is also stored in experiment.dict_annotations
File-assets
The file-asset object
Attributes
id
(int) Unique identifier for the objectname
(string) The name of the file-assetobject_name
(string) The path to the file in our object storagedate_created
(date) Date and time at which the object was createdlast_update
(date) Date and time of the last update of the object
store
Create a file-asset for your experiment and upload the file on our object storage. Please check this page if you need more details about what it does in the background and how to use it properly.
Arguments:
name
(string,) the name of the file, it will be displayed on Picsell.iapath
(string, optional) the path to the file you want to uploadzip
(boolean, optional) set to True if you want to zip your file or a folder to an archive before upload
list_files
List all the files belonging to one experiment
Returns:
A list of all the file asset object of your experiment
delete_all_files
Delete all the files belonging to one experiment
Returns:
True if all the files has been deleted correctly
get_file
Retrieve one particular file of an experiment by its name
Arguments:
name
(string) the name of the file asset you want to retrieve
Returns:
A file-asset object
delete_file
Delete a file from your experiment
Arguments:
name
(string) the name of the file asset you want to delete
Returns:
True if the file has been deleted correctly
update_file
Update the information of a given file
Arguments:
file_name
(string) the name of the file asset you want to update**kwargs
name
(string) the new name for your file
Returns:
A file-asset containing the updated object
Data-assets
The data-asset object
Attributes
id
(int) Unique identifier for the objectname
(string) The name of the data-assetdata
(hash, data object) The data logged in this objectdate_created
(date) Date and time at which the object was createdlast_update
(date) Date and time of the last update of the object
log
Log your results to Picsell.ia, check this page for more details on how to use it and what you can do with logs.
Arguments:
name
(string) the name of the data-asset you want to createdata
(dict) a dictionary containing the data you want to display on the platformtype
(string, optional) the type of asset you are logging, see all the types available here
list_data
List all the data-assets belonging to one experiment
Returns:
A list of all the data-assets object of your experiment
delete_all_data
Delete all the files belonging to one experiment
Returns:
True if all the data-assets has been deleted correctly
get_data
Retrieve one particular file of an experiment by its name
Arguments:
name
(string) the name of the data-asset you want to retrieve
Returns:
A data-asset object
You will only return what is stored in the data field of the data asset, not all the information about the asset.
delete_data
Delete a file from your experiment
name
(string) the name of the data-asset you want to delete
Returns:
True if the data-asset has been deleted correctly
update_data
Update the information of a given file
Arguments:
data_name
(string) the name of the data-asset you want to update**kwargs
name
(string) the new name for your data-assetdata
(dict) the updated data for your asset, please refer to this page for details on the data objects
Returns:
A data-asset containing the updated object
Logging (coming soon)
Logging is the telemetry (if existing) of your experiment. It allows you to record in real time what's happening in the interpreter during an experiment and to monitor it from the platform.
The logging object
Attributes
logs
(dict) The raw stdout of your interpretersteps
(dict) The categories of your logs, useful to navigate inside your logstimestamps
(dict) The timestamps for each stepexit_code
(dict) The exit code and the timestamp of the end of your run
Last updated
Was this helpful?