### TPU/CPU/GPU Strategy Setup (Python) Source: https://documentation.picsellia.com/docs/final-script Configures the distributed training strategy, attempting to connect to a TPU runtime if available, otherwise falling back to a CPU/GPU strategy. ```python ##Harware try: tpu = tf.distribute.cluster_resolver.TPUClusterResolver.connect() print("Device:", tpu.master()) strategy = tf.distribute.TPUStrategy(tpu) except ValueError: print("Not connected to a TPU runtime. Using CPU/GPU strategy") strategy = tf.distribute.MirroredStrategy() ``` -------------------------------- ### Image Preprocessing and Augmentation Setup (Python) Source: https://documentation.picsellia.com/docs/final-script Sets up image data generators for training and testing, including rescaling and augmentation. It also defines an image augmentation pipeline using Keras layers. ```python ##Preprocessing size = (IMG_SIZE, IMG_SIZE) train_img_gen = tf.keras.preprocessing.image.ImageDataGenerator(rescale=1./255, rotation_range=20) test_img_gen = tf.keras.preprocessing.image.ImageDataGenerator(rescale=1./255) ds_train = next(train_img_gen.flow_from_directory('train', target_size=size, batch_size=batch_size, seed=42)) ds_test = next(test_img_gen.flow_from_directory('test', target_size=size, batch_size=batch_size, seed=42)) NUM_CLASSES = len(experiment.get_dataset('train').list_labels()) img_augmentation = Sequential( [ layers.RandomRotation(factor=0.15), layers.RandomTranslation(height_factor=0.1, width_factor=0.1), layers.RandomFlip(), layers.RandomContrast(factor=0.1), ], name="img_augmentation", ) print("Dataloader Instantiated") ``` -------------------------------- ### Setup Feedback Loop for Picsellia Deployment Source: https://documentation.picsellia.com/reference/deployment Sets up the Feedback Loop for a Picsellia Deployment. A Dataset Version can be specified during setup or attached later using attach_dataset_to_feedback_loop(). This feature helps in augmenting the training set with quality data. ```python deployment.setup_feedback_loop(dataset_version) ``` -------------------------------- ### Setup Continuous Deployment Source: https://documentation.picsellia.com/reference/deployment Configures the continuous deployment policy for a deployment. ```APIDOC ## POST /websites/picsellia/setup_continuous_deployment ### Description Set up the continuous deployment for this pipeline. ### Method POST ### Endpoint /websites/picsellia/setup_continuous_deployment ### Parameters #### Request Body - **policy** (string or ContinuousDeploymentPolicy enum) - Required - The policy to use for continuous deployment (e.g., 'DEPLOY_MANUAL'). ### Request Example ```json { "policy": "DEPLOY_MANUAL" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating successful setup. #### Response Example ```json { "message": "Continuous deployment setup complete." } ``` ``` -------------------------------- ### Dockerfile Setup for Picsellia Source: https://documentation.picsellia.com/docs/part-4-make-your-modelversion-trainable This Dockerfile demonstrates how to set up a custom Docker image for Picsellia. It specifies a base CUDA image, installs Python dependencies from a requirements file, and sets the working directory and entrypoint for the training script. Ensure the CUDA version is compatible with your hardware, especially Tesla V100s GPUs. ```dockerfile FROM picsellia/cuda:11.7.1-cudnn8-ubuntu20.04 COPY your-custom-image/requirements.txt . RUN pip install -r requirements. txt # You can also put the picsellia package inside your requirements RUN pip install -r picsellia --upgrade WORKDIR /picsellia COPY your-custom-image/picsellia . ENTRYPOINT ["run", "main.py"] ``` -------------------------------- ### Install Picsellia Python Package Source: https://documentation.picsellia.com/docs/annotation-formats Installs the Picsellia Python package, which is required for importing annotations into the Picsellia platform. This is a prerequisite for using the provided Python code examples. ```bash pip install picsellia ``` -------------------------------- ### Python Training Script Initialization with Picsellia Client Source: https://documentation.picsellia.com/docs/part-4-make-your-modelversion-trainable This Python script snippet shows the initial setup for integrating Picsellia into a training script. It imports necessary libraries, initializes the Picsellia Client with API token, organization name, and host, and retrieves a specific project and experiment. This setup is a prerequisite for sending training logs and monitoring progress via the Picsellia platform. ```python from tensorflow.keras.applications import EfficientNetB0 from tensorflow.keras.models import Sequential from tensorflow.keras import layers from tensorflow import keras import tensorflow as tf import tensorflow_datasets as tfds from picsellia import Client, Experiment from picsellia.types.enums import LogType import os import numpy as np print("Initializing Picsellia Client 🥑") client = Client( api_token="XXXXXXX", organization_name="my_organization", host="https://app.picsellia.com" ) project = client.get_project("documentation_project") experiment = project.get_experiment("exp-0-documentation") datasets = experiment.list_attached_dataset_versions() # The rest of your script ``` -------------------------------- ### Job - start_logging_buffer Source: https://documentation.picsellia.com/reference/job Starts a logging buffer to accumulate log entries before sending them. ```APIDOC ## Job - start_logging_buffer ### Description Start a logging buffer. ### Method POST ### Endpoint /job/{job_id}/log/buffer/start ### Parameters #### Request Body - **length** (int) - Optional - Buffer length. Defaults to 1. ### Request Example ```json { "length": 10 } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example ```json { "message": "Logging buffer started successfully." } ``` ``` -------------------------------- ### Job - start_logging_chapter Source: https://documentation.picsellia.com/reference/job Starts a new logging chapter, allowing for organized log entries. ```APIDOC ## Job - start_logging_chapter ### Description Start a logging chapter. ### Method POST ### Endpoint /job/{job_id}/log/chapter/start ### Parameters #### Request Body - **name** (str) - Required - Chapter name. ### Request Example ```json { "name": "chapter1" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example ```json { "message": "Logging chapter started successfully." } ``` ``` -------------------------------- ### Picsellia Client Initialization and Data Retrieval (Python) Source: https://documentation.picsellia.com/docs/final-script Initializes the Picsellia client, retrieves a project and experiment, and downloads attached dataset versions and their associated assets. It also downloads model weights and training parameters. ```python from tensorflow.keras.applications import EfficientNetB0 from tensorflow.keras.models import Sequential from tensorflow.keras import layers from tensorflow import keras import tensorflow as tf import tensorflow_datasets as tfds from picsellia import Client, Experiment from picsellia.types.enums import LogType import os import numpy as np ##Client initialization print("Initializing Picsellia Client 🥑") client = Client( api_token="XXXXXXX", organization_name="my_organization", host="https://app.picsellia.com" ) ##Retrieve experiment to train project = client.get_project("documentation_project") experiment = project.get_experiment("exp-0-documentation") ##Retreive & download datasets datasets = experiment.list_attached_dataset_versions() print("Downloading Images for datasets ...") for dataset in datasets: for label in dataset.list_labels(): os.makedirs(os.path.join(dataset.version, label.name)) assets = dataset.list_assets(q=f"annotations.classifications.label.name = \"{str(label.name)}\"").download(os.path.join(dataset.name, label.name)) print("Downloading Images for datasets ... ✅") ##Retrieve and download model weights print("Downloading Weights for Model ... ") base_model = experiment.get_base_model_version() base_model_weights = base_model.get_file('weights') base_model_weights.download() print("Downloading Weights for Model ... ✅") ##Retrieve experiment training parameters parameters = experiment.get_log(name='parameters').data IMG_SIZE = parameters['image_size'] batch_size = parameters['batch_size'] ``` -------------------------------- ### POST /setup_feedback_loop Source: https://documentation.picsellia.com/reference/deployment Set up the Feedback Loop for a Deployment. You can optionally attach a Dataset Version during setup or use `attach_dataset_version_to_feedback_loop` afterward. This is useful for augmenting your training set with quality data. ```APIDOC ## POST /setup_feedback_loop ### Description Set up the Feedback Loop for a Deployment. You can specify one Dataset Version to attach to it or use the attach_dataset_to_feedback_loop() afterward, so you can add multiple ones. This is a great option to increase your training set with quality data. ### Method POST ### Endpoint /setup_feedback_loop ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **dataset_version** (DatasetVersion | None) - Optional - The Dataset Version to attach. Note: This parameter is deprecated. Use `attach_dataset_version_to_feedback_loop()` instead. ### Request Example ```python dataset_version = client.get_dataset("my-dataset").get_version("latest") deployment = client.get_deployment( name="awesome-deploy" ) deployment.setup_feedback_loop(dataset_version) ``` ### Response #### Success Response (200) - **message** (str) - Confirmation message indicating the feedback loop setup. #### Response Example ```json { "message": "Feedback loop setup successfully." } ``` ``` -------------------------------- ### HuggingFace Zero-Shot Classifier Example Source: https://documentation.picsellia.com/docs/evaluate-a-classification-model This Python code demonstrates how to use a Zero-Shot classifier (CLIP model) from HuggingFace. It loads a pre-trained model and processor, fetches an image from a URL, and then uses the processor to get similarity scores between the image and provided text labels. ```python from PIL import Image import requests from transformers import CLIPProcessor, CLIPModel model = CLIPModel.from_pretrained("openai/clip-vit-large-patch14") processor = CLIPProcessor.from_pretrained("openai/clip-vit-large-patch14") url = "http://images.cocodataset.org/val2017/000000039769.jpg" image = Image.open(requests.get(url, stream=True).raw) inputs = processor(text=["a photo of a cat", "a photo of a dog"], images=image, return_tensors="pt", padding=True) outputs = model(**inputs) logits_per_image = outputs.logits_per_image # this is the image-text similarity score probs = logits_per_image.softmax(dim=1) # we can take the softmax to get the label probabilities ``` -------------------------------- ### Setup Continuous Training Pipeline (Python) Source: https://documentation.picsellia.com/reference/deployment Initializes and activates continuous training features. A training will be triggered based on the attached dataset versions when the deployment pipeline hits a specified trigger. Supports experiment parameters but not scan configurations at the moment. Requires a Project object and optionally accepts dataset_version, model_version, trigger, threshold, and experiment_parameters. ```python deployment.setup_continuous_training( project, threshold=150, experiment_parameters=experiment_parameters ) ``` -------------------------------- ### Create Campaign for Deployment (Python) Source: https://documentation.picsellia.com/reference/deployment Creates a new campaign for a deployment. Allows setting a description, instructions (from file or text), end date, and flags for automatically adding new assets or closing the campaign upon completion. Returns a ReviewCampaign object. ```python def create_campaign( description: (str|None) = None, instructions_file_path: (str|None) = None, instructions_text: (str|None) = None, end_date: (date|None) = None, auto_add_new_assets: (bool|None) = False, auto_close_on_completion: (bool|None) = False ) ``` Create campaign on a deployment. ```python foo_deployment.create_campaign() ``` ``` -------------------------------- ### Call Picsellia Monitoring Service with Python Source: https://documentation.picsellia.com/docs/predicting-and-monitoring-without-python-sdk This Python snippet demonstrates how to connect to the Picsellia monitoring service. It includes a function to generate a JWToken for authentication and an example of sending prediction data via an HTTP POST request. Ensure you have the 'requests' library installed. The function requires the monitoring service host, deployment ID, and your API token. It outputs prediction results from the monitoring service. ```python import base64 import mimetypes import requests import json def generate_authorization_header(host: str, deployment_id: str, api_token: str): """This method calls our monitoring service to create a jwt and build authorization header. Our jwt are usually available for 1 hour, you might need to recall this method at some point to maintain connection. :param host: of our monitoring service :param deployment_id: deployment identifier that you want to use :param api_token: your picsellia api token :return: a dict representing headers with a JWT of connection to our service. """ # Take care, this auth url is different from prediction service one auth_url = host + "/api/auth/login" auth_headers = { "Authorization": "Token " + api_token, } # json.dumps() serialize a python dictionary to a json string auth_payload = json.dumps({"deployment_id": deployment_id, "api_token": api_token}) # requests.post() makes an HTTP 'POST', on given url, with given headers, and given json payload # calling .json() return the response as a dict, that have the wanted key "jwt" response = requests.post( url=auth_url, headers=auth_headers, data=auth_payload ).json() return { "Authorization": "Bearer " + response["jwt"], } if __name__ == "__main__": # Host of our picsellia prediction service. host = "https://serving.picsellia.com" # Fill these variables with your data deployment_id = "" api_token = "" # Generate authorization headers by calling our prediction service headers = generate_authorization_header(host, deployment_id, api_token) # Url of our service to make a prediction url = host + "/api/deployment/" + deployment_id + "/predictions" # This block is needed in our snippet, because we want to find content type, filename # also we have to encode image to a base64 data : monitoring api only allows this type of encoding at the moment # image_width and image_height are not computed in this snippet but need to be sent to monitoring service # You might already have opened this image, you might want to do it differently image_path = "/path/to/your/image" image_height = 600 image_width = 800 with open(image_path, "rb") as img_file: content_type = mimetypes.guess_type(image_path, strict=False)[0] filename = image_path.split("/")[-1] encoded_image = base64.b64encode(img_file.read()).decode("utf-8") # latency given by your model to predict on this image latency = 0.259 # prediction is a python dictionary representing shapes predicted by your model, # it needs different keys depending on your model. For example for an ObjectDetection model: raw_predictions = { "detection_scores": [ 0.7279638051986694, # first shape's score and should be between 0 and 1 0.7203983664512634, 0.7142382264137268, ], "detection_boxes": [ [57, 213, 118, 256], # first shape's box as [y1, x1, y2, x2] coordinates [186, 165, 246, 248], [80, 73, 169, 199], ], "detection_classes": [ 3, # first shape's class, please make sure your labelmap is well-defined 3, 4, ], } data = json.dumps( { "filename": filename, "content_type": content_type, "height": image_height, "width": image_width, "image": encoded_image, "raw_predictions": raw_predictions, "latency": latency, } ) # requests.post() will send your prediction to our monitoring service response = requests.post(url=url, headers=headers, data=data) monitoring_response = response.json() print(monitoring_response) ``` -------------------------------- ### Start Logging Buffer (Python) Source: https://documentation.picsellia.com/reference/experiment Starts a logging buffer for an experiment. This can be used to group log entries. The buffer length can be specified, defaulting to 1. ```python experiment.start_logging_buffer() ``` -------------------------------- ### Initialize Picsellia Client in Trial Environment (Python) Source: https://documentation.picsellia.com/docs/installation This Python code snippet demonstrates how to initialize the Picsellia client for the trial environment. It requires your organization name, API token, and the trial host URL. ```python # Organization name organization_name = "organization_name" # Define the environement to connect to host = "https://trial.picsellia.com" # Client initialization in the Trial environment client = Client(api_token="YOUR API TOKEN", organization_name=organization_name, host=host) ``` -------------------------------- ### Install MLFlow and Picsellia Dependencies Source: https://documentation.picsellia.com/docs/use-mlflow-with-picsellia Installs necessary Python libraries for MLFlow, Picsellia, PyTorch, and related utilities using pip. This command ensures all required packages are available for the experiment. ```python %pip install -q mlflow databricks-sdk torchmetrics torchinfo picsellia ``` -------------------------------- ### Create Deployment from Model Version Source: https://documentation.picsellia.com/reference/client Creates a deployment from a given model version. This allows for monitoring and potentially a hosted endpoint. It accepts optional parameters for shadow model versions, deployment name, detection thresholds, target datalake, and serving disablement. ```python model_version = client.get_model_version_by_id('918351d2-3e96-4970-bb3b-420f33ded895') deployment = client.create_deployment(model_version=model_version) ``` -------------------------------- ### Get Data Tag Source: https://documentation.picsellia.com/reference/datalake Retrieves a data tag by its name. ```APIDOC ## GET /websites/picsellia/data/tags/{name} ### Description Retrieves a data tag by its name. ### Method GET ### Endpoint /websites/picsellia/data/tags/{name} ### Parameters #### Path Parameters - **name** (str) - Required - Name of the tag to retrieve. ### Response #### Success Response (200) - **Tag** (object) - A Tag object representing the retrieved tag. #### Response Example { "example": "Tag object" } ``` -------------------------------- ### Full Training Script Initialization with Picsellia Data Source: https://documentation.picsellia.com/docs/part-3-retrieve-data-files-and-parameters-from-picsellia This comprehensive Python script integrates Picsellia SDK functionalities to initialize a client, retrieve project and experiment details, download datasets, fetch model weights, and load training parameters. It sets up the necessary data and configurations for a machine learning training process. ```python from tensorflow.keras.applications import EfficientNetB0 from tensorflow.keras.models import Sequential from tensorflow.keras import layers import tensorflow as tf import tensorflow_datasets as tfds from picsellia import Client import os ## Initialization of the Picsellia client client = Client( api_token="XXXXXXX", organization_name="my_organization", host="https://app.picsellia.com" ) ## Retrieve the Picsellia experiment that needs to be trained project = client.get_project("documentation_project") experiment = project.get_experiment("exp-0-documentation") ## Download the datasets from Picsellia and organize the data on the infrastrcture drive datasets = experiment.list_attached_dataset_versions() for dataset in datasets: for label in dataset.list_labels(): os.makedirs(os.path.join(dataset.version, label.name)) assets = dataset.list_assets(q=f"annotations.classifications.label.name = \"{str(label.name)}\"").download(os.path.join(dataset.name, label.name)) ## Get base model of this experiment and download associated files base_model = experiment.get_base_model_version() base_model_weights = base_model.get_file('weights') base_model_weights.download() ## Get experiment parameters that will define the training parameters = experiment.get_log(name='parameters').data IMG_SIZE = parameters['image_size'] batch_size = parameters['batch_size'] ``` -------------------------------- ### Get Processing API Source: https://documentation.picsellia.com/reference/client Retrieves a specific processing by its name. ```APIDOC ## GET /websites/picsellia/processings/{name} ### Description Find a processing in this organization by its unique name. ### Method GET ### Endpoint /websites/picsellia/processings/{name} ### Parameters #### Path Parameters - **name** (str) - Required - The name of the processing to retrieve. ### Request Example ``` GET /websites/picsellia/processings/auto-tagging-dataset ``` ### Response #### Success Response (200) - **processing** (Processing) - The requested Processing object. #### Response Example ```json { "processing": { "id": "string", "name": "string", "creation_date": "string", "last_update": "string" } } ``` ``` -------------------------------- ### Get Model by Name API Source: https://documentation.picsellia.com/reference/client Retrieve a model by its name. ```APIDOC ## GET /models?name={name} ### Description Retrieve a model by its name. ### Method GET ### Endpoint /models?name={name} ### Parameters #### Query Parameters - **name** (str) - Required - The name of the model you are looking for. ### Response #### Success Response (200) - **model** (Model) - The requested Model object. #### Response Example { "id": "uuid-of-model", "name": "foo_model", "created_at": "timestamp" } ``` -------------------------------- ### Client Initialization Source: https://documentation.picsellia.com/reference/client Initialize the Picsellia SDK Client to interact with Picsellia services. Requires an API token. ```APIDOC ## Client Initialization ### Description Initialize the Picsellia SDK Client to communicate with Picsellia services. An API token is required, which can be found in your Profile Settings on the web platform. The client allows you to retrieve and manipulate data objects within the platform. ### Arguments * **api_token** (str, optional): Your API token. Defaults to None, in which case the client will attempt to find it in the environment variable 'PICSELLIA_TOKEN'. * **organization_id** (str or UUID, optional): Specify an organization to connect to by its ID. Defaults to None, connecting to your main organization. * **organization_name** (str, optional): Specify an organization to connect to by its name. If `organization_id` is also provided, `organization_id` will take precedence. Defaults to None, connecting to your main organization. * **host** (str, optional): Define a custom host for the platform. Defaults to 'https://app.picsellia.com'. * **session** (requests.Session, optional): Allows you to provide your own `requests.Session` object for custom headers or proxies. ### Request Example ```python from picsellia import Client client = Client(api_token="a0c9f3bbf7e8bc175494fc44bfc6f89aae3eb9d0") ``` ### Properties * **id** (Organization UUID): The UUID of the organization connected with this client. * **name** (str): The name of the organization connected with this client. ``` -------------------------------- ### Build and Push Docker Image Source: https://documentation.picsellia.com/docs/part-4-make-your-modelversion-trainable These bash commands are used to build a Docker image from a Dockerfile located in the current directory ('.') with a specified Dockerfile path ('your-custom-image/Dockerfile') and tag it with a registry name, image name, and version ('myregistry/my-image:1.0'). After building, the image is pushed to the Docker registry. ```bash docker build . -f your-custom-image/Dockerfile -t myregistry/my-image:1.0 docker push myregistry/my-image:1.0 ``` -------------------------------- ### ModelVersion - Get File Source: https://documentation.picsellia.com/reference/modelversion Retrieves a specific ModelFile by its name from a ModelVersion. ```APIDOC ## GET /modelversions/{id}/files/{filename} ### Description Retrieves a specific ModelFile by its name from a ModelVersion. ### Method GET ### Endpoint /modelversions/{id}/files/{filename} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the ModelVersion. - **filename** (string) - Required - The name of the ModelFile to retrieve. ### Response #### Success Response (200) - **file** (ModelFile) - The requested ModelFile object. #### Response Example ```json { "file": { "name": "model-latest", "content": "...file content..." } } ``` ``` -------------------------------- ### Main Script Initialization with Picsellia Client Source: https://documentation.picsellia.com/docs/part-4-make-your-modelversion-trainable This Python script demonstrates how to initialize the Picsellia client by calling the `get_experiment` function and then listing attached dataset versions. It imports necessary libraries from TensorFlow, Picsellia, and standard Python modules. Ensure `utils.py` containing `get_experiment` is in the same directory or accessible. ```python from tensorflow.keras.applications import EfficientNetB0 from tensorflow.keras.models import Sequential from tensorflow.keras import layers from tensorflow import keras import tensorflow as tf import tensorflow_datasets as tfds from picsellia import Client, Experiment from picsellia.types.enums import LogType import os import numpy as np from utils import get_experiment print("Initializing Picsellia Client 🥑") experiment = get_experiment() datasets = experiment.list_attached_dataset_versions() # The rest of your script # ... ``` -------------------------------- ### ModelVersion - Get Tags Source: https://documentation.picsellia.com/reference/modelversion Retrieves all tags associated with a specific ModelVersion. ```APIDOC ## GET /modelversions/{id}/tags ### Description Retrieves all tags associated with a specific ModelVersion. ### Method GET ### Endpoint /modelversions/{id}/tags ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the ModelVersion. ### Response #### Success Response (200) - **tags** (list[Tag]) - A list of Tag objects associated with the ModelVersion. #### Response Example ```json { "tags": [ {"name": "tag1", "target": "DATA"}, {"name": "tag2", "target": "DATA"} ] } ``` ``` -------------------------------- ### Model - Get Tags Source: https://documentation.picsellia.com/reference/model Retrieves all tags associated with a specific model. ```APIDOC ## Model - Get Tags ### Description Retrieve the tags of your model. ### Method GET ### Endpoint /websites/picsellia/models/{model_id}/tags ### Parameters #### Path Parameters - **model_id** (string) - Required - The ID of the model whose tags are to be retrieved. ### Response #### Success Response (200) - **tags** (list[Tag]) - A list of Tag objects associated with the model. #### Response Example ```json [ { "id": "tag-abc", "name": "my-model-tag", "target": "MODEL" } ] ``` ``` -------------------------------- ### Initialize Picsellia Client Source: https://documentation.picsellia.com/reference/client Initializes the Picsellia SDK Client with an API token. The token can be provided directly or will be read from the environment variable 'PICSELLIA_TOKEN'. Optional arguments allow specifying organization details and a custom host. ```python client = Client(api_token="a0c9f3bbf7e8bc175494fc44bfc6f89aae3eb9d0") ``` -------------------------------- ### Start Fast Training Source: https://documentation.picsellia.com/reference/datasetversion Initiates a fast training process using the current dataset as input data. An optional description can be provided. ```APIDOC ## POST /websites/picsellia/start_fast_training ### Description This method will start a fast training with this dataset as input data. ### Method POST ### Endpoint /websites/picsellia/start_fast_training ### Parameters #### Query Parameters - **description** (str) - Optional - A description for the fast training job. ### Response #### Success Response (200) - **fast_training** (FastTraining) - A FastTraining object representing the initiated training. ``` -------------------------------- ### Model Context - Get Experiment Source: https://documentation.picsellia.com/reference/modelcontext Retrieve the source experiment associated with this model context. ```APIDOC ## GET /websites/picsellia/modelcontext/experiment ### Description Retrieve the source experiment of this context. It will raise an exception if this context has no experiment source. ### Method GET ### Endpoint /websites/picsellia/modelcontext/experiment ### Parameters #### Query Parameters None ### Request Example None ### Response #### Success Response (200) - **experiment** (Object) - An Experiment object. #### Response Example { "id": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "name": "My Experiment" } ``` -------------------------------- ### Create Model Source: https://documentation.picsellia.com/reference/client Creates a new model within the organization. Requires a name and optionally accepts a description. ```python model = client.create_model(name="foo_model", description="A brand new model!") ``` -------------------------------- ### Initialize Picsellia Client and Get Project/Experiment (Python) Source: https://documentation.picsellia.com/docs/part-2-initializing-picsellia-connection-retrieve-the-experiment This Python code snippet demonstrates how to initialize the Picsellia client using your API token, organization name, and host. It then retrieves a specific project and experiment by their names, preparing them for further use in your script. Ensure you replace placeholder values with your actual credentials. ```python from picsellia import Client client = Client( api_token="XXXXXXX", organization_name="XXXX", host="https://app.picsellia.com" ) project = client.get_project("documentation-project") experiment = project.get_experiment("exp-0-documentation") ``` -------------------------------- ### Get Model by ID Source: https://documentation.picsellia.com/reference Retrieve a specific model using its unique identifier. ```APIDOC ## GET /models/{id} ### Description Retrieve a model by its id. ### Method GET ### Endpoint /models/{id} ### Parameters #### Path Parameters - **id** (str or UUID) - Required - The unique identifier of the model to retrieve. ### Response #### Success Response (200) - **model** (Model) - The requested Model object. ### Response Example ```json { "id": "d8fae655-5c34-4a0a-a59a-e49c89f20998", "name": "My Model", "description": "A model for object detection" } ``` ``` -------------------------------- ### Initialize Picsellia SDK Client Source: https://documentation.picsellia.com/reference Instantiate the Picsellia SDK Client to interact with Picsellia services. Requires an API token, which can also be set via an environment variable. Optional arguments allow specifying organization and custom host. ```python client = Client(api_token="a0c9f3bbf7e8bc175494fc44сная3eb9d0") ``` -------------------------------- ### Upload Instructions File for Campaign - Python Source: https://documentation.picsellia.com/reference/annotationcampaign Uploads an instructions file for an annotation campaign. The provided path should point to the local file to be uploaded. ```python foo_campaign.upload_instructions_file("/path/to/file.pdf") ``` -------------------------------- ### Get Asset Tag Source: https://documentation.picsellia.com/reference/datasetversion Retrieves an asset tag used in this dataset version by its name. ```APIDOC ## GET /websites/picsellia/get_asset_tag ### Description Retrieve an asset tag used in this dataset version by its name. ### Method GET ### Endpoint /websites/picsellia/get_asset_tag ### Parameters #### Query Parameters - **name** (str) - Required - Name of the tag you're looking for ### Response #### Success Response (200) - **Tag** - The Tag object. #### Response Example ```json { "id": "tag_id_3", "name": "dog" } ``` ``` -------------------------------- ### Get Job By ID Source: https://documentation.picsellia.com/reference/client Retrieves a specific Job object using its unique ID. ```APIDOC ## Get Job By ID ### Description Get a [Job](job) from its id. ### Method GET ### Endpoint /jobs/{id} ### Parameters #### Path Parameters - **id** (UUID|str) - Required - The unique identifier of the job. ### Request Example ```python job = client.get_job_by_id( id="YOUR JOB ID" ) ``` ### Response #### Success Response (200) - **job** (Job) - The Job object corresponding to the provided ID. #### Response Example ```json { "id": "job_id_123", "name": "Example Job", "status": "COMPLETED", "created_at": "2023-10-27T10:00:00Z" } ``` ``` -------------------------------- ### Get Model by ID API Source: https://documentation.picsellia.com/reference/client Retrieve a specific model using its unique identifier. ```APIDOC ## GET /models/{id} ### Description Retrieve a model by its id. ### Method GET ### Endpoint /models/{id} ### Parameters #### Path Parameters - **id** (str or UUID) - Required - The ID of the model to retrieve. ### Response #### Success Response (200) - **model** (Model) - The requested Model object. #### Response Example { "id": "d8fae655-5c34-4a0a-a59a-e49c89f20998", "name": "my_model", "created_at": "timestamp" } ``` -------------------------------- ### Start Fast Training in Python Source: https://documentation.picsellia.com/reference/datasetversion Initiates a fast training process using the current dataset as input. An optional description can be provided for the training job. ```Python start_fast_training( description: (str|None) = None ) ``` -------------------------------- ### Create Deployment Tag Source: https://documentation.picsellia.com/reference/client Creates a tag that can be applied to Deployment objects. The tag is identified by its name. ```python tag = client.create_deployment_tag("operation") ``` -------------------------------- ### Get or Create Data Tag Source: https://documentation.picsellia.com/reference/datalake Retrieves a data tag by its name. If the tag does not exist, it is created. ```APIDOC ## POST /websites/picsellia/data/tags/get_or_create ### Description Retrieves a data tag by its name. If the tag does not exist, it is created. ### Method POST ### Endpoint /websites/picsellia/data/tags/get_or_create ### Parameters #### Request Body - **name** (str) - Required - Name of the tag to retrieve or create. ### Request Example ```json { "name": "new_tag" } ``` ### Response #### Success Response (200) - **Tag** (object) - A Tag object representing the retrieved or newly created tag. #### Response Example { "example": "Tag object" } ``` -------------------------------- ### ModelVersion - Get Context Source: https://documentation.picsellia.com/reference/modelversion Retrieves the ModelContext associated with a ModelVersion, which can be used to access further information and functionalities. ```APIDOC ## GET /modelversions/{id}/context ### Description Retrieves the ModelContext associated with a ModelVersion, which can be used to access further information and functionalities. ### Method GET ### Endpoint /modelversions/{id}/context ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the ModelVersion. ### Response #### Success Response (200) - **context** (ModelContext) - The ModelContext object associated with the ModelVersion. #### Response Example ```json { "context": { "info": "Model context information" } } ``` ``` -------------------------------- ### Create Deployment using Picsellia API Source: https://documentation.picsellia.com/reference Creates a Deployment from a specified ModelVersion. This enables monitoring and potentially a hosted endpoint. Optional parameters include shadow model version, name, minimum threshold, target datalake, and serving disablement. ```Python def create_deployment( model_version: ModelVersion, shadow_model_version: (ModelVersion|None) = None, name: (str|None) = None, min_threshold: (float|None) = None, target_datalake: (Datalake|None) = None, disable_serving: (bool|None) = False ): """Create a Deployment from a model. This method allows you to create a Deployment on Picsellia. You will then have access to the monitoring dashboard and eventually a hosted endpoint. """ pass # Example: model_version = client.get_model_version_by_id('918351d2-3e96-4970-bb3b-420f33ded895') deployment = client.create_deployment(model_version=model_version) ``` -------------------------------- ### Set Training Data for Deployment (Python) Source: https://documentation.picsellia.com/reference/deployment Sets the training data reference for a deployment, enabling metric computation based on training data distribution in the Monitoring service. Requires a DatasetVersion object. ```python deployment.set_training_data(dataset_version) ``` -------------------------------- ### Model - Get Version Source: https://documentation.picsellia.com/reference/model Retrieves a specific version of a model using its version number or name. ```APIDOC ## Model - Get Version ### Description Retrieve a version of a model from its version or its name. ### Method GET ### Endpoint /websites/picsellia/models/{model_id}/versions/{version_identifier} ### Parameters #### Path Parameters - **model_id** (string) - Required - The ID of the model. - **version_identifier** (integer | string) - Required - The version number or name of the model version to retrieve. ### Response #### Success Response (200) - **id** (string) - The ID of the model version. - **version** (integer) - The version number. - **name** (string) - The name of the model version. - **framework** (string) - The framework used for this version. - **type** (string) - The inference type for this version. - **description** (string) - The description of the model version. #### Response Example ```json { "id": "version-xyz", "version": 0, "name": "first-version", "framework": "TENSORFLOW", "type": "OBJECT_DETECTION", "description": "Initial version of the model." } ``` -------------------------------- ### Initialize Picsellia Client and Fetch Project Data Source: https://documentation.picsellia.com/docs/evaluate-a-detection-model-copy This script initializes the Picsellia client connection and retrieves project, experiment, and dataset information. It requires API token, organization name, and project/experiment/dataset names as parameters. ```python from picsellia import Client client = Client(api_token, organization_name, host='https://app.picsellia.com') project = client.get_project(name='Documentation Project') experiment = project.get_experiment(name='my_experiment') testing_dataset = experiment.get_dataset('test') ``` -------------------------------- ### Get Processing Information Source: https://documentation.picsellia.com/reference Retrieves details about a specific processing job within the organization by its name. ```APIDOC ## GET /websites/picsellia/processing ### Description Find a processing in this organization by its name. ### Method GET ### Endpoint /websites/picsellia/processing ### Parameters #### Query Parameters - **name** (str) - Required - The name of the processing job to find. ### Request Example ``` GET /websites/picsellia/processing?name=auto-tagging-dataset ``` ### Response #### Success Response (200) - **Processing** (object) - A Processing object containing details of the found processing job. #### Response Example ```json { "id": "60d5ec49a1b2c3d4e5f6a7b8", "name": "auto-tagging-dataset", "status": "completed", "createdAt": "2023-10-27T10:00:00Z" } ``` ``` -------------------------------- ### Experiment Launch and Artifacts Source: https://documentation.picsellia.com/reference/experiment Launch experiments on remote environments and download their artifacts. ```APIDOC ## POST /experiments/{experiment_id}/launch ### Description Launch a job on a remote environment with this experiment. The remote environment must be set up prior to launching. ### Method POST ### Endpoint /experiments/{experiment_id}/launch ### Parameters #### Request Body - **gpus** (integer, optional) - Number of GPUs to use for the training. Defaults to 1. ### Request Example ```json { "gpus": 2 } ``` ### Response #### Success Response (200) - **job_id** (string) - The ID of the launched job. #### Response Example ```json { "job_id": "job_789" } ``` ## GET /experiments/{experiment_id}/artifacts ### Description Download all artifacts from the experiment to the local directory. ### Method GET ### Endpoint /experiments/{experiment_id}/artifacts ### Parameters #### Query Parameters - **with_tree** (boolean, optional) - If true, the artifacts will be downloaded in a tree structure. ### Response #### Success Response (200) - **download_url** (string) - A URL to download the artifacts. #### Response Example ```json { "download_url": "https://example.com/artifacts.zip" } ``` ``` -------------------------------- ### List Deployment Tags Source: https://documentation.picsellia.com/reference/client Lists all available Deployment tags. These tags are applicable only to Deployment objects. ```APIDOC ## List Deployment Tags ### Description List all Deployment tags, usable only on Deployment Version objects. ### Method GET ### Endpoint /deployments/tags ### Parameters #### Query Parameters None ### Request Example ```python tags = client.list_deployment_tags() ``` ### Response #### Success Response (200) - **tags** (list[Tag]) - A list of Tag objects. #### Response Example ```json [ { "id": "tag_id_1", "name": "tag_name_1", "color": "#FF0000" }, { "id": "tag_id_2", "name": "tag_name_2", "color": "#00FF00" } ] ``` ```