|
|
import os
|
|
|
import sys
|
|
|
|
|
|
|
|
|
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
|
|
|
|
|
from core.models.vit_classifier import predict_dcrm_image
|
|
|
|
|
|
def test_remote_vit():
|
|
|
|
|
|
image_path = os.path.join(os.path.dirname(__file__), '..', 'temp_vit_plot.png')
|
|
|
|
|
|
if not os.path.exists(image_path):
|
|
|
print(f"Warning: {image_path} not found. Creating a dummy image.")
|
|
|
from PIL import Image
|
|
|
img = Image.new('RGB', (224, 224), color = 'red')
|
|
|
img.save(image_path)
|
|
|
|
|
|
print(f"Testing with image: {image_path}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
predicted_class, confidence, details = predict_dcrm_image(image_path)
|
|
|
|
|
|
print("\n--- Prediction Results ---")
|
|
|
print(f"Predicted Class: {predicted_class}")
|
|
|
print(f"Confidence: {confidence}")
|
|
|
print("\n--- Details ---")
|
|
|
print(f"ViT Probs (Source should be remote): {details.get('vit_probs')}")
|
|
|
print(f"Gemini Probs: {details.get('gemini_probs')}")
|
|
|
print(f"Ensemble Scores: {details.get('ensemble_scores')}")
|
|
|
|
|
|
if details.get('vit_probs'):
|
|
|
print("\nSUCCESS: Received probabilities from ViT.")
|
|
|
else:
|
|
|
print("\nFAILURE: No ViT probabilities received.")
|
|
|
|
|
|
except Exception as e:
|
|
|
print(f"\nERROR: {e}")
|
|
|
import traceback
|
|
|
traceback.print_exc()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
test_remote_vit()
|
|
|
|