Cuong2004 commited on
Commit
de5d894
·
1 Parent(s): 6695bc6

Fix Hugging Face deployment - Update dependencies and model URLs

Browse files
Files changed (3) hide show
  1. DEPLOYMENT_READY.md +17 -0
  2. README.md +18 -1
  3. test_requirements.py +101 -0
DEPLOYMENT_READY.md CHANGED
@@ -102,6 +102,23 @@ Trong `download_models.py`, thay `your-username` thành username thực:
102
  - Docker build sẽ cố gắng pre-download models
103
  - Fallback download trong runtime nếu build fail
104
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  ---
106
 
107
  **🎉 Package này đã sẵn sàng để deploy lên Hugging Face Spaces!**
 
102
  - Docker build sẽ cố gắng pre-download models
103
  - Fallback download trong runtime nếu build fail
104
 
105
+ ## 🛠️ Troubleshooting
106
+
107
+ ### Requirements Installation Issues
108
+ ```bash
109
+ # Test requirements locally trước khi deploy
110
+ python test_requirements.py
111
+
112
+ # Nếu fixed versions fail, sử dụng flexible versions
113
+ cp requirements-flexible.txt requirements.txt
114
+ ```
115
+
116
+ ### Common Issues:
117
+ - **MediaPipe version**: Đã update lên 0.10.21 (latest available)
118
+ - **Python version**: Dockerfile sử dụng Python 3.11 để tương thích
119
+ - **Dependencies conflicts**: Có fallback mechanism trong Dockerfile
120
+ - **System libraries**: Đã thêm đầy đủ OpenCV, MediaPipe dependencies
121
+
122
  ---
123
 
124
  **🎉 Package này đã sẵn sàng để deploy lên Hugging Face Spaces!**
README.md CHANGED
@@ -60,10 +60,27 @@ Thay `your-username` bằng username thực của bạn trong file `download_mod
60
 
61
  ### Bước 3: Deploy Space
62
  1. Tạo new Space trên https://huggingface.co/spaces
63
- 2. Chọn Docker SDK
64
  3. Upload tất cả files trong thư mục này
65
  4. Space sẽ tự động build và deploy
66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  ## 🔧 Kiến trúc hệ thống
68
 
69
  ### Quy trình xử lý:
 
60
 
61
  ### Bước 3: Deploy Space
62
  1. Tạo new Space trên https://huggingface.co/spaces
63
+ 2. Chọn Docker SDK
64
  3. Upload tất cả files trong thư mục này
65
  4. Space sẽ tự động build và deploy
66
 
67
+ ### 🛠️ Troubleshooting Build Issues
68
+
69
+ Nếu gặp lỗi dependencies:
70
+ ```bash
71
+ # Test requirements locally trước
72
+ python test_requirements.py
73
+
74
+ # Nếu cần, sử dụng flexible versions
75
+ cp requirements-flexible.txt requirements.txt
76
+ ```
77
+
78
+ **Common fixes:**
79
+ - Requirements đã được update với versions mới nhất
80
+ - Python 3.11 trong Docker để tương thích tốt hơn
81
+ - Fallback mechanism nếu fixed versions fail
82
+ - Đầy đủ system dependencies cho MediaPipe/OpenCV
83
+
84
  ## 🔧 Kiến trúc hệ thống
85
 
86
  ### Quy trình xử lý:
test_requirements.py ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Test requirements installation locally before deployment
4
+ """
5
+
6
+ import subprocess
7
+ import sys
8
+ import logging
9
+ from pathlib import Path
10
+
11
+ # Configure logging
12
+ logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s')
13
+ logger = logging.getLogger(__name__)
14
+
15
+ def test_pip_install(requirements_file):
16
+ """Test pip install with dry-run"""
17
+ try:
18
+ logger.info(f"🔍 Testing {requirements_file}...")
19
+
20
+ # Use --dry-run to test without actually installing
21
+ result = subprocess.run([
22
+ sys.executable, '-m', 'pip', 'install',
23
+ '--dry-run', '--no-deps', '-r', requirements_file
24
+ ], capture_output=True, text=True, timeout=60)
25
+
26
+ if result.returncode == 0:
27
+ logger.info(f"✅ {requirements_file} looks good!")
28
+ return True
29
+ else:
30
+ logger.error(f"❌ {requirements_file} has issues:")
31
+ logger.error(result.stderr)
32
+ return False
33
+
34
+ except subprocess.TimeoutExpired:
35
+ logger.error(f"❌ {requirements_file} test timed out")
36
+ return False
37
+ except Exception as e:
38
+ logger.error(f"❌ Error testing {requirements_file}: {e}")
39
+ return False
40
+
41
+ def check_available_versions():
42
+ """Check available versions for problematic packages"""
43
+ problematic_packages = ['mediapipe', 'tensorflow', 'torch']
44
+
45
+ for package in problematic_packages:
46
+ try:
47
+ logger.info(f"🔍 Checking available versions for {package}...")
48
+ result = subprocess.run([
49
+ sys.executable, '-m', 'pip', 'index', 'versions', package
50
+ ], capture_output=True, text=True, timeout=30)
51
+
52
+ if result.returncode == 0:
53
+ logger.info(f"✅ {package} versions available")
54
+ # Show first few lines
55
+ lines = result.stdout.split('\n')[:5]
56
+ for line in lines:
57
+ if line.strip():
58
+ logger.info(f" {line}")
59
+ else:
60
+ logger.warning(f"⚠️ Could not check {package} versions")
61
+
62
+ except Exception as e:
63
+ logger.warning(f"⚠️ Error checking {package}: {e}")
64
+
65
+ def main():
66
+ """Main test function"""
67
+ logger.info("🧪 Testing requirements installation...")
68
+ logger.info(f"🐍 Python version: {sys.version}")
69
+ logger.info("=" * 60)
70
+
71
+ # Test both requirements files
72
+ files_to_test = ['requirements.txt']
73
+ if Path('requirements-flexible.txt').exists():
74
+ files_to_test.append('requirements-flexible.txt')
75
+
76
+ success_count = 0
77
+ for req_file in files_to_test:
78
+ if Path(req_file).exists():
79
+ if test_pip_install(req_file):
80
+ success_count += 1
81
+ else:
82
+ logger.error(f"❌ {req_file} not found")
83
+
84
+ logger.info("\n" + "=" * 60)
85
+
86
+ if success_count > 0:
87
+ logger.info("✅ At least one requirements file is valid")
88
+ logger.info("💡 You can proceed with deployment")
89
+
90
+ # Show available versions for common problematic packages
91
+ logger.info("\n🔍 Checking package versions...")
92
+ check_available_versions()
93
+
94
+ return 0
95
+ else:
96
+ logger.error("❌ All requirements files have issues")
97
+ logger.info("💡 Try updating package versions or use more flexible ranges")
98
+ return 1
99
+
100
+ if __name__ == "__main__":
101
+ sys.exit(main())