int main()

in sagemaker-neo-notebooks/edge/cpp-integration/tutorial.cc [544:607]


int main(int argc, char** argv) {
  // in this example, we're using gluon_imagenet_classifier resnet18
  std::string MODEL_NAME = "resnet18_v1";
  std::string MODEL = MODEL_NAME + ".tar.gz";
  std::string MODEL_ZOO = "gluon_imagenet_classifier";
  std::string FILENAME = "./" + MODEL;

  // this is where we set input bucket
  // this can be changed to your corresponding input
  std::string pretrained_bucket = "neo-ai-dlr-test-artifacts";
  std::string pretrained_key = "neo-ai-notebook/" + MODEL_ZOO + "/" + MODEL;
  std::string target_device = "ml_c4";

  std::string model_name = MODEL_NAME;
  std::string filename = "./" + model_name;

  // s3 bucket for compiled model output
  std::string s3_bucket_name = "windows-demo";

  // compiled model meta
  std::string compiled_filename = "./compiled_model.tar.gz";
  std::string compiled_folder = "./compiled_model";

  if (argc < 2) {
    std::cerr << "invalid argument count, need at least one command" << std::endl;
    return 1;
  }

  std::string cmd = argv[1];
  try {
    if (cmd == "compile") {
      std::string target = argv[2];
      Aws::SDKOptions options;
      Aws::InitAPI(options);

      // make your SDK calls here.
      GetPretrainedModel(pretrained_bucket, pretrained_key, filename);
      UploadModelToS3(model_name, filename, s3_bucket_name);
      CreateIamStep();
      CompileNeoModel(s3_bucket_name, model_name, target);
      GetCompiledModelFromNeo(s3_bucket_name, model_name, target, compiled_filename);

      Aws::ShutdownAPI(options);
    } else if (cmd == "inference") {
      std::string npy_name = "./dog.npy";
      Aws::SDKOptions options;
      Aws::InitAPI(options);

      // download sample npy file
      DownloadNpyData();

      // run inference
      RunInference(compiled_folder, npy_name);

      Aws::ShutdownAPI(options);
    } else {
      std::cerr << "no valid argument command" << std::endl;
    }
  } catch (std::exception& e) {
    std::cout << e.what() << std::endl;
  }

  return 0;
}