Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error processing image locally with openai api #33

Open
simeneide opened this issue Nov 7, 2024 · 1 comment
Open

Error processing image locally with openai api #33

simeneide opened this issue Nov 7, 2024 · 1 comment

Comments

@simeneide
Copy link

Had to change the process_page() function to this for it to work (didnt seem to provide the correct "message" syntax to openai):


            def process_page(page_num):
                page = doc[page_num]
                text = page.get_text()
                pix = page.get_pixmap()
                image = Image.frombytes("RGB", [pix.width, pix.height], pix.samples)
                
                base64_image = make_image_url(image, host_images=HOST_IMAGES)  # Assuming it returns a base64-encoded result

                messages = [
                    {
                        "role": "user",
                        "content": [
                            {"type": "text", "text": "```{} ```\n{}".format(text, SCRAPING_PROMPT)},
                            {"type": "image_url", "image_url": {"url": base64_image}},
                        ]
                    },
                ]
@g-simmons
Copy link

same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants