Package: pipeline-ai
Pipeline SDKCreated bymystic.aiTry premade models for free that have been made using this library:https://www.mystic.ai/exploreTable of ContentsAboutInstallationModelsExample and tutorialsDevelopmentLicenseAboutPipeline is a python library that provides a simple way to construct computational flows for AI/ML models. The library is suitable for both development and production environments supporting inference and training/finetuning. This library is also a direct interface toMysticwhich provides a compute engine to run pipelines at scale and on enterprise GPUs. This SDK can also be used withPipeline Coreon a private hosted cluster.The syntax used for defining AI/ML pipelines shares some similarities in syntax to sessions inTensorflow v1, and Flows found inPrefect.Installation and quickstartTo install pipeline run:pipinstallpipeline-aiTo create a new pipeline navigate to the directory you want to create the pipeline in and run:pipelinecontainerinit-nquickstartThis will create two files in the directory:pipeline.yaml- The configuration file for the container to run the pipeline.new_pipeline.py- The python file to populate with your pipeline.ModelsBelow are some popular models that have been premade by the community on Mystic. You can find more models in theexploresection of Mystic, and the source code for these models is also referenced in the table.ModelCategoryDescriptionSourcemeta/llama2-7BLLMA 7B parameter LLM created by Meta (vllm accelerated)sourcemeta/llama2-13BLLMA 13B parameter LLM created by Meta (vllm accelerated)sourcemeta/llama2-70BLLMA 70B parameter LLM created by Meta (vllm accelerated)sourcerunwayml/stable-diffusion-1.5VisionText -> Imagesourcestabilityai/stable-diffusion-xl-refiner-1.0VisionSDXL Text -> Imagesourcematthew/e5_large-v2LLMText embeddingsourcematthew/musicgen_largeAudioMusic generationsourcematthew/blipVisionImage captioningsourceExample and tutorialsTutorialDescriptionEntity objectsUse entity objects to persist values and store thingsCold start optimisationsPremade functions to do heavy tasks seperatelyInput/output typesDefining what goes in and out of your pipesFilesInputing or outputing files from your runsPipeline buildingBuilding pipelines - how it worksRunsRunning a pipeline remotely - how it worksBelow is some sample python that demonstrates various features and how to use the Pipeline SDK to create a simple pipeline that can be run locally or on Mystic.frompathlibimportPathfromtypingimportListimporttorchfromdiffusersimportStableDiffusionPipelinefrompipelineimportPipeline,Variable,pipe,entityfrompipeline.cloudimportcompute_requirementsfrompipeline.objectsimportFilefrompipeline.objects.graphimportInputField,InputSchemaclassModelKwargs(InputSchema):# TUTORIAL: Input/output typesheight:int|None=InputField(default=512,ge=64,le=1024)width:int|None=InputField(default=512,ge=64,le=1024)num_inference_steps:int|None=InputField(default=50)num_images_per_prompt:int|None=InputField(default=1,ge=1,le=4)guidance_scale:int|None=InputField(default=7.5)@entity# TUTORIAL: Entity objectsclassStableDiffusionModel:@pipe(on_startup=True,run_once=True)# TUTORIAL: Cold start optimisationsdefload(self):model_id="runwayml/stable-diffusion-v1-5"device=torch.device("cuda"iftorch.cuda.is_available()else"cpu")self.pipe=StableDiffusionPipeline.from_pretrained(model_id,)self.pipe=self.pipe.to(device)@pipedefpredict(self,prompt:str,kwargs:ModelKwargs)->List[File]:# TUTORIAL: Input/output typesdefaults=kwargs.to_dict()images=self.pipe(prompt,**defaults).imagesoutput_images=[]fori,imageinenumerate(images):path=Path(f"/tmp/sd/image-{i}.jpg")path.parent.mkdir(parents=True,exist_ok=True)image.save(str(path))output_images.append(File(path=path,allow_out_of_context_creation=True))# TUTORIAL: Filesreturnoutput_imageswithPipeline()asbuilder:# TUTORIAL: Pipeline buildingprompt=Variable(str)kwargs=Variable(ModelKwargs)model=StableDiffusionModel()model.load()output=model.predict(prompt,kwargs)builder.output(output)my_pl=builder.get_pipeline()DevelopmentThis project is made with poetry,so firstly setup poetry on your machine.Once that is done, please run./setup.shWith this you should be good to go. This sets up dependencies, pre-commit hooks and
pre-push hooks.You can manually run pre commit hooks withpre-commitrun--all-filesTo run tests manually please runpytestFor developing v4, i.e. containerized pipelines, you need to override the installed pipeline-ai python package on the container.
This can be done by bind mounting your target pipeline directory, e.g. using raw dockerLicensePipeline is licensed underApache Software License Version 2.0.