102 lines
2.6 KiB
Python
102 lines
2.6 KiB
Python
#!/usr/bin/env python3
|
||
"""
|
||
Test de Qwen3-VL avec une image réelle
|
||
"""
|
||
|
||
import sys
|
||
sys.path.insert(0, 'geniusia2')
|
||
|
||
from core.llm_manager import LLMManager
|
||
import cv2
|
||
import numpy as np
|
||
|
||
print("=" * 60)
|
||
print("🧪 TEST QWEN3-VL AVEC IMAGE")
|
||
print("=" * 60)
|
||
|
||
# 1. Charger l'image
|
||
print("\n1️⃣ Chargement de l'image...")
|
||
image_path = "geniusia2/thumb_Lac_d_Annecy-vue_panoramique.jpeg"
|
||
try:
|
||
image = cv2.imread(image_path)
|
||
if image is None:
|
||
print(f"❌ Impossible de charger l'image: {image_path}")
|
||
sys.exit(1)
|
||
print(f"✅ Image chargée: {image.shape}")
|
||
except Exception as e:
|
||
print(f"❌ Erreur: {e}")
|
||
sys.exit(1)
|
||
|
||
# 2. Initialiser le LLM Manager
|
||
print("\n2️⃣ Initialisation du LLM Manager...")
|
||
try:
|
||
llm = LLMManager(model_name="qwen3-vl:8b")
|
||
print(f"✅ LLM Manager créé")
|
||
except Exception as e:
|
||
print(f"❌ Erreur: {e}")
|
||
sys.exit(1)
|
||
|
||
# 3. Vérifier la disponibilité
|
||
print("\n3️⃣ Vérification de la disponibilité...")
|
||
try:
|
||
available = llm.is_available()
|
||
print(f"Disponible: {available}")
|
||
if not available:
|
||
print("❌ Ollama n'est pas disponible")
|
||
print("💡 Lance Ollama avec: ollama serve")
|
||
sys.exit(1)
|
||
print("✅ Ollama est disponible")
|
||
except Exception as e:
|
||
print(f"❌ Erreur: {e}")
|
||
sys.exit(1)
|
||
|
||
# 4. Test sans image (texte seul)
|
||
print("\n4️⃣ Test sans image (texte seul)...")
|
||
try:
|
||
response = llm.generate_with_vision(
|
||
prompt="Réponds juste 'OK'",
|
||
images=None
|
||
)
|
||
print(f"Réponse: '{response}'")
|
||
print(f"Longueur: {len(response)}")
|
||
if response and len(response) > 0:
|
||
print("✅ Génération texte fonctionne")
|
||
else:
|
||
print("⚠️ Réponse vide")
|
||
except Exception as e:
|
||
print(f"❌ Erreur: {e}")
|
||
import traceback
|
||
traceback.print_exc()
|
||
|
||
# 5. Test avec l'image
|
||
print("\n5️⃣ Test avec l'image...")
|
||
try:
|
||
prompt = "Décris moi l'image en 1 phrase"
|
||
print(f"Prompt: {prompt}")
|
||
print(f"Image shape: {image.shape}")
|
||
|
||
response = llm.generate_with_vision(
|
||
prompt=prompt,
|
||
images=[image]
|
||
)
|
||
|
||
print(f"\n📝 Réponse complète:")
|
||
print("-" * 60)
|
||
print(response)
|
||
print("-" * 60)
|
||
print(f"Longueur: {len(response)} caractères")
|
||
|
||
if response and len(response) > 5:
|
||
print("✅ Génération avec image fonctionne")
|
||
else:
|
||
print("⚠️ Réponse trop courte ou vide")
|
||
|
||
except Exception as e:
|
||
print(f"❌ Erreur: {e}")
|
||
import traceback
|
||
traceback.print_exc()
|
||
|
||
print("\n" + "=" * 60)
|
||
print("✅ Test terminé")
|
||
print("=" * 60)
|