Recipe Instructions and Validations 📋
Welcome to the guide on recipe instructions and validations in Dataloop! Let's explore how to set up instructions and validation rules for your annotation tasks.
PDF Instructions 📄
Dataloop allows you to provide clear guidance to your annotation team through PDF instructions:
import dtlpy as dl
# Get your recipe
recipe = dataset.recipes.get(recipe_id='your-recipe-id')
# Upload annotation instructions
recipe.add_instruction(annotation_instruction_file='/path/to/instructions.pdf')
When creating tasks, you can specify which pages from these PDFs should be shown to annotators.
📚 Learn more about PDF Instructions
Annotation Validation with JavaScript 🔍
Add validation rules to ensure annotation quality using JavaScript. Here's a simple example:
function validateAnnotations(annotationsArr) {
let result = {
ok: true,
errorMessage: "",
errors: {}
}
// Example: Ensure at least one annotation exists
if (annotationsArr.length === 0) {
result.ok = false;
result.errorMessage = "Item must have at least one annotation";
}
return result;
}
Adding a JS validation script to a recipe:
recipe.upload_annotations_verification_file(local_path='/path/to/validation_script.js')
Common Validation Use Cases:
🎯 Label Coexistence
// Example: Only one person per image if (annotations.filter(a => a.label === 'person').length > 1) { result.ok = false; result.errorMessage = "Only one person allowed per image"; }
📐 Geometry Rules
// Example: Ensure polygon has minimum points if (a.type === 'segment' && a._def[0].length < 4) { result.ok = false; result.errors[a.clientId] = "Polygon must have at least 4 points"; }
Key Points:
- Validation runs when annotators click the "Complete" button
- Scripts must follow the required format with
validateAnnotations
function - Can validate label combinations, geometry, attributes, and more
- Supports detailed error messages per annotation
📚 Learn more about Annotation Validation
Best Practices 💡
- 📝 Keep instructions clear and concise
- 🎯 Include visual examples in PDF instructions
- 🔍 Test validation rules thoroughly
- ⚡ Keep validation logic simple and efficient
- 🐛 Use console.log for debugging validation scripts
Need More Help? 🤔
Happy validating! 🚀