Files
Geniusia_v2/archive/old_tests/test_qwen_image.py
2026-03-05 00:20:25 +01:00

102 lines
2.6 KiB
Python
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/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)