|
@@ -4,6 +4,7 @@ Deci-lab model export example.
|
|
The main purpose of this code is to demonstrate how to upload the model to the platform, optimize and download it
|
|
The main purpose of this code is to demonstrate how to upload the model to the platform, optimize and download it
|
|
after training is complete, using DeciPlatformCallback.
|
|
after training is complete, using DeciPlatformCallback.
|
|
"""
|
|
"""
|
|
|
|
+import os
|
|
from super_gradients.training import models
|
|
from super_gradients.training import models
|
|
|
|
|
|
from super_gradients import Trainer
|
|
from super_gradients import Trainer
|
|
@@ -24,8 +25,7 @@ def main(architecture_name: str):
|
|
# Empty on purpose so that it can be fit to the trainer use case
|
|
# Empty on purpose so that it can be fit to the trainer use case
|
|
checkpoint_dir = ""
|
|
checkpoint_dir = ""
|
|
|
|
|
|
- auth_token = "YOUR_API_TOKEN_HERE"
|
|
|
|
-
|
|
|
|
|
|
+ os.environ["DECI_PLATFORM_TOKEN"] = "YOUR_API_TOKEN_HERE" # You can also set your token as environment variable using the commandline or your IDE.
|
|
trainer = Trainer(
|
|
trainer = Trainer(
|
|
f"lab_optimization_{architecture_name}_example",
|
|
f"lab_optimization_{architecture_name}_example",
|
|
model_checkpoints_location="local",
|
|
model_checkpoints_location="local",
|
|
@@ -64,7 +64,6 @@ def main(architecture_name: str):
|
|
phase_callbacks = [
|
|
phase_callbacks = [
|
|
ModelConversionCheckCallback(model_meta_data=model_meta_data, opset_version=11),
|
|
ModelConversionCheckCallback(model_meta_data=model_meta_data, opset_version=11),
|
|
DeciLabUploadCallback(
|
|
DeciLabUploadCallback(
|
|
- auth_token=auth_token,
|
|
|
|
model_meta_data=model_meta_data,
|
|
model_meta_data=model_meta_data,
|
|
optimization_request_form=optimization_request_form,
|
|
optimization_request_form=optimization_request_form,
|
|
opset_version=11,
|
|
opset_version=11,
|
|
@@ -84,7 +83,6 @@ def main(architecture_name: str):
|
|
"criterion_params": {},
|
|
"criterion_params": {},
|
|
"train_metrics_list": [Accuracy(), Top5()],
|
|
"train_metrics_list": [Accuracy(), Top5()],
|
|
"valid_metrics_list": [Accuracy(), Top5()],
|
|
"valid_metrics_list": [Accuracy(), Top5()],
|
|
-
|
|
|
|
"metric_to_watch": "Accuracy",
|
|
"metric_to_watch": "Accuracy",
|
|
"greater_metric_to_watch_is_better": True,
|
|
"greater_metric_to_watch_is_better": True,
|
|
"phase_callbacks": phase_callbacks,
|
|
"phase_callbacks": phase_callbacks,
|
|
@@ -92,8 +90,7 @@ def main(architecture_name: str):
|
|
|
|
|
|
# RUN TRAINING. ONCE ALL EPOCHS ARE DONE THE OPTIMIZED MODEL FILE WILL BE LOCATED IN THE EXPERIMENT'S
|
|
# RUN TRAINING. ONCE ALL EPOCHS ARE DONE THE OPTIMIZED MODEL FILE WILL BE LOCATED IN THE EXPERIMENT'S
|
|
# CHECKPOINT DIRECTORY
|
|
# CHECKPOINT DIRECTORY
|
|
- trainer.train(model=model, training_params=train_params, train_loader=classification_test_dataloader(),
|
|
|
|
- valid_loader=classification_test_dataloader())
|
|
|
|
|
|
+ trainer.train(model=model, training_params=train_params, train_loader=classification_test_dataloader(), valid_loader=classification_test_dataloader())
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if __name__ == "__main__":
|