Use Pre-trained Weights
Upload weights along with your model in theuser.uploadModel() step and set weights=True, the default value is False:
Model Code Formats
Model code can be:- A single Python file containing one or more functions
- A single Python file with no functions
- Multiple Python files (zipped), with the main file code outside of any function
- Multiple Python files (zipped), with the main file code inside a function
In case of multiple files saved as .zip format, the files should be directly inside the .zip file. Subdirectory structure in .zip files is not supported.
Mandatory Variables
PyTorch mandatory variables
The file must contain these variables:- framework : name of the framework for which this model file is created. For PyTorch its value will be pytorch.
- model_type : name of the model type for which this model file is created. its value will be either empty or rcnn or heatmap or yolo.
- main_class : name of the main class of the model.
- image_size : name of the variable defining the input size considered for creating model layers.
- category : name of the category for which this model file is created. its value will be either of these : image_classification, object_detection, keypoint_detection, text_classification.
- batch_size : name of the variable defining the batch size of the images considered for creating model layers.
Sklearn mandatory variables
The file must contain these variables:- framework : name of the framework for which this model file is created. For Sklearn its value will be sklearn.
- model_type : name of the model type for which this model file is created. Its value will be either empty or tree or linear or knn or naive or mlp.
- main_class or main_method : name of the main class or main method of the model. Any one of these is necessary for model.
- image_size : name of the variable defining the input size considered for creating model layers.
- category : name of the category for which this model file is created. Its value will be either of these : image_classification, object_detection, keypoint_detection, text_classification.
- batch_size : name of the variable defining the batch size of the images considered for creating model layers.
Tensorflow mandatory variables
Each format must contain these variables on the main file:- framework : name of the framework for which this model file is created. For tensorflow its value will be tensorflow.
- model_type : name of the model type for which this model file is created. Its value will be either empty or rcnn or heatmap.
- main_method : name of the main function
- input_shape or image_size : name of the variable defining the input shape of the model
- category : name of the category for which this model file is created. Its value will be either of these : image_classification, object_detection, keypoint_detection, text_classification.
- output_classes : name of the variable defining the output shape of the variables. The value of this variable is equal to the number of classes in the dataset.
Additional variables
Some additional variables are required for specific categories- num_feature_points : number of keypoints or feature points for which this model file is created. This variable is used only for keypoint_detection and generic_classification category.
- model_id : model id using which this model file is created. This variable is used only for text_classification category.
- hf_token : hf token using which this model file is created. This variable is used only for text_classification category.
Detailed Information on each format
1. Single python file containing one class for pyTorch
All your model code needs to be contained in a single python file with the following structure:1.1 Import Section
Import all the necessary functionality needed to build your model.1.2 Main Class
This is the main method which should return the model as output.- framework = ‘pytorch’
- main_method = ‘Net’
- image_size = 224
- batch_size = 16
2. Single python file containing one class for sklearn
All your model code needs to be contained in a single python file with the following structure:2.2 Import Section
Import all the necessary functionality you need to build your model.2.3 Main Method
This is the main method which should return the model as output.- framework = ‘sklearn’
- main_method = ‘MyModel’
- image_size = 224
- batch_size = 16
3. Single python file containing one/multiple methods for tensorflow
All your model code needs to be contained in a single python file with the following structure:3.1 Import Section
Import all the necessary functionality you need to build your model.3.2 Supporting Functions
Any kind of functionality that supports the model architecture. This section is optional. This section can be left out if the model architecture does not require it.3.3 Main Method
This is the main method which should return the model as output.- framework = ‘tensorflow’
- main_method = ‘MyModel’
- input_shape = ‘input_shape’
- output_classes = ‘classes’
4. Single python file having no method for tensorflow
All your model code needs to be in a single python file with the following structure: The model file can be broken down into two sections: The Import section and the main code.4.1 Import Section
Import all the necessary functionalities you need to build your model.4.2 Main Code
This is the model code with all layers.- framework = ‘tensorflow’
- main_method = ”
- input_shape = ‘input_shape’
- output_classes = ‘classes’
5. Multiple python files with main file code not contained in a method
In this format the model architecture is defined using multiple python files. But the main file should use the same format as type 1. In order to upload models with this format, zip all python files with the main method containing the mentioned variables and upload the zip file.The main file should contain the variable values as mentioned in the type 1 format. Other files should not contain these variables.
6. Multiple python file with main file code contained in a method
In this format the model architecture is defined using multiple python files. But the main file should use the same format as type 2. In order to upload models with this format, zip all python files with the main method containing the mentioned variables and upload the zip file.The main file should contain the variable values as mentioned in type 2 format. Other files should not contain these variables.
Next Steps
- Configure training parameters: Hyperparameters
Need Help?
- Email us at [email protected]