Spaces:
Running
Running
File size: 1,426 Bytes
76d0495 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 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)}")
# EfficientNetV2-S embedding dimension should be 1280
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()
|