Package: irisml
IrisMLProof of Concept for a simple framework to create a ML pipeline.FeaturesRun a ML training/inference with a simple JSON configuration.Modularized interfaces for task components.Cache task outputs for faster experiments.Getting startedInstallationPrerequisite: python 3.8+# Install the core framework and standard tasks.
pip install irisml irisml-tasks irisml-tasks-trainingRun an example job# Install additional packages that are required for the example
pip install irisml-tasks-torchvision

# Run on local machine
irisml_run docs/examples/mobilenetv2_mnist_training.jsonAvailable commands# Run the specified pipeline. You can provide environment variables by "-e" option, which will be acceible through $env variable in the json config.
irisml_run <pipeline_json_path> [-e <ENV_NAME>=<env_value>] [--no_cache] [--no_cache_read] [-v]

# Show information about the specified task. If <task_name> is not provided, shows a list of available tasks in the current environment.
irisml_show [<task_name>]

# Manage a cache storage on Azure Blob Storage
# list - Show a list of matched blobs.
# download - Download matched blobs.
# remove - Remove matched blobs.
# show - Show the contents of matched blobs.
irisml_cache <list|download|remove|show> [--mtime <+|->N] [--name NAME]Pipeline definitionPipelineDefinition = {"tasks": List[TaskDefinition], "on_error": Optional[List[TaskDescription]]}

TaskDefinition = {
    "task": <task module name>,
    "name": <optional unique name of the task>,
    "inputs": <list of input objects>,
    "config": <config for the task. Use irisml_show command to find the available configurations.>
}In the TaskDefinition.inputs and TaskDefinition.config, you cna use the following two variable.$env.<variable_name>
This variable will be replaced by the environment variable that was provided as arguments for irisml_run command.$outputs.<task_name>.<field_name>
This variable will be replaced by the outputs of the specified previous task.It raises an exception on runtime if the specified variable was not found.If a task raised an exception, the tasks specified in on_error field will be executed. The exception object will be assigned to "$env.IRISML_EXCEPTION" variable.Pipeline cacheUsing cache, you can modify and re-run a pipeline config with minimum cost. If the cache is enabled, IrisML will calculate hash values for all task inputs/configs and upload the task outputs to a specified storage. When it found a task with same hash values, it can download the cache and skip the task execution.To enable cache, you must specify the cache storage location by setting IRISML_CACHE_URL environment variable. Currently Azure Blob Storage and local filesystem is supported.To use Azure Blob Storage, a container URL must be provided. It the URL contains a SAS token, it will be used for authentication. Otherwise, interactive authentication and Managed Identity authentication will be used.Python APITo run a pipeline from python code, you can use the following APIs.importjsonimportpathlibfromirisml.coreimportJobRunnerjob_description=json.loads(pathlib.Path('example.json').read_text())runner=JobRunner(job_description)runner.run({'DATASET_NAME':'mnist'})runner.run({'DATASET_NAME':'cifar10'})Available official tasksTo show the detailed help for each task, run the following command after installing the package.irisml_show <task_name>irisml-tasksTaskDescriptionassertionAssert the given input.assign_class_to_stringsAssigns a class to a string based on the class name being present in the string.branch'If' conditional branch.calculate_cosine_similarityCalculate cosine similarity between two sets of vectors.check_model_parametersCheck Inf/NaN values in model parameters.compareCompare two valuesdeserialize_tensorDeserialize a pytorch tensor.divide_floatFloating point division.download_azure_blobDownload a single blob from Azure Blob Storage.extract_image_bytes_from_datasetExtract images from a dataset and convert them to bytes.get_current_timeGet the current time in seconds since the epochget_dataset_splitGet a train/val split of a dataset.get_dataset_statsGet statistics of a dataset.get_dataset_subsetGet a subset of a dataset.get_fake_image_classification_datasetGenerate a fake image classification dataset.get_fake_object_detection_datasetGenerate a fake object detection dataset.get_int_from_json_stringsGet an integer from a JSON string.get_itemGet an item from the given list.get_kfold_cross_validation_datasetGet train/test dataset for k-fold cross validation.get_secret_from_azure_keyvaultGet a secret from Azure KeyVault.get_topkGet the largest Topk values and indices.join_filepathJoin a given dir_path and a filename.load_state_dictLoad a state_dict from various sources.make_cached_datasetSave dataset cache on disk.make_prompt_for_each_stringMake a prompt for each string.make_prompt_with_stringsMake a prompt with a list of strings.pickling_objectPickling an object.printPrint or Pretty Print the input object.print_environment_infoPrint various environment information to stdout/stderr.read_fileReads a file and returns its contents as bytes.repeat_tasksRepeat the given tasks for multiple times.run_parallelRun the given tasks in parallel. A new process will be forked for each task. Each task must have an unique name.run_profilerRun profiler on the given tasks.run_sequentialRun the given tasks in sequence. Each task must have an unique name.save_fileSave the given input binary to a file.save_images_from_datasetSave images from a dataset to disk.save_state_dictSave the model's state_dict to the specified file.search_grid_sequentialGrid search hyperparameters. Tasks are run in sequence.serialize_tensorSerialize a pytorch tensor.switch_pickpick from vals based on conditions. Task will return the first val with condition being True.upload_azure_blobUpload a binary file to Azure Storage Blob.irisml-tasks-trainingThis package contains tasks related to pytorch trainingTaskDescriptionappend_classifierAppend a classifier model to a given model. A predictor and a loss module will be added, too.benchmark_datasetBenchmark dataset loading and preprocessingbenchmark_modelBenchmark a given model using a given dataset.benchmark_model_with_grad_cacheBenchmark a given model using a given dataset with grad caching. Useful for cases which require sub batching.build_classification_prompt_datasetCreate a classification prompt dataset.build_zero_shot_classifierCreate a zero-shot classification layer.concatenate_datasetsConcatenate the given two datasets together.create_classification_prompt_generatorCreate a prompt generator for a classification task.evaluate_accuracyCalculate accuracy of the given prediction results.evaluate_detection_average_precisionCalculate mean average precision for object detection task results.exclude_negative_samples_from_classification_datasetExclude negative samples from classification dataset.export_onnxExport the given model as ONNX.get_targets_from_datasetExtract only targets from a given Dataset.load_simple_classification_datasetLoad a simple classification dataset from a directory of images and an index file.make_classification_dataset_from_object_detectionConvert an object detection dataset into a classification dataset.make_classification_dataset_from_predictionsMake a classification dataset from predictions.make_feature_extractor_modelMake a wrapper model to extract a feature vector from a vision model.make_fixed_prompt_image_transformMake a transform function for image and a fixed prompt.make_image_text_contrastive_modelMake a model for image-text contrastive training.make_image_text_transformMake a transform function for image-text classification.make_oversampled_datasetMake an oversampled dataset.num_iters_to_epochsConvert number of iterations to number of epochs. Min value is 1.predictPredict using a given model.remove_empty_images_from_datasetRemove empty images from dataset.sample_few_shot_datasetFew-shot sampling of a IC/OD dataset.split_image_text_modelSplit a image-text model into an image model and a text model.trainTrain a pytorch model.train_with_gradient_cacheTrain a model using gradient cache. Useful for contrastive learning with a large model.irisml-tasks-torchvisionAdapter tasks for torchvision library.TaskDescriptioncreate_torchvision_modelCreate a torchvision model.create_torchvision_transformCreate transform objects in torchvision library.load_torchvision_datasetLoad a dataset from torchvision package.irisml-tasks-transformersAdapter tasks for HuggingFace transformers library.TaskDescriptioncreate_transformers_modelCreate a model using the transformers library.create_transformers_tokenizerCreate a tokenizer using the transformers library.irisml-tasks-timmAdapter for models in timm library.TaskDescriptioncreate_timm_modelCreate a model using the timm library.create_timm_transformCreate a preprocessing function using the timm library.irisml-tasks-onnxAdapter tasks for OnnxRuntime library.TaskDescriptionpredict_onnxRun inference for an ONNX model.irisml-tasks-azuremlTaskDescriptionrun_azureml_childRun tasks as a new child AzureML Run.add_aml_tagTag the AML Run with a string key and optional value.irisml-tasks-fiftyoneTaskDescriptionlaunch_fiftyoneLaunch a fiftyone interface.DevelopmentCreate a new taskTo create a Task, you must define a module that contains a "Task" class. Here is a simple example:# irisml/tasks/my_custom_task.pyimportdataclassesimportirisml.coreclassTask(irisml.core.TaskBase):# The class name must be "Task".VERSION='1.0.0'CACHE_ENABLED=True# (default: True) This is optional.@dataclasses.dataclassclassInputs:# You can remove this class if the task doesn't require inputs.int_value:intfloat_value:float@dataclasses.dataclassclassConfig:# If there is no configuration, you can remove this class. All fields must be JSON-serializable.another_float:floatchild_dataclass:dataclass# If you'd like to define a nested config, you can define another dataclass.@dataclasses.dataclassclassOutputs:# Can be removed if the task doesn't have outputs.float_value:float=0# If dry_run() is not implemented, Outputs fields must have default value or default factory.defexecute(self,inputs:Inputs)->Outputs:returnself.Outputs(inputs.int_value*inputs.float_value*self.config.another_float)defdry_run(self,inputs:Inputs)->Outputs:# This method is optional.returnself.Outputs(0)# Must return immediately without actual processing.Each Task must define "execute" method. The base class has empty implementation for Inputs, Config, Outputs and dry_run(). For the detail, please see the document for TaskBase class.Related repositoriesirisml-tasksirisml-tasks-trainingirisml-tasks-torchvisionirisml-tasks-transformersirisml-tasks-timmirisml-tasks-azuremlirisml-tasks-fiftyone