QuickStart tutorials
Integrate AIShield in 5 mins
11min
tl;dr in under 30 minutes, follow the easy step by step process (including code snippets) presented in this guide to effortlessly integrate aishield’s vulnerability analysis and defense generation features into your mlops workflow experience these three key benefits by implementing aishield benefit 1 ensure the security, robustness, and resistance to adversarial attacks of your ai models by integrating aishield in your mlops pipeline benefit 2 receive detailed vulnerability analysis and defense reports to identify and address potential weaknesses in your ai models benefit 3 deploy secure, high quality machine learning models with confidence, protecting your applications and users from adversarial attacks act now to protect your organization’s ai models sign up for a free trial of aishield api ( aws , non aws ) today, and seize the opportunity to bolster security of ai model you can also check out reference implementations here , as ai developers, we strive to create robust and secure machine learning models one essential aspect of this process is integrating security checks and vulnerability analysis within your mlops pipeline aishield, an ai security platform, offers a powerful solution to analyze, detect, and mitigate potential vulnerabilities in your ai models in this blog post, we will guide you through integrating aishield in your mlops pipeline to ensure your models are secure before deployment overview of aishield aishield is a comprehensive ai security platform designed to analyze machine learning models for potential vulnerabilities, generate defenses, and provide detailed reports for developers by integrating aishield in your mlops pipeline, you can ensure your models are secure, robust, and resistant to adversarial attacks prerequisites to follow this guide, you should have a basic understanding of mlops and experience with python and machine learning libraries such as tensorflow or pytorch you will also need an aishield subscription to access the api train your model before integrating aishield, train your machine learning model using your preferred framework (e g , tensorflow or pytorch) for the remaining of the explanation, we assume that you have used mnist dataset and trained a simple cnn model in tensorflow let’s have fun steps to integrate aishield in your mlops pipeline below are the key steps for integrating aishield into your mlops pipeline, along with code snippets to guide you through the process install aishield package install the aishield package using pip pip install aishield 2 import aishield library in your python script, import the aishield library import aishield as ais 3 prepare your model, data, and label artifacts create zip folders for your model, data, and label artifacts this is required for uploading these artifacts to the aishield api """ description zip data """ from shutil import make archive import os zip path = "/path/to/zip/folder" data path = "/path/to/data/folder" label path = "/path/to/label/folder" model path = "/path/to/model/folder" """ description file paths """ make archive(base name=os path join(zip path, "data"), root dir=data path, zip format="zip") make archive(base name=os path join(zip path, "label"), root dir=label path, zip format="zip") make archive(base name=os path join(zip path, "model"), root dir=model path, zip format="zip") 4 aishield api key follow the instruction provided in the email to generate api key / x api key if you are using pypi package then , x api key generation is taken care from pypi side using given org id 5 initialize aishield api client and register the model create an aishield api client instance, register your model, and upload the input artifacts (data, label, and model zip files) """ description initialize the aishield api """ client = ais aishieldapi(api url=url, org id=org id) """ description define the task and analysis type """ task type = ais get type("task", "image classification") analysis type = ais get type("analysis", "extraction") """ description perform model registration and upload the input artifacts """ status, job details = client register model(task type=task type, analysis type=analysis type) model id = job details model id data path = os path join(zip path, 'data zip') label path = os path join(zip path, 'label zip') model path = os path join(zip path, 'model zip') upload status = client upload input artifacts( job details=job details, data path=data path, label path=label path, model path=model path, ) print('upload status {}' format(', ' join(upload status))) 6 configure vulnerability analysis define the vulnerability analysis configuration, such as input dimensions, number of classes, attack type, number of attack queries, and encryption strategy """ description specify the appropriate configs required for vulnerability analysis """ input shape = (28, 28, 1) # example input shape for mnist dataset num classes = 10 # example number of classes for mnist dataset vuln config = ais vulnconfig(task type=task type, analysis type=analysis type, defense generate=true) vuln config input dimensions = input shape # input dimension for mnist digit classification vuln config number of classes = = num classes # number of classes for mnist digit classification vuln config attack type = = "greybox" # greybox or blackbox depending upon the availability of information about model, data and parameters vuln config attack queries = 60000 # number of attack queries to be generated for testing model vulnerability vuln config encryption strategy = 0 # value 0 (or) 1, if model is unencrypted or encrypted(pyc) respectively 7 perform vulnerability analysis run the vulnerability analysis using the aishield api client monitor the progress through the provided url and fetch the job status using the job id """ description specify the appropriate configs required for vulnerability analysis """ input shape = (28, 28, 1) # example input shape for mnist dataset num classes = 10 # example number of classes for mnist dataset vuln config = ais vulnconfig(task type=task type, analysis type=analysis type, defense generate=true) vuln config input dimensions = input shape # input dimension for mnist digit classification vuln config number of classes = = num classes # number of classes for mnist digit classification vuln config attack type = = "greybox" # greybox or blackbox depending upon the availability of information about model, data and parameters vuln config attack queries = 60000 # number of attack queries to be generated for testing model vulnerability vuln config encryption strategy = 0 # value 0 (or) 1, if model is unencrypted or encrypted(pyc) respectively 8 save and download reports and artifacts download the vulnerability report, defense reports, defense artifacts (e g , the model), and attack samples save these files in a specified output folder for further review and analysis """ description creating a directory to save the defense artifacts """ output path = os path join(os getcwd(), "output artifacts") os makedirs(output path, exist ok=true) if job status state == ais get type("job state", "finished") \# download vulnerability report output conf = ais outputconf(report type=ais get type("report", "vulnerability"), file format=ais get type("file format", "pdf"), save folder path=output path) vulnerability report = client save job report(job id=job id, output config=output conf) \# download defense report output conf = ais outputconf(report type=ais get type("report", "defense"), file format=ais get type("file format", "pdf"), save folder path=output path) defense report = client save job report(job id=job id, output config=output conf) \# download defense model output conf = ais outputconf(report type=ais get type("report", "defense artifact"), file format=ais get type("file format", "zip"), save folder path=output path) defense artifact = client save job report(job id=job id, output config=output conf) \# download attack samples output conf = ais outputconf(report type=ais get type("report", "attack samples"), save folder path=output path) attack samples = client save job report(job id=job id, output config=output conf) post using aishield analyzing and implementing improvements review the vulnerability and defense reports generated by aishield you can do either downloading the reports or using the dashboard to view the the model details this helps you identify potential weaknesses and implement necessary improvements to enhance your model’s security by either hardening the model using supplied attack vectors or integrating the defense model provided deploy your secure model once you have addressed the vulnerabilities and enhanced your model, integrate the secure model back into your mlops pipeline for deployment this ensures that you are deploying a robust and secure machine learning model for real world applications conclusion integrating aishield in your mlops pipeline is an essential step for ai developers to ensure the security and robustness of their machine learning models by following the steps outlined in this guide, you can seamlessly incorporate aishield’s vulnerability analysis and defense generation capabilities into your mlops workflow this enables you to deploy secure, high quality models with confidence, protecting your applications and users from potential adversarial attacks act now to protect your organization’s ai models sign up for a free trial of aishield api ( aws , non aws ) today, and seize the opportunity to bolster security of ai model you can also check out reference implementations here