Generates JSON Schema-compatible recipes from images using Open AI's GPT-4-Turbo-Vision preview API.
You will need an Open AI platform account. https://platform.openai.com/
To get access to the GPT-4-Turbo-Vision API, you will need to fund your account with at least 5 dollars in credits. I was able to process roughly 200 recipes (plus 10-15 test calls while I was building this script) for about nine dollars.
Usage:
- Create a folder called "out".
- If generating from a PDF, convert each page to a JPG image. If you're using macOS, this is easy to do using Automator.
- Remove any images that do not contain a recipe.
- Place all the images to be converted into a folder next to gpt.go.
- Set the
input_folder
variable to your image folder name. - Set the
author
variable to any value (perhaps the author of the recipes you're converting). - Set
key
to your OpenAI key. - Run the file by invoking
go run ./gpt.go
.
The Vision API is in preview at the time of this writing. Rate limits are
low. Depending on the number of requests, you will hit these limits and start
seeing errors. When you do, just kill the script and try again later. So long
as you don't move files out of out
, it will pick up where it left off.