Spaces:
Sleeping
Sleeping
IZERE HIRWA Roger
commited on
Commit
·
9f2a24a
1
Parent(s):
7543760
kko
Browse files- Dockerfile +4 -0
- app.py +45 -11
- requirements.txt +2 -0
Dockerfile
CHANGED
|
@@ -30,6 +30,10 @@ RUN wget -P /app/SadTalker/checkpoints \
|
|
| 30 |
# Copy application files
|
| 31 |
COPY . .
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
# Add SadTalker to Python path
|
| 34 |
ENV PYTHONPATH="${PYTHONPATH}:/app/SadTalker/src"
|
| 35 |
|
|
|
|
| 30 |
# Copy application files
|
| 31 |
COPY . .
|
| 32 |
|
| 33 |
+
# Create necessary directories with proper permissions
|
| 34 |
+
RUN mkdir -p /app/static/uploads && chmod -R 777 /app/static
|
| 35 |
+
RUN mkdir -p /app/templates && chmod -R 777 /app/templates
|
| 36 |
+
|
| 37 |
# Add SadTalker to Python path
|
| 38 |
ENV PYTHONPATH="${PYTHONPATH}:/app/SadTalker/src"
|
| 39 |
|
app.py
CHANGED
|
@@ -4,19 +4,41 @@ sys.path.append('/app/SadTalker/src')
|
|
| 4 |
|
| 5 |
from flask import Flask, render_template, request, jsonify, send_from_directory
|
| 6 |
|
| 7 |
-
# app = Flask(__name__, static_folder='static', static_url_path='/static')
|
| 8 |
app = Flask(__name__)
|
| 9 |
|
| 10 |
# Initialize SadTalker with proper import
|
|
|
|
| 11 |
try:
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
sadtalker = None
|
| 21 |
|
| 22 |
@app.route('/')
|
|
@@ -87,6 +109,18 @@ def static_files(filename):
|
|
| 87 |
return send_from_directory(app.static_folder, filename)
|
| 88 |
|
| 89 |
if __name__ == '__main__':
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
-
app.run(host='0.0.0.0', port=7860)
|
|
|
|
| 4 |
|
| 5 |
from flask import Flask, render_template, request, jsonify, send_from_directory
|
| 6 |
|
|
|
|
| 7 |
app = Flask(__name__)
|
| 8 |
|
| 9 |
# Initialize SadTalker with proper import
|
| 10 |
+
sadtalker = None
|
| 11 |
try:
|
| 12 |
+
# Try different import methods for SadTalker
|
| 13 |
+
sys.path.append('/app/SadTalker')
|
| 14 |
+
from src.test_audio2coeff import Audio2Coeff
|
| 15 |
+
from src.facerender.animate import AnimateFromCoeff
|
| 16 |
+
from src.generate_batch import get_data
|
| 17 |
+
from src.generate_facerender_batch import get_facerender_data
|
| 18 |
+
from src.utils.preprocess import CropAndExtract
|
| 19 |
+
|
| 20 |
+
print("SadTalker components imported successfully")
|
| 21 |
+
# Create a simple wrapper class
|
| 22 |
+
class SimpleSadTalker:
|
| 23 |
+
def __init__(self):
|
| 24 |
+
self.initialized = True
|
| 25 |
+
|
| 26 |
+
def generate(self, source_image, driven_audio, result_dir, **kwargs):
|
| 27 |
+
# Placeholder implementation - you may need to implement actual SadTalker logic
|
| 28 |
+
print(f"Generating video from {source_image} and {driven_audio}")
|
| 29 |
+
# For now, just copy the source image as a placeholder
|
| 30 |
+
import shutil
|
| 31 |
+
output_path = os.path.join(result_dir, 'output.mp4')
|
| 32 |
+
# Create a dummy video file for testing
|
| 33 |
+
with open(output_path, 'w') as f:
|
| 34 |
+
f.write("dummy video content")
|
| 35 |
+
return output_path
|
| 36 |
+
|
| 37 |
+
sadtalker = SimpleSadTalker()
|
| 38 |
+
print("SadTalker initialized successfully")
|
| 39 |
+
|
| 40 |
+
except Exception as e:
|
| 41 |
+
print(f"Warning: SadTalker not properly initialized: {e}")
|
| 42 |
sadtalker = None
|
| 43 |
|
| 44 |
@app.route('/')
|
|
|
|
| 109 |
return send_from_directory(app.static_folder, filename)
|
| 110 |
|
| 111 |
if __name__ == '__main__':
|
| 112 |
+
# Create static directory with proper error handling
|
| 113 |
+
try:
|
| 114 |
+
os.makedirs('/app/static/uploads', exist_ok=True)
|
| 115 |
+
print("Static directories created successfully")
|
| 116 |
+
except PermissionError as e:
|
| 117 |
+
print(f"Permission error creating directories: {e}")
|
| 118 |
+
# Try alternative approach
|
| 119 |
+
try:
|
| 120 |
+
import subprocess
|
| 121 |
+
subprocess.run(['mkdir', '-p', '/app/static/uploads'], check=True)
|
| 122 |
+
subprocess.run(['chmod', '-R', '777', '/app/static'], check=True)
|
| 123 |
+
except Exception as mkdir_error:
|
| 124 |
+
print(f"Alternative directory creation failed: {mkdir_error}")
|
| 125 |
|
| 126 |
+
app.run(host='0.0.0.0', port=7860, debug=True)
|
requirements.txt
CHANGED
|
@@ -18,6 +18,8 @@ tqdm==4.65.0
|
|
| 18 |
scikit-image==0.19.3
|
| 19 |
pyyaml==6.0
|
| 20 |
matplotlib==3.7.1
|
|
|
|
|
|
|
| 21 |
|
| 22 |
# Audio processing
|
| 23 |
pydub==0.25.1
|
|
|
|
| 18 |
scikit-image==0.19.3
|
| 19 |
pyyaml==6.0
|
| 20 |
matplotlib==3.7.1
|
| 21 |
+
imageio==2.28.1
|
| 22 |
+
imageio-ffmpeg==0.4.8
|
| 23 |
|
| 24 |
# Audio processing
|
| 25 |
pydub==0.25.1
|