Point to embeddings properly
Browse files- backend/runner/config.py +1 -1
- backend/runner/inference.py +22 -6
backend/runner/config.py
CHANGED
|
@@ -43,7 +43,7 @@ MARKER_DIR = DATA_READ_ROOT / "marker_output"
|
|
| 43 |
|
| 44 |
# Model-specific embedding directories
|
| 45 |
CLIP_EMBEDDINGS_DIR = EMBEDDINGS_DIR / "CLIP_Embeddings"
|
| 46 |
-
PAINTINGCLIP_EMBEDDINGS_DIR = EMBEDDINGS_DIR / "
|
| 47 |
|
| 48 |
# Model directories
|
| 49 |
PAINTINGCLIP_MODEL_DIR = MODELS_DIR / "PaintingClip"
|
|
|
|
| 43 |
|
| 44 |
# Model-specific embedding directories
|
| 45 |
CLIP_EMBEDDINGS_DIR = EMBEDDINGS_DIR / "CLIP_Embeddings"
|
| 46 |
+
PAINTINGCLIP_EMBEDDINGS_DIR = EMBEDDINGS_DIR / "PaintingCLIP_Embeddings"
|
| 47 |
|
| 48 |
# Model directories
|
| 49 |
PAINTINGCLIP_MODEL_DIR = MODELS_DIR / "PaintingClip"
|
backend/runner/inference.py
CHANGED
|
@@ -33,7 +33,8 @@ from .config import (
|
|
| 33 |
CLIP_EMBEDDINGS_DIR,
|
| 34 |
PAINTINGCLIP_EMBEDDINGS_DIR,
|
| 35 |
PAINTINGCLIP_MODEL_DIR,
|
| 36 |
-
SENTENCES_JSON
|
|
|
|
| 37 |
)
|
| 38 |
|
| 39 |
# βββ Configuration βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -443,14 +444,29 @@ def load_consolidated_embeddings(embedding_file: Path, metadata_file: Path):
|
|
| 443 |
def load_embeddings_for_model(model_type: str):
|
| 444 |
"""Load embeddings for the specified model type"""
|
| 445 |
if model_type == "clip":
|
| 446 |
-
|
| 447 |
-
|
|
|
|
| 448 |
else: # paintingclip
|
| 449 |
-
|
| 450 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 451 |
|
| 452 |
if not embedding_file.exists():
|
| 453 |
-
print(f"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 454 |
return None, None
|
| 455 |
|
|
|
|
|
|
|
|
|
|
| 456 |
return load_consolidated_embeddings(embedding_file, metadata_file)
|
|
|
|
| 33 |
CLIP_EMBEDDINGS_DIR,
|
| 34 |
PAINTINGCLIP_EMBEDDINGS_DIR,
|
| 35 |
PAINTINGCLIP_MODEL_DIR,
|
| 36 |
+
SENTENCES_JSON,
|
| 37 |
+
EMBEDDINGS_DIR # β Add this line
|
| 38 |
)
|
| 39 |
|
| 40 |
# βββ Configuration βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 444 |
def load_embeddings_for_model(model_type: str):
|
| 445 |
"""Load embeddings for the specified model type"""
|
| 446 |
if model_type == "clip":
|
| 447 |
+
# Consolidated files are in the root embeddings directory
|
| 448 |
+
embedding_file = EMBEDDINGS_DIR / "clip_embeddings_consolidated.pt"
|
| 449 |
+
metadata_file = EMBEDDINGS_DIR / "clip_embeddings_metadata.json"
|
| 450 |
else: # paintingclip
|
| 451 |
+
# Consolidated files are in the root embeddings directory
|
| 452 |
+
embedding_file = EMBEDDINGS_DIR / "paintingclip_embeddings_consolidated.pt"
|
| 453 |
+
metadata_file = EMBEDDINGS_DIR / "paintingclip_embeddings_metadata.json"
|
| 454 |
+
|
| 455 |
+
print(f"π Looking for embeddings at: {embedding_file}")
|
| 456 |
+
print(f"π Looking for metadata at: {metadata_file}")
|
| 457 |
|
| 458 |
if not embedding_file.exists():
|
| 459 |
+
print(f"β Consolidated embedding file not found: {embedding_file}")
|
| 460 |
+
print(f" Available files in embeddings directory:")
|
| 461 |
+
for file in EMBEDDINGS_DIR.iterdir():
|
| 462 |
+
print(f" - {file.name}")
|
| 463 |
+
return None, None
|
| 464 |
+
|
| 465 |
+
if not metadata_file.exists():
|
| 466 |
+
print(f"β Metadata file not found: {metadata_file}")
|
| 467 |
return None, None
|
| 468 |
|
| 469 |
+
print(f"β
Found embedding file: {embedding_file}")
|
| 470 |
+
print(f"β
Found metadata file: {metadata_file}")
|
| 471 |
+
|
| 472 |
return load_consolidated_embeddings(embedding_file, metadata_file)
|