【问题标题】:What is this file type is this? [closed]这是什么文件类型这是什么? [关闭]
【发布时间】:2022-01-21 17:54:20
【问题描述】:

我目前在 Loop 模型中使用自定义 GCP Human,当在本地运行时,它返回的文本似乎是 JSON 文件的形式,但有一些特性使其并非如此。谁能告诉我这个文件是什么? 目前用于生成此代码的代码如下:

def inline_text_payload(file_path):
    with open(file_path, 'rb') as ff:
        content = ff.read()
    return {'text_snippet': {'content': content, 'mime_type': 'text/plain'} }

def pdf_payload(file_path):
    return {'document': {'input_config': {'gcs_source': {'input_uris': [file_path] } } } }

def get_prediction(file_path, model_name):
    options = ClientOptions(api_endpoint='automl.googleapis.com')
    prediction_client = automl_v1.PredictionServiceClient(client_options=options)

    #payload = inline_text_payload(file_path)
    # Uncomment the following line (and comment the above line) if want to predict on PDFs.
    payload = pdf_payload(file_path)

    params = {}

    request = prediction_client.predict(name=model_name, payload=payload)


    return request  # waits until request is returned

请求返回如下所示的文本。

payload {
  annotation_spec_id: "xxxxx"
  display_name: "xxxx"
  text_extraction {
    score: xxxx
    text_segment {
      start_offset: xxx
      end_offset: xxx
      content: "xxxxxx"
    }
  }
}
payload {
  annotation_spec_id: "xxxxx"
  display_name: "xxxxx"
  text_extraction {
    score: xxxx
    text_segment {
      start_offset: xxxx
      end_offset: xxxx
      content: "xxxxx"
    }
  }
}
payload {
  annotation_spec_id: "xxxxx"
  display_name: "xxxxx"
  text_extraction {
    score: xxxxx
    text_segment {
      start_offset: xxxx
      end_offset: xxx
      content: "xxx"
    }
  }
}
payload {
  annotation_spec_id: "xxxx"
  display_name: "xxxxx"
  text_extraction {
    score: xxxx
    text_segment {
      start_offset: xxxx
      end_offset: xxx
      content: "xxxxx"
    }
  }
}

【问题讨论】:

标签: file machine-learning google-cloud-platform types


【解决方案1】:

就@john-hanley 而言,代码有助于识别方法,而且由于 Google 在记录其 API 方面做得非常出色,因此我们可以从代码中提供帮助:

predict 返回PredictResponse

响应应该是[]payload 和有效的 JSON。

【讨论】:

    猜你喜欢
    • 2013-08-15
    • 1970-01-01
    • 2013-03-14
    • 2015-02-18
    • 1970-01-01
    • 2016-04-12
    • 1970-01-01
    • 1970-01-01
    • 2015-11-30
    相关资源
    最近更新 更多