Notes
Notes - notes.io |
def encode_image(image_path):
"""Encodes an image to base64."""
with open(image_path, "rb") as image_file:
return base64.b64encode(image_file.read()).decode('utf-8')
def image_to_text_claude(image_base64, index):
"""
Sends a base64-encoded image to the Claude model for text extraction, returning the response text.
Args:
image_base64 (str): Base64-encoded image data.
Returns:
str: Extracted text from the image.
"""
day = day_index[index]
example_format1 = example_format.replace("Perticular Day Of Week", day)
response = client.messages.create(
model="claude-3-5-sonnet-20240620",
max_tokens=1024,
messages=[
{
"role": "user",
"content": [
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/png",
"data": image_base64,
},
},
{
"type": "text",
"text": f"""This image shows a weekly meal attendance table for a program or institution. The table has the following structure:
1. Rows represent individual participants, identified by their last name followed by first name (e.g., 'DEATER, STELLA').
2. Columns represent various days (e.g., 'Monday', 'Tuesday', etc.).
3. For each day, there are sub-columns representing different meal types:
* 'At'
* 'B'
* 'A'
* 'L'
* 'P'
* 'S'
* 'E'
4. In each cell, Crossmarks ("X") indicates True (the participant attended that meal on that day), while a blank cell indicates False (the participant did not attend).
5. The 'Age' column provides the age of each participant.
6. The table is labeled 'CLASS 3B (3 YRS)' on the left side.
**Please analyze this table and provide the extracted information in a JSON format with the following structure:{example_format1}**
**Ensure that all participants and their complete weekly attendance records are included in the JSON output.**
Rules:
1. Carefully examine each Crossmarks ("X") marking, ensuring it's assigned to the correct meal column based on where the majority of the Crossmarks ("X") appears.
2. Pay special attention to Crossmarks ("X") markings that cross multiple columns, assigning them to the column where the majority of the Crossmarks ("X") appears."""
}
],
}
],
)
response = response.content[0].text
return response
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team
