Google automl_v1beta1错误“提供的位置ID无效”

时间:2019-03-20 08:18:32

标签: google-cloud-automl

我正在尝试通过提供的示例从google colab调用经过训练的模型。

但是有一个错误。

谁知道这是beta错误还是我没有正确设置某些东西?

谢谢。

代码

Map<LocalDate, MenuChart2.Statistics> last3MPerDay =    

                menuPriceByDayService.findAllOrderByUpdateDate(menu, DateUtils.quarterlyDate(), 92)
                .stream()
                .sorted(comparing(MenuPriceByDay::getUpdateDate))
                .collect(Collectors
                        .toMap(MenuPriceByDay::getUpdateLocalDate, p -> new MenuChart2().new Statistics( p.getMinPrice().doubleValue());

TreeMap<LocalDate, , MenuChart2.Statistics> last3MPerDaySorted = new TreeMap<LocalDate, MenuChart2.Statistics>(last3MPerDay);

错误信息^

from google.cloud import automl_v1beta1 as automl

automl_client = automl.AutoMlClient()

# Create client for prediction service.
prediction_client = 
automl.PredictionServiceClient().from_service_account_json(
        'XXXXX.json')

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

# Read the file content for prediction.
#with open(file_path, "rb") as content_file:
snippet = "fsfsf" #content_file.read()

# Set the payload by giving the content and type of the file.
payload = {"text_snippet": {"content": snippet, "mime_type": "text/plain"}}

# params is additional domain-specific parameters.
# currently there is no additional parameters supported.
params = {}
response = prediction_client.predict(model_full_id, payload, params)
print("Prediction results:")
for result in response.payload:
    print("Predicted class name: {}".format(result.display_name))
    print("Predicted class score: {}".format(result.classification.score))

2 个答案:

答案 0 :(得分:0)

您必须使用支持AutoML beta的区域。这对我有用:

create_dataset("myproj-123456", "us-central1", "my_dataset_id", "en", "de")

答案 1 :(得分:0)

  1. 我克隆了仓库“ python-docs-samples”:

$ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git

  1. 我导航到automl示例

$ cd / home / MY_USER / python-docs-samples / language / automl /

  1. 我为[1]设置了环境变量:

    • GOOGLE_APPLICATION_CREDENTIALS
    • PROJECT_ID
    • REGION_NAME
  2. 我输入了:

$ python automl_natural_language_dataset.py create_dataset automltest1 False

  1. 我收到此消息:

数据集名称:projects / 198768927566 / locations / us-central1 / datasets / TCN7889001684301386365 数据集ID:TCN7889001684301386365 数据集显示名称:automltest1 文本分类数据集元数据:         category_type:MULTICLASS

数据集示例计数:0 数据集创建时间:         秒:1569367227         纳米:873147000

  1. 我为设置环境变量:

    • DATASET_ID

请注意,我已经在步骤5中得到了它。

  1. 我输入:

python automl_natural_language_dataset.py import_data $ DATASET_ID“ gs://$PROJECT_ID-lcm/complaints_manual.csv”

  1. 我收到此消息:

正在处理导入... 数据集已导入。