Supporting Functions¶
configure_credentials()¶
Return a formatted credentials file built with user inputs.
Combine your AI Model Share & AWS credentials into a single ‘credentials.txt’ file with the configure_credentials function. You only have to make the file once, then you can use it whenever you use the aimodelshare library.
Credentials files must follow this format:
The following code will prompt you to provide your credentials one at a time and pre-format a txt file for you to use in the future:
Example
#install aimodelshare library
! pip install aimodelshare
# Generate credentials file
import aimodelshare as ai
from aimodelshare.aws import configure_credentials
configure_credentials()
set_credentials()¶
Set credentials for all AI Model Share functions with
the aimodelshare.aws.set_credentials()
function:
Set credentials for AI Model Share and Amazon Web Services (AWS).
- Parameters:
credential_file (string) – Path to formatted credentials txt file.
type (string) – set to “deploy_model” to deploy a ModelPlayground.
apiurl (string) – unique api_url that powers a specific Model Playground.
- Returns:
Success Message.
Example
# Deploying ModelPlaygrounds - Requires AWS credentials
from aimodelshare.aws import set_credentials
set_credentials(credential_file="credentials.txt", type="deploy_model")
# Submitting Models to Competition - No AWS credentials required
from aimodelshare.aws import set_credentials
apiurl="https://example.execute-api.us-east-1.amazonaws.com/prod/m"
set_credentials(apiurl=apiurl)
download_data()¶
Download data sets that have been shared to AI ModelShare with the aimodelshare.data_sharing.download_data()
function:
Download data that has been shared to the AI ModelShare website.
- Parameters:
repository (string) – URI & image_tag of uploaded data (provided with the create_competition method of the Model Playground class)
- Returns:
Success Message & downloaded data directory
Example
from aimodelshare import download_data
download_data('example-repository:image_tag')
export_eval_metric()¶
Export evaluation metric and related objects into zip file for model deployment
- Parameters:
eval_metric_fxn (string) – name of eval metric function (should always be named “eval_metric” to work properly)
directory (string) – folderpath to eval metric function use “” to reference current working directory
name (string) – name of the custom eval metric
- Returns:
file named ‘name.zip’ in the correct format for model deployment
Example
from aimodelshare import export_eval_metric
export_eval_metric(eval_metric_fxn, directory, name)
export_reproducibility_env()¶
Export development environment to enable reproducibility of your model.
- Parameters:
seed (Int) – Random Seed
mode (string) – Processor - either “gpu” or “cpu”
- Directory:
Directory for completed json file
- Returns:
“./reproducibility.json” file to use with submit_model()
Example
from aimodelshare import export_reproducibility_env
export_eval_metric(seed, directory, mode)