84 lines
No EOL
2.8 KiB
Bash
Executable file
84 lines
No EOL
2.8 KiB
Bash
Executable file
#!/bin/bash
|
||
# Visual AI QC - Headless Operation with cURL Examples
|
||
|
||
API_BASE="http://localhost:7183"
|
||
IMAGE_FILE="path/to/your/image.jpg"
|
||
|
||
echo "🤖 Visual AI QC - Headless cURL Examples"
|
||
echo "========================================"
|
||
|
||
# 1. Get available profiles
|
||
echo -e "\n📋 1. Get Available Profiles:"
|
||
curl -s "$API_BASE/api/profiles" | python -m json.tool
|
||
|
||
# 2. Get reference assets
|
||
echo -e "\n📁 2. Get Reference Assets:"
|
||
curl -s "$API_BASE/api/brand_guidelines" | python -m json.tool
|
||
|
||
# 3. Start async analysis
|
||
echo -e "\n🔍 3. Start Analysis (Update IMAGE_FILE path first!):"
|
||
echo "curl -X POST -F \"file=@$IMAGE_FILE\" \\"
|
||
echo " -F \"profile=diageo_key_visual\" \\"
|
||
echo " -F \"mode=json\" \\"
|
||
echo " -F \"reference_asset=Hellmanns_20250805_113413\" \\"
|
||
echo " \"$API_BASE/api/start_analysis\""
|
||
|
||
# Example response parsing
|
||
echo -e "\n# Example: Parse session ID and track progress"
|
||
echo "SESSION_ID=\$(curl -s -X POST -F \"file=@$IMAGE_FILE\" -F \"profile=diageo_key_visual\" \"$API_BASE/api/start_analysis\" | jq -r '.session_id')"
|
||
echo "echo \"Session ID: \$SESSION_ID\""
|
||
|
||
# 4. Check progress
|
||
echo -e "\n⏳ 4. Check Analysis Progress:"
|
||
echo "curl -s \"$API_BASE/api/progress/\$SESSION_ID\" | python -m json.tool"
|
||
|
||
# 5. Simple direct analysis (no progress tracking)
|
||
echo -e "\n🚀 5. Simple Direct Analysis:"
|
||
echo "curl -X POST -F \"file=@$IMAGE_FILE\" \\"
|
||
echo " -F \"profile=general_key_visual\" \\"
|
||
echo " -F \"mode=json\" \\"
|
||
echo " \"$API_BASE/api/analyze\" | python -m json.tool"
|
||
|
||
# 6. Brand detection
|
||
echo -e "\n🏷️ 6. Brand Detection:"
|
||
echo "curl -X POST -F \"file=@$IMAGE_FILE\" \\"
|
||
echo " \"$API_BASE/api/detect_brand\" | python -m json.tool"
|
||
|
||
# 7. List output files
|
||
echo -e "\n📄 7. List Generated Files:"
|
||
curl -s "$API_BASE/api/output_files" | python -m json.tool
|
||
|
||
# 8. Complete workflow example
|
||
echo -e "\n🔄 8. Complete Workflow Script:"
|
||
cat << 'EOF'
|
||
#!/bin/bash
|
||
# Complete headless analysis workflow
|
||
|
||
IMAGE="your_image.jpg"
|
||
API="http://localhost:7183"
|
||
|
||
# Start analysis
|
||
RESPONSE=$(curl -s -X POST -F "file=@$IMAGE" -F "profile=diageo_key_visual" -F "mode=json" "$API/api/start_analysis")
|
||
SESSION_ID=$(echo $RESPONSE | jq -r '.session_id')
|
||
|
||
echo "Analysis started: $SESSION_ID"
|
||
|
||
# Poll for completion
|
||
while true; do
|
||
PROGRESS=$(curl -s "$API/api/progress/$SESSION_ID")
|
||
STAGE=$(echo $PROGRESS | jq -r '.progress.stage')
|
||
|
||
if [ "$STAGE" = "complete" ]; then
|
||
echo "Analysis complete!"
|
||
echo $PROGRESS | jq '.progress.result.summary'
|
||
break
|
||
else
|
||
CURRENT=$(echo $PROGRESS | jq -r '.progress.current_check_display')
|
||
PERCENT=$(echo $PROGRESS | jq -r '.progress.percentage')
|
||
echo "Progress: $PERCENT% - $CURRENT"
|
||
sleep 2
|
||
fi
|
||
done
|
||
EOF
|
||
|
||
echo -e "\n✅ All examples ready! Update IMAGE_FILE path and run." |