Spaces:
Sleeping
Sleeping
Download tests/test_gemini_vision.py from Presight-AI/app: direct link, hf CLI and curl.
- Browser
- Download file 1.46 kB
-
https://huggingface.co/spaces/Presight-AI/app/resolve/main/tests/test_gemini_vision.py
- Command line
-
hf download hf://spaces/Presight-AI/app/tests/test_gemini_vision.py
-
curl -L -o test_gemini_vision.py https://huggingface.co/spaces/Presight-AI/app/resolve/main/tests/test_gemini_vision.py
1.46 kB
| import os | |
| import sys | |
| import asyncio | |
| from pathlib import Path | |
| # Add project root to path | |
| sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
| from backend.gemini_analyzer import GeminiPrescriptionAnalyzer | |
| import pytest | |
| async def test_vision(): | |
| print("🧪 Testing Gemini Vision Integration...") | |
| # Use the default key from the code or env | |
| api_key = os.getenv('GEMINI_API_KEY', 'AIzaSyD72bMoC9tuQyz2QZTWEQqaM2TXk4M_wI0') | |
| analyzer = GeminiPrescriptionAnalyzer(api_key=api_key) | |
| image_path = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "sample_prescriptions", "sample_prescription.jpg") | |
| if not os.path.exists(image_path): | |
| print(f"❌ Sample image not found at {image_path}") | |
| return | |
| print(f"📸 Analyzing image: {image_path}") | |
| try: | |
| # Test with image path | |
| result = analyzer.analyze_prescription(raw_text="OCR failed", image_path=image_path) | |
| print("\n✅ Analysis Result:") | |
| print(f"Patient: {result.patient_name}") | |
| print(f"Medicines: {len(result.medicines)}") | |
| for med in result.medicines: | |
| print(f" - {med.name} ({med.strength})") | |
| print(f"\nConfidence: {result.analysis_confidence}") | |
| except Exception as e: | |
| print(f"❌ Test failed: {e}") | |
| if __name__ == "__main__": | |
| asyncio.run(test_vision()) | |