This comprehensive guide demonstrates how to create a pre-classification task Agent that uses GPT-4 to automatically classify images and route them to specific annotation stages based on their classification. This approach is particularly useful when you have specialized annotators. Images with uncertain classifications are automatically added to the Archive for further review.
This guide makes the following assumptions:
Set Up AWS
Before you can do anything with the Encord platform and cloud storage, you need to configure your cloud storage to work with Encord. Once the integration between Encord and your cloud storage is complete, you can then use your data in Encord.
In order to integrate with AWS S3, you need to:
You have the following options to integrate AWS and Encord:
Create AWS Integration in Encord
In the Integrations section of the Encord platform, click +New integration to create a new integration.
Select AWS S3 at the top of the chooser.
Create JSON file for Registration
Create a JSON file based on the templates provided below. imageMetadata
is optional unless you are using a client-only access integration.
The title
field is optional. If omitted, the image file path and name are used as the default title. For example, if the file is located at https://encord-solutions-bucket.s3.eu-west-2.amazonaws.com/path/to/my/bucket/image23.mp4
, the title defaults to /path/to/my/bucket/image23.jpg
.
Key or Flag | Required? | Default value |
---|---|---|
”objectUrl” | Yes | |
”title” | No | The file’s path + title |
”imageMetadata” | No | |
”clientMetadata” | No | |
”createVideo” | No | false |
imageMetadata
must be specified when a Strict client-only access integration is used. In all other cases, imageMetadata
is optional, but including it significantly reduces import times.Create a Folder to Store Your Images
All files in Encord must be stored within folders. Therefore, you need to create a folder before registering any data with Encord. To create a folder:
Give the folder a meaningful name and description.
Click Create to create the folder. The folder is listed in Files.
Upload Your Images to Encord
Create a Dataset
Select the folders containing the files you want to attach to the Dataset. To select individual files, double-click a folder to see its contents, and select the files you want to add to the Dataset.
Click Attach data to attach the selected files to the Dataset.
Create an Ontology
Create a new Ontology that includes:
A radio classification called “Animal” with two options: One called “Cat” the other called “Dog”.
Any other Objects you want to include in your Ontology.
Create Your Workflow template
Learn how to create Workflow templates here.
Create the following Workflow template by dragging the necessary components onto the canvas. For instructions on creating Workflows see our documentation here. Ensure your Agent node has the name “Agent 1”
Create a Project
If you are part of an Organization, an optional Project tags drop-down is visible. Project tags are useful for categorizing and finding your Projects. Select as many tags as are relevant for your Project.
Click the Attach ontology button.
Select the Ontology you created previously from the list using the Select button.
Click OK to attach the Ontology to the Project.
Click the Attach datasets button.
Select the Dataset you created previously from the list using the Attach button.
Select the template you want to use and click Load template.
Click Create project to finish creating the Project.
Create a python file called imagePreClassification.py
.
Paste the following script into imagePreClassification.py
replacing:
<your_openai_api_key>
with your OpenAI API key.<private_key_path>
with the path to your private key.<project_hash>
with the hash of the Project you created in STEP 2.imagePreClassification.py
.Run imagePreClassification.py
.
The script processes all images in the Dataset. If additional images are added, the script must be re-run to include them.
Now your annotators can start annotating images.
See our guide on how to label here.