S-Rajesh commited on
Commit
a591ec3
·
verified ·
1 Parent(s): 1bfcc88

Upload test_demo.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. test_demo.py +70 -0
test_demo.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Test script for TRIQA Hugging Face demo
4
+ Run this to test the demo locally before uploading
5
+ """
6
+
7
+ import os
8
+ import sys
9
+
10
+ def test_demo():
11
+ """Test the demo components."""
12
+ print("Testing TRIQA Hugging Face Demo...")
13
+
14
+ # Check if required files exist
15
+ required_files = [
16
+ 'app.py',
17
+ 'convnext_original.py',
18
+ 'convnext_finetune.py',
19
+ 'requirements.txt',
20
+ 'package.json'
21
+ ]
22
+
23
+ missing_files = []
24
+ for file in required_files:
25
+ if not os.path.exists(file):
26
+ missing_files.append(file)
27
+
28
+ if missing_files:
29
+ print(f"❌ Missing files: {missing_files}")
30
+ return False
31
+
32
+ print("✅ All required files present")
33
+
34
+ # Check if model files exist
35
+ model_files = [
36
+ 'feature_models/convnext_tiny_22k_224.pth',
37
+ 'feature_models/triqa_quality_aware.pth',
38
+ 'Regression_Models/KonIQ_scaler.save',
39
+ 'Regression_Models/KonIQ_TRIQA.save'
40
+ ]
41
+
42
+ missing_models = []
43
+ for file in model_files:
44
+ if not os.path.exists(file):
45
+ missing_models.append(file)
46
+
47
+ if missing_models:
48
+ print(f"⚠️ Missing model files: {missing_models}")
49
+ print(" Download from Box: https://utexas.box.com/s/8aw6axc2lofouja65uc726lca8b1cduf")
50
+ else:
51
+ print("✅ All model files present")
52
+
53
+ # Check if sample images exist
54
+ sample_dir = 'sample_image'
55
+ if os.path.exists(sample_dir):
56
+ sample_files = os.listdir(sample_dir)
57
+ if sample_files:
58
+ print(f"✅ Sample images present: {len(sample_files)} files")
59
+ else:
60
+ print("⚠️ No sample images found")
61
+ else:
62
+ print("⚠️ Sample image directory not found")
63
+
64
+ print("\nDemo test complete!")
65
+ print("If all files are present, you can upload to Hugging Face Spaces.")
66
+
67
+ return len(missing_files) == 0
68
+
69
+ if __name__ == "__main__":
70
+ test_demo()