| import requests |
| import os |
|
|
| def test_image_embedding(): |
| url = "http://localhost:8000/image_embedding/image_to_embedding" |
| image_path = r"C:\Users\itg\.gemini\antigravity\brain\a2d1bd2b-b329-461a-ab89-c0d64934f5fb\test_image_for_embedding_1772686600102.png" |
| |
| if not os.path.exists(image_path): |
| print(f"Error: {image_path} not found.") |
| return |
|
|
| with open(image_path, "rb") as f: |
| files = {"file": (image_path, f, "image/png")} |
| try: |
| response = requests.post(url, files=files) |
| if response.status_code == 200: |
| result = response.json() |
| if result["success"]: |
| embedding = result["data"]["embedding"] |
| print(f"Successfully retrieved embedding. Dimension: {len(embedding)}") |
| |
| if len(embedding) == 1280: |
| print("Verification PASSED: Embedding dimension is 1280.") |
| else: |
| print(f"Verification FAILED: Expected dimension 1280, got {len(embedding)}.") |
| else: |
| print(f"API Error: {result['msg']}") |
| else: |
| print(f"HTTP Error: {response.status_code}") |
| except Exception as e: |
| print(f"Request failed: {e}") |
|
|
| if __name__ == "__main__": |
| test_image_embedding() |
|
|