Spaces:
Sleeping
Sleeping
| import os | |
| import sys | |
| # Add current directory to path so we can import app | |
| sys.path.append(r"f:\BRATS\Interface") | |
| from app import get_available_models, run_inference | |
| def main(): | |
| image_path = r"f:\BRATS\Interface\Image\BraTS20_Training_001_flair_slice77.png" | |
| result_dir = r"f:\BRATS\Interface\static\results" | |
| if not os.path.exists(result_dir): | |
| os.makedirs(result_dir) | |
| models = get_available_models() | |
| results = [] | |
| print(f"Found models: {models}") | |
| print(f"Testing with image: {image_path}") | |
| print("-" * 40) | |
| for model in models: | |
| result_path = os.path.join(result_dir, f"test_result_{model}.png") | |
| print(f"Testing model: {model}...") | |
| try: | |
| detected, confidence = run_inference(image_path, result_path, model) | |
| results.append({ | |
| "model": model, | |
| "detected": detected, | |
| "confidence": confidence, | |
| "result_path": result_path | |
| }) | |
| print(f" -> Detected: {detected}, Confidence: {confidence:.2f}%") | |
| except Exception as e: | |
| print(f" -> Error with model {model}: {e}") | |
| # Rank the models based on confidence | |
| results.sort(key=lambda x: x["confidence"], reverse=True) | |
| print("\n" + "=" * 60) | |
| print(" Model Ranking (Best to Worst based on Confidence)") | |
| print("=" * 60) | |
| for i, res in enumerate(results, 1): | |
| print(f"{i}. {res['model']} | Detected: {res['detected']} | Confidence: {res['confidence']:.2f}%") | |
| if __name__ == "__main__": | |
| main() | |