- Newest
- Most votes
- Most comments
Your code is the same of my
here is my Role/user : Id - Last utilisation(last hour) - region (eu-west-3)- last used service (textract) - Statut(Active) I dont know why with image.png is correct , and with another file ist incorrect.
Hi,
thanks a lot for your response. I find the solution and it works;
the code from PIL import Image import boto3 import io import pandas as pd from trp import Document
image=images[0] image.save(path+"image.png", format="png")
im = Image.open(path+"image.png") buffered = io.BytesIO() im.save(buffered, format='PNG')
client = boto3.client('textract') response = client.analyze_document( Document={'Bytes': buffered.getvalue()}, FeatureTypes=['TABLES'] )
for item in response["Blocks"]: if item["BlockType"] == "LINE": tata=item["Geometry"]["BoundingBox"] X0 , Y0, width, height = tata['Left'] , tata['Top'] ,tata['Width'] , tata['Height'] dim = item["Text"].upper(), X0 , Y0 , width , height Detail_page.append(dim)
df = pd.DataFrame (Detail_page,columns = ['text','X0','Y0','width','height'])
Good to hear that. May I ask you please to accept the question, so it will help also others. Thanks
Please try this way:
import boto3
#import Document
# Add your file to your bucket and change the bellow 2 lines
s3BucketName = "dus-idp-textract"
document = "The_river_effect_in_justified_text.jpg"
textractmodule = boto3.client('textract',region_name='eu-west-1')
response = textractmodule.detect_document_text( Document={ 'S3Object': { 'Bucket': s3BucketName, 'Name': document } })
response
I just tried it and it works. Also please add the permissions (Textract Policy) to the Role/User you are using in order to have permission to call Amazon Textract APIs
If you consider that this answer helped, please accept it
Relevant content
- asked a month ago
- asked 10 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated 2 years ago
You found the problem, correct?