dots-ocr-idcard / scripts /test_hf_dots_ocr_curl.sh
tommulder's picture
chore(repo): add model artifacts tracked by Git LFS; add scripts\n\n- enable model/** via .gitignore override\n- ensure Git LFS patterns for *.safetensors and other ML artifacts\n- add testing scripts for HF Space and curl
f4349d6
raw
history blame
2.38 kB
#!/bin/bash
# Test script for Hugging Face Dots-OCR Space API using curl
HF_SPACE_URL="https://algoryn-dots-ocr-idcard.hf.space"
echo "πŸš€ Testing Hugging Face Dots-OCR Space API"
echo "=========================================="
# Test 1: Health check
echo ""
echo "1️⃣ Testing health check..."
curl -s "${HF_SPACE_URL}/health" | jq '.' 2>/dev/null || curl -s "${HF_SPACE_URL}/health"
# Test 2: OCR extraction (if demo image exists)
DEMO_IMAGE="data/demo/tom_id_card_front.jpg"
if [ -f "$DEMO_IMAGE" ]; then
echo ""
echo "2️⃣ Testing OCR extraction with $DEMO_IMAGE..."
curl -X POST "${HF_SPACE_URL}/v1/id/ocr" \
-F "file=@$DEMO_IMAGE" | jq '.' 2>/dev/null || echo "Response received (install jq for pretty JSON)"
# Test 3: OCR with ROI (top half of image)
echo ""
echo "3️⃣ Testing OCR with ROI (top half)..."
curl -X POST "${HF_SPACE_URL}/v1/id/ocr" \
-F "file=@$DEMO_IMAGE" \
-F 'roi={"x1": 0.0, "y1": 0.0, "x2": 1.0, "y2": 0.5}' | jq '.' 2>/dev/null || echo "Response received (install jq for pretty JSON)"
# Test 4: OCR with ROI (center region)
echo ""
echo "4️⃣ Testing OCR with ROI (center region)..."
curl -X POST "${HF_SPACE_URL}/v1/id/ocr" \
-F "file=@$DEMO_IMAGE" \
-F 'roi={"x1": 0.25, "y1": 0.25, "x2": 0.75, "y2": 0.75}' | jq '.' 2>/dev/null || echo "Response received (install jq for pretty JSON)"
else
echo ""
echo "2️⃣ No demo image found at $DEMO_IMAGE"
echo "πŸ’‘ Place a test image in the data/demo/ directory"
fi
echo ""
echo "πŸŽ‰ Testing complete!"
echo ""
echo "πŸ’‘ To test with your own files:"
echo " curl -X POST \"${HF_SPACE_URL}/v1/id/ocr\" -F \"file=@your_image.jpg\""
echo ""
echo "πŸ’‘ To test with ROI:"
echo " curl -X POST \"${HF_SPACE_URL}/v1/id/ocr\" -F \"file=@your_image.jpg\" -F 'roi={\"x1\": 0.0, \"y1\": 0.0, \"x2\": 0.5, \"y2\": 0.5}'"
echo ""
echo "πŸ’‘ Available ROI examples:"
echo " Full image: no roi parameter"
echo " Top half: {\"x1\": 0.0, \"y1\": 0.0, \"x2\": 1.0, \"y2\": 0.5}"
echo " Bottom half: {\"x1\": 0.0, \"y1\": 0.5, \"x2\": 1.0, \"y2\": 1.0}"
echo " Center: {\"x1\": 0.25, \"y1\": 0.25, \"x2\": 0.75, \"y2\": 0.75}"
echo " Left side: {\"x1\": 0.0, \"y1\": 0.0, \"x2\": 0.5, \"y2\": 1.0}"
echo " Right side: {\"x1\": 0.5, \"y1\": 0.0, \"x2\": 1.0, \"y2\": 1.0}"