Diese Seite wurde von der Cloud Translation API übersetzt.
Switch to English

Modell abrufen

Informationen zu einem Modell abrufen.



 * Demonstrates using the AutoML client to get model details.
 * @param projectId the Id of the project.
 * @param computeRegion the Region name.
 * @param modelId the Id of the model.
 * @throws IOException on Input/Output errors.
public static void getModel(String projectId, String computeRegion, String modelId)
    throws IOException {
  // Instantiates a client
  try (AutoMlClient client = AutoMlClient.create()) {

    // Get the full path of the model.
    ModelName modelFullId = ModelName.of(projectId, computeRegion, modelId);

    // Get complete detail of the model.
    Model model = client.getModel(modelFullId);

    // Display the model information.
    System.out.println(String.format("Model name: %s", model.getName()));
            "Model id: %s", model.getName().split("/")[model.getName().split("/").length - 1]));
    System.out.println(String.format("Model display name: %s", model.getDisplayName()));
    System.out.println("Model create time:");
    System.out.println(String.format("\tseconds: %s", model.getCreateTime().getSeconds()));
    System.out.println(String.format("\tnanos: %s", model.getCreateTime().getNanos()));
    System.out.println(String.format("Model deployment state: %s", model.getDeploymentState()));


    # TODO(developer): Uncomment and set the following variables
    # project_id = 'PROJECT_ID_HERE'
    # compute_region = 'COMPUTE_REGION_HERE'
    # model_id = 'MODEL_ID_HERE'

    from google.cloud import automl_v1beta1 as automl

    client = automl.AutoMlClient()

    # Get the full path of the model.
    model_full_id = client.model_path(project_id, compute_region, model_id)

    # Get complete detail of the model.
    model = client.get_model(name=model_full_id)

    # Retrieve deployment state.
    if model.deployment_state == automl.Model.DeploymentState.DEPLOYED:
        deployment_state = "deployed"
        deployment_state = "undeployed"

    # Display the model information.
    print("Model name: {}".format(model.name))
    print("Model id: {}".format(model.name.split("/")[-1]))
    print("Model display name: {}".format(model.display_name))
    print("Model create time: {}".format(model.create_time))
    print("Model deployment state: {}".format(deployment_state))