Hi,
I am trying to prepare some NLP test data by performing OCR on a bunch of pdf documents using google cloud vision OCR and to test it out on a single file i have created a bucket in google cloud, uploaded a pdf file to it and tried to OCR that file using the below code, however i am getting the permissiondenied error, i tried my best to find documentation on how to properly provide permissions and followed the instructions on google documentation by activating the service account as a bearer. Can anyone please look at my code and tell me if i am missing something here.
##I activated the service key using following command line argument.gcloud auth activate-service-account --key-file C:\Python27\GoogleOCR\key.json
import argparseimport reimport osfrom google.cloud import storagefrom google.cloud import vision_v1p2beta1 as visionfrom google.protobuf import json_format
##i have taken sections of code from google documentation on PDF, TIFF file formats.mime_type = 'application/pdf'batch_size = 2client = vision.ImageAnnotatorClient()
feature = vision.types.Feature(type=vision.enums.Feature.Type.DOCUMENT_TEXT_DETECTION)
gcs_source = vision.types.GcsSource(uri='gs://myocrbucket-v/2.pdf')(uri="gs://{}/{}".format('Buckets/myocrbucket-v','2.pdf'))
input_config = vision.types.InputConfig(gcs_source=gcs_source, mime_type=mime_type)
gcs_destination = vision.types.GcsDestination(uri='gs://myocrbucket-v/2.pdf')(uri="gs://{}/{}".format('Buckets/myocrbucket-v','2.pdf'))output_config = vision.types.OutputConfig(gcs_destination=gcs_destination, batch_size=batch_size)
async_request = vision.types.AsyncAnnotateFileRequest(features=[feature],input_config=input_config,output_config=output_config)operation = client.async_batch_annotate_files(requests=[async_request])
print(operation.result)
--
You received this message because you are subscribed to the Google Groups "cloud-vision-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-vision-dis...@googlegroups.com.
To post to this group, send email to cloud-visi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-vision-discuss/6c3ebe89-1151-4df3-8316-3861cb189ee9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "cloud-vision-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-vision-dis...@googlegroups.com.
To post to this group, send email to cloud-visi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-vision-discuss/0299556a-cca3-446b-8fb1-2dd542d55124%40googlegroups.com.
Hi,Your curl parameters are not quite right, but I'm not familiar enough with Windows command line to give much advice.There is a useful Chrome extension for REST testing called Advanced REST client: https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo?hl=en-USIf you use firefox, there is Poster: https://addons.mozilla.org/en-US/firefox/addon/poster/Let me know if those work out for you.Thanks,Duane
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-vision-discuss+unsub...@googlegroups.com.
To post to this group, send email to cloud-vision-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-vision-discuss/0299556a-cca3-446b-8fb1-2dd542d55124%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-vision-dis...@googlegroups.com.
To post to this group, send email to cloud-visi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-vision-discuss/0299556a-cca3-446b-8fb1-2dd542d55124%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--Tangutoori Vamsidhar.
Forbidden: 403 GET https://www.googleapis.com/storage/v1/b/myocrbucket-vamsi?projection=noAcl: mygoo...@turnkey-alpha-125119.iam.gserviceaccount.com does not have storage.buckets.get access to myocrbucket-vamsi.
Hi,
Thanks for the info. Now that we ruled out the Python code as a potential issue, the next thing to check is whether your service account has access to your GCS file.Try using the GCS REST API to read the file in question using the same credentials: https://cloud.google.com/storage/docs/json_api/v1/Thanks,- Duane
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-vision-discuss+unsub...@googlegroups.com.
To post to this group, send email to cloud-vision-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-vision-discuss/0299556a-cca3-446b-8fb1-2dd542d55124%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--Tangutoori Vamsidhar.
Hi Duane,I tried the get bucket method and got the below error.# Imports the Google Cloud client libraryfrom google.cloud import storageimport osos.environ["GOOGLE_APPLICATION_CREDENTIALS"]="C:/Python27/GoogleOCR/key1.json"# Instantiates a clientstorage_client = storage.Client()# The name for the new bucketbucket_name = 'myocrbucket-vamsi'# Creates the new bucketbucket = storage_client.get_bucket(bucket_name)Forbidden: 403 GET https://www.googleapis.com/storage/v1/b/myocrbucket-vamsi?projection=noAcl: mygoo...@turnkey-alpha-125119.iam.gserviceaccount.com does not have storage.buckets.get access to myocrbucket-vamsi.
On Tue, May 8, 2018 at 2:54 PM, Duane Chen <du...@google.com> wrote:
Hi,Thanks for the info. Now that we ruled out the Python code as a potential issue, the next thing to check is whether your service account has access to your GCS file.Try using the GCS REST API to read the file in question using the same credentials: https://cloud.google.com/storage/docs/json_api/v1/Thanks,- Duane
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-vision-dis...@googlegroups.com.
To post to this group, send email to cloud-visi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-vision-discuss/0299556a-cca3-446b-8fb1-2dd542d55124%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--Tangutoori Vamsidhar.--Tangutoori Vamsidhar.
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa1 in position 11: invalid start byte
--
You received this message because you are subscribed to the Google Groups "cloud-vision-discuss" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-vision-discuss/01fb62f0-26a0-4e19-950a-a8078da8c67c%40googlegroups.com.To unsubscribe from this group and stop receiving emails from it, send an email to cloud-vision-discuss+unsub...@googlegroups.com.
To post to this group, send email to cloud-vision-discuss@googlegroups.com.