nnstreamer / api

Machine Learning API (Origin: C++: SNAP, C/C#: Tizen API, Java: Samsung-Research ML API). For Web/JS, https://git.tizen.org/cgit/platform/core/api/webapi-plugins/
Apache License 2.0
23 stars 25 forks source link

[ml-service] Remote launch/request #415

Open gichan-jang opened 1 year ago

gichan-jang commented 1 year ago

Currently, using ml-service-remote, registering models and pipelines on remote devices has been implemented. Next, let's implement the function of launching the pipeline from the sender device (RTOS) or requesting interference using registered model on remote devices.

taos-ci commented 1 year ago

:octocat: cibot: Thank you for posting issue #415. The person in charge will reply soon.

songgot commented 10 months ago

How about creating the following APIs for remote services?

static void API_NAME (handle *handle,
  const char *pipeline_description, const char *file_name, const char *file_path,
  const char *file_desccription, const char *service_type, const char *service_key, const char *topic)
{
  int ret = ML_ERROR_NONE;
  gsize len = 0;

  ret = ml_option_create (&handle->option_h);
  if (ML_ERROR_NONE != ret) {
    return;
  }

  ret = ml_option_set (handle->option_h, "node-type", "remote_sender", NULL);
  if (ML_ERROR_NONE != ret) {
    return;
  }

  ret = ml_option_set (handle->option_h, "dest-host", handle->broker_ip, NULL);
  if (ML_ERROR_NONE != ret) {
    return;
  }

  ret = ml_option_set (handle->option_h, "dest-port", &handle->broker_port, NULL);
  if (ML_ERROR_NONE != ret) {
    return;
  }

  ret = ml_option_set (handle->option_h, "connect-type", handle->connect_type, NULL);
  if (ML_ERROR_NONE != ret) {
    return;
  }

  if (g_strcmp0(handle->connect_type, "HYBRID") == 0) {
    ret = ml_option_set (handle->option_h, "host", handle->local_ip, NULL);
    if (ML_ERROR_NONE != ret) {
      return;
    }
  }

  ret = ml_option_set (handle->option_h, "topic", (void *)topic, NULL);
  if (ML_ERROR_NONE != ret) {
    return;
  }

  ret = ml_service_remote_create (handle->option_h, NULL, NULL, &handle->service_h);
  if (ML_ERROR_NONE != ret) {
    return;
  }

  ret = ml_option_create (&handle->service_option_h);
  if (ML_ERROR_NONE != ret) {
    return;
  }

  ret =
      ml_option_set (handle->service_option_h, "service-type", (void *)service_type, NULL); //service_type = model_raw
  if (ML_ERROR_NONE != ret) {
    return;
  }

  ret =
      ml_option_set (handle->service_option_h, "service-key", (void *)service_key, g_free); // service-key = model_registration_key
  if (ML_ERROR_NONE != ret) {
    return;
  }

  // ret = ml_option_set (handle->service_option_h, "activate", "true", NULL);
  // if (ML_ERROR_NONE != ret) {
  //   return;
  // }

  if (file_name && file_path && file_desccription) {
    ret = ml_option_set (handle->service_option_h, "name", (void *)file_name, NULL);
    if (ML_ERROR_NONE != ret) {
      return;
    }

    ret = ml_option_set (handle->service_option_h, "description", (void *)file_desccription, NULL);
    if (ML_ERROR_NONE != ret) {
      return;
    }

    dlog_print (DLOG_INFO, LOG_TAG, "transmission data:%s", file_path);

    ret = g_file_get_contents (file_path, &handle->contents, &len, NULL);
    if (FALSE == ret) {
      return;
    }
    ret = ml_service_remote_register (handle->service_h, handle->service_option_h, handle->contents, len);
    if (ML_ERROR_NONE != ret) {
      return;
    }
  } else if (pipeline_description) {
    ret =
      ml_service_remote_register (handle->service_h, handle->service_option_h, (void *)pipeline_description, strlen (pipeline_description) + 1);
    if (ML_ERROR_NONE != ret) {
      return;
    }

  } else {
    return;
  }
  return;
}