| |
| """ |
| Test script to verify YOLO seal detection works with the fixes |
| """ |
| import requests |
| import json |
|
|
| |
| print("=" * 60) |
| print("Testing /health endpoint...") |
| print("=" * 60) |
| try: |
| response = requests.get("http://localhost:8000/health", timeout=10) |
| print(f"Status Code: {response.status_code}") |
| print(f"Response: {json.dumps(response.json(), indent=2)}") |
| except Exception as e: |
| print(f"Error: {e}") |
|
|
| print("\n" + "=" * 60) |
| print("To test YOLO detection, you need to:") |
| print("1. Have a certificate image ready") |
| print("2. Run the following curl command:") |
| print("=" * 60) |
| print(""" |
| curl -X POST "http://localhost:8000/api/verify?return_image=true" \\ |
| -F "file=@/path/to/your/certificate.jpg" \\ |
| -F "certificate_id=TEST123" \\ |
| -F "student_name=Test Student" |
| """) |
| print("=" * 60) |
| print("\nOr use this Python code:") |
| print("=" * 60) |
| print(""" |
| import requests |
| |
| with open('/path/to/certificate.jpg', 'rb') as f: |
| files = {'file': f} |
| data = { |
| 'certificate_id': 'TEST123', |
| 'student_name': 'Test Student' |
| } |
| response = requests.post( |
| 'http://localhost:8000/api/verify?return_image=true', |
| files=files, |
| data=data |
| ) |
| result = response.json() |
| print(f"Total seals detected: {result['seal_verification']['total_seals']}") |
| print(f"Seal status: {result['seal_verification']['seal_status']}") |
| if 'annotated_image_url' in result: |
| print("✓ Annotated image generated successfully!") |
| else: |
| print("✗ No annotated image (no seals detected)") |
| """) |
|
|