github-actions[bot]
commited on
Commit
·
3c55f2b
1
Parent(s):
f37773a
Sync from GitHub: ba056c7a94990d2798b5f09905c694ae76fe7ff7
Browse files- .gitignore +12 -3
- Dockerfile +4 -1
- utils/image_enhancer.py +23 -8
.gitignore
CHANGED
|
@@ -31,12 +31,21 @@ htmlcov/
|
|
| 31 |
frontend/node_modules/
|
| 32 |
frontend/.env.local
|
| 33 |
|
|
|
|
| 34 |
*.md
|
| 35 |
!README_git.md
|
| 36 |
!README.md
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
executable.py
|
| 39 |
client_example.py
|
| 40 |
-
Docs
|
| 41 |
|
| 42 |
-
|
|
|
|
|
|
| 31 |
frontend/node_modules/
|
| 32 |
frontend/.env.local
|
| 33 |
|
| 34 |
+
# Documentation (keep essential ones)
|
| 35 |
*.md
|
| 36 |
!README_git.md
|
| 37 |
!README.md
|
| 38 |
+
DEPLOYMENT.md
|
| 39 |
+
HF_DEPLOYMENT_READY.md
|
| 40 |
+
IMAGE_ENHANCEMENT.md
|
| 41 |
+
|
| 42 |
+
# Test files and docs
|
| 43 |
+
test_*.py
|
| 44 |
+
Docs/
|
| 45 |
+
|
| 46 |
+
# Executables and examples
|
| 47 |
executable.py
|
| 48 |
client_example.py
|
|
|
|
| 49 |
|
| 50 |
+
# Real-ESRGAN downloaded binaries (will be installed via Docker)
|
| 51 |
+
utils/realesrgan/
|
Dockerfile
CHANGED
|
@@ -49,7 +49,10 @@ RUN mkdir -p /app/utils/realesrgan && \
|
|
| 49 |
rm realesrgan-ncnn-vulkan-v0.2.0-ubuntu.zip && \
|
| 50 |
find . -name "realesrgan-ncnn-vulkan" -type f -exec chmod +x {} \; && \
|
| 51 |
mv realesrgan-ncnn-vulkan-v0.2.0-ubuntu/* . 2>/dev/null || true && \
|
| 52 |
-
rmdir realesrgan-ncnn-vulkan-v0.2.0-ubuntu 2>/dev/null || true
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
# Expose Hugging Face Spaces default port
|
| 55 |
EXPOSE 7860
|
|
|
|
| 49 |
rm realesrgan-ncnn-vulkan-v0.2.0-ubuntu.zip && \
|
| 50 |
find . -name "realesrgan-ncnn-vulkan" -type f -exec chmod +x {} \; && \
|
| 51 |
mv realesrgan-ncnn-vulkan-v0.2.0-ubuntu/* . 2>/dev/null || true && \
|
| 52 |
+
rmdir realesrgan-ncnn-vulkan-v0.2.0-ubuntu 2>/dev/null || true && \
|
| 53 |
+
echo "Real-ESRGAN installed at /app/utils/realesrgan/" && \
|
| 54 |
+
ls -la /app/utils/realesrgan/ && \
|
| 55 |
+
test -f /app/utils/realesrgan/realesrgan-ncnn-vulkan && echo "✓ Executable found" || echo "✗ Executable NOT found"
|
| 56 |
|
| 57 |
# Expose Hugging Face Spaces default port
|
| 58 |
EXPOSE 7860
|
utils/image_enhancer.py
CHANGED
|
@@ -74,16 +74,31 @@ class ImageEnhancer:
|
|
| 74 |
possible_paths = [
|
| 75 |
self.enhancer_dir / exe_name,
|
| 76 |
self.enhancer_dir / "realesrgan-ncnn-vulkan" / exe_name,
|
|
|
|
| 77 |
]
|
| 78 |
|
| 79 |
for path in possible_paths:
|
| 80 |
-
if path.exists():
|
| 81 |
self.executable_path = path
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
return False
|
| 89 |
|
|
@@ -150,8 +165,8 @@ class ImageEnhancer:
|
|
| 150 |
"-f", "png" # Output format
|
| 151 |
]
|
| 152 |
|
| 153 |
-
# Add model path if available
|
| 154 |
-
if self.models_path:
|
| 155 |
cmd.extend(["-m", str(self.models_path)])
|
| 156 |
|
| 157 |
# Run enhancement
|
|
|
|
| 74 |
possible_paths = [
|
| 75 |
self.enhancer_dir / exe_name,
|
| 76 |
self.enhancer_dir / "realesrgan-ncnn-vulkan" / exe_name,
|
| 77 |
+
self.enhancer_dir / "realesrgan-ncnn-vulkan-v0.2.0-ubuntu" / exe_name,
|
| 78 |
]
|
| 79 |
|
| 80 |
for path in possible_paths:
|
| 81 |
+
if path.exists() and (path.stat().st_mode & 0o111 or platform.system() == "Windows"):
|
| 82 |
self.executable_path = path
|
| 83 |
+
print(f" Found executable: {path}")
|
| 84 |
+
|
| 85 |
+
# Look for models directory in multiple locations
|
| 86 |
+
possible_model_dirs = [
|
| 87 |
+
path.parent / "models",
|
| 88 |
+
self.enhancer_dir / "models",
|
| 89 |
+
]
|
| 90 |
+
|
| 91 |
+
for models_dir in possible_model_dirs:
|
| 92 |
+
if models_dir.exists():
|
| 93 |
+
self.models_path = models_dir
|
| 94 |
+
print(f" Found models: {models_dir}")
|
| 95 |
+
return True
|
| 96 |
+
|
| 97 |
+
# Even without models directory, if executable exists, mark as available
|
| 98 |
+
# Models can be specified via -n parameter
|
| 99 |
+
print(f" Models directory not found, but executable is available")
|
| 100 |
+
self.models_path = path.parent / "models" # Set expected path
|
| 101 |
+
return True
|
| 102 |
|
| 103 |
return False
|
| 104 |
|
|
|
|
| 165 |
"-f", "png" # Output format
|
| 166 |
]
|
| 167 |
|
| 168 |
+
# Add model path if available and exists
|
| 169 |
+
if self.models_path and self.models_path.exists():
|
| 170 |
cmd.extend(["-m", str(self.models_path)])
|
| 171 |
|
| 172 |
# Run enhancement
|