Update app.py
Browse files
app.py
CHANGED
@@ -35,10 +35,13 @@ async def extract_features(file: UploadFile = File(...)):
|
|
35 |
image = Image.open(io.BytesIO(contents)).convert("RGB")
|
36 |
|
37 |
# Get feature embeddings
|
38 |
-
features = feature_extraction_pipeline(image)
|
|
|
|
|
|
|
39 |
|
40 |
# Return the embedding vector
|
41 |
-
return JSONResponse(content={"features":
|
42 |
|
43 |
except Exception as e:
|
44 |
raise HTTPException(status_code=500, detail=str(e))
|
|
|
35 |
image = Image.open(io.BytesIO(contents)).convert("RGB")
|
36 |
|
37 |
# Get feature embeddings
|
38 |
+
features = feature_extraction_pipeline(image) # Shape: (1, 577, 768)
|
39 |
+
|
40 |
+
# Extract CLS token embedding
|
41 |
+
cls_embedding = np.array(features)[0, 0, :] # Shape: (768,)
|
42 |
|
43 |
# Return the embedding vector
|
44 |
+
return JSONResponse(content={"features": cls_embedding.tolist()})
|
45 |
|
46 |
except Exception as e:
|
47 |
raise HTTPException(status_code=500, detail=str(e))
|