|
|
|
|
|
""" |
|
|
Test script for TRIQA Hugging Face demo |
|
|
Run this to test the demo locally before uploading |
|
|
""" |
|
|
|
|
|
import os |
|
|
import sys |
|
|
|
|
|
def test_demo(): |
|
|
"""Test the demo components.""" |
|
|
print("Testing TRIQA Hugging Face Demo...") |
|
|
|
|
|
|
|
|
required_files = [ |
|
|
'app.py', |
|
|
'convnext_original.py', |
|
|
'convnext_finetune.py', |
|
|
'requirements.txt', |
|
|
'package.json' |
|
|
] |
|
|
|
|
|
missing_files = [] |
|
|
for file in required_files: |
|
|
if not os.path.exists(file): |
|
|
missing_files.append(file) |
|
|
|
|
|
if missing_files: |
|
|
print(f"❌ Missing files: {missing_files}") |
|
|
return False |
|
|
|
|
|
print("✅ All required files present") |
|
|
|
|
|
|
|
|
model_files = [ |
|
|
'feature_models/convnext_tiny_22k_224.pth', |
|
|
'feature_models/triqa_quality_aware.pth', |
|
|
'Regression_Models/KonIQ_scaler.save', |
|
|
'Regression_Models/KonIQ_TRIQA.save' |
|
|
] |
|
|
|
|
|
missing_models = [] |
|
|
for file in model_files: |
|
|
if not os.path.exists(file): |
|
|
missing_models.append(file) |
|
|
|
|
|
if missing_models: |
|
|
print(f"⚠️ Missing model files: {missing_models}") |
|
|
print(" Download from Box: https://utexas.box.com/s/8aw6axc2lofouja65uc726lca8b1cduf") |
|
|
else: |
|
|
print("✅ All model files present") |
|
|
|
|
|
|
|
|
sample_dir = 'sample_image' |
|
|
if os.path.exists(sample_dir): |
|
|
sample_files = os.listdir(sample_dir) |
|
|
if sample_files: |
|
|
print(f"✅ Sample images present: {len(sample_files)} files") |
|
|
else: |
|
|
print("⚠️ No sample images found") |
|
|
else: |
|
|
print("⚠️ Sample image directory not found") |
|
|
|
|
|
print("\nDemo test complete!") |
|
|
print("If all files are present, you can upload to Hugging Face Spaces.") |
|
|
|
|
|
return len(missing_files) == 0 |
|
|
|
|
|
if __name__ == "__main__": |
|
|
test_demo() |
|
|
|