Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,20 +27,21 @@ def process_image(image):
|
|
| 27 |
if not isinstance(image, Image.Image):
|
| 28 |
image = Image.fromarray(image)
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
|
|
|
| 32 |
return_tensors="pt"
|
| 33 |
).to(model.device)
|
| 34 |
|
| 35 |
logger.info("Generating embeddings")
|
| 36 |
with torch.no_grad():
|
| 37 |
outputs = model(**inputs)
|
| 38 |
-
embeddings = outputs.
|
| 39 |
|
| 40 |
logger.info(f"Embeddings shape: {embeddings.shape}")
|
| 41 |
return {
|
| 42 |
-
"
|
| 43 |
-
"
|
| 44 |
}
|
| 45 |
except Exception as e:
|
| 46 |
logger.error(f"Error: {str(e)}", exc_info=True)
|
|
|
|
| 27 |
if not isinstance(image, Image.Image):
|
| 28 |
image = Image.fromarray(image)
|
| 29 |
|
| 30 |
+
# Process image with proper settings
|
| 31 |
+
inputs = processor.process_images( # Changed from processor()
|
| 32 |
+
images=[image],
|
| 33 |
return_tensors="pt"
|
| 34 |
).to(model.device)
|
| 35 |
|
| 36 |
logger.info("Generating embeddings")
|
| 37 |
with torch.no_grad():
|
| 38 |
outputs = model(**inputs)
|
| 39 |
+
embeddings = outputs.cpu().numpy()
|
| 40 |
|
| 41 |
logger.info(f"Embeddings shape: {embeddings.shape}")
|
| 42 |
return {
|
| 43 |
+
"mixed_embedding_p1": embeddings[0, :1024].tolist(),
|
| 44 |
+
"mixed_embedding_p2": embeddings[0, 1024:].tolist(),
|
| 45 |
}
|
| 46 |
except Exception as e:
|
| 47 |
logger.error(f"Error: {str(e)}", exc_info=True)
|