This script, gpt4_group_criteria.py
, is a Python script that uses OpenAI's GPT-4V model to perform certain tasks. The script requires an OpenAI API key to function.
The script uses the following criterion outlined in the Rubric for Scientific Posters provided by Harvard University's Writing Center:
- Organization
- Graphics
- Data Visualization
- Text
- White Space
- Objectives
- Main Points
-
Ensure you have a
.env
file in your project root with your OpenAI API key. The key should be stored asOPENAI_API_KEY=your_api_key_here
. -
Create a virtual environment using
conda
orvenv
, and install the required Python packages usingpip install -r requirements.txt
. -
If your files are in pdf format. Use the command
python convert_pdf2img.py --input_dir "path_to_dir_with_pdf_files" --output_dir "path_to_dir_to_store_png"
to convert pdf files to PNG. -
Use the script by running the command
python gpt4_group_criteria.py --image_path "./images/path_to_your_poster_file" --result_base_dir "./output_json_files"
. Replace./images/path_to_your_poster_file
with the path to the image you want to encode, and./output_json_files
with the directory where you want to store the output JSON files. -
(Optional) Use the script by running the command
python gpt4_group_criteria_batch.py --image_dir "path_to_your_poster_files" --result_base_dir "./output_json_files"
. Replacepath_to_your_poster_files
with the path to the poster image folder.
This function takes an image path as input and returns the base64 encoding of the image.
This function takes a JSON file path as input and returns the loaded JSON object.
This function takes a numpy object as input and converts it into a serializable format. It supports np.int64
and np.ndarray
objects.