- Frontend v4 accessible sur réseau local (192.168.1.40) - Ports ouverts: 3002 (frontend), 5001 (backend), 5004 (dashboard) - Ollama GPU fonctionnel - Self-healing interactif - Dashboard confiance Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
54 lines
1.6 KiB
Python
Executable File
54 lines
1.6 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Test de persistence FAISS"""
|
|
import sys
|
|
from pathlib import Path
|
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
|
|
from core.embedding.clip_embedder import CLIPEmbedder
|
|
from core.embedding.faiss_manager import FAISSManager
|
|
from PIL import Image
|
|
|
|
print("="*70)
|
|
print(" TEST PERSISTENCE FAISS")
|
|
print("="*70)
|
|
|
|
# 1. Créer index
|
|
print("\n1. Création index...")
|
|
clip = CLIPEmbedder()
|
|
faiss = FAISSManager(dimensions=512, metric="cosine")
|
|
|
|
# 2. Ajouter embeddings
|
|
print("2. Ajout embeddings...")
|
|
for i, color in enumerate([(255,0,0), (0,255,0), (0,0,255)]):
|
|
img = Image.new('RGB', (224, 224), color=color)
|
|
emb = clip.embed_image(img)
|
|
faiss.add_embedding(f"img_{i}", emb, {"color": str(color)})
|
|
|
|
print(f"✓ {faiss.get_stats()['total_vectors']} vecteurs")
|
|
|
|
# 3. Sauvegarder
|
|
print("\n3. Sauvegarde...")
|
|
index_path = Path("data/faiss_index/test_index.index")
|
|
meta_path = Path("data/faiss_index/test_index.metadata")
|
|
faiss.save(index_path, meta_path)
|
|
print(f"✓ Sauvegardé: {index_path}")
|
|
|
|
# 4. Charger
|
|
print("\n4. Chargement...")
|
|
faiss2 = FAISSManager.load(index_path, meta_path)
|
|
print(f"✓ Chargé: {faiss2.get_stats()['total_vectors']} vecteurs")
|
|
|
|
# 5. Vérifier
|
|
print("\n5. Vérification...")
|
|
img_test = Image.new('RGB', (224, 224), color=(255,0,0))
|
|
emb_test = clip.embed_image(img_test)
|
|
results = faiss2.search_similar(emb_test, k=1)
|
|
print(f"✓ Recherche: {results[0].metadata['color']}")
|
|
|
|
print("\n" + "="*70)
|
|
print("✅ PERSISTENCE FAISS FONCTIONNELLE")
|
|
print("="*70)
|
|
print(f"\nFichiers créés:")
|
|
print(f" - {index_path}")
|
|
print(f" - {meta_path}")
|