gadhalevy commited on
Commit
74ebee3
Β·
1 Parent(s): 4ae37f3

dock avatar12

Browse files
Files changed (2) hide show
  1. Dockerfile +11 -11
  2. avatar_streamlit.py +69 -8
Dockerfile CHANGED
@@ -52,16 +52,16 @@ RUN pip install --no-cache-dir \
52
  RUN git clone --depth 1 https://github.com/OpenTalker/SadTalker.git /app/SadTalker
53
 
54
  # ---------- Download SadTalker Checkpoints ----------
55
- # RUN cd /app/SadTalker && \
56
- # mkdir -p checkpoints && \
57
- # echo "πŸ“¦ Downloading SadTalker model checkpoints..." && \
58
- # wget --progress=bar:force:noscroll --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 -t 3 \
59
- # https://github.com/OpenTalker/SadTalker/releases/download/v0.0.2-rc/checkpoints.zip -O checkpoints.zip && \
60
- # echo "πŸ“¦ Extracting checkpoints..." && \
61
- # unzip -o checkpoints.zip && \
62
- # rm checkpoints.zip && \
63
- # echo "βœ… Checkpoints downloaded successfully" && \
64
- # ls -lh checkpoints/
65
 
66
  # Install SadTalker requirements with correct NumPy
67
  RUN cd /app/SadTalker && \
@@ -101,4 +101,4 @@ RUN cd /app/SadTalker && \
101
  EXPOSE 8501
102
  CMD ["streamlit", "run", "avatar_streamlit.py", "--server.port=8501", "--server.address=0.0.0.0"]
103
 
104
- # FORCE_REBUILD: 2025-01-04-v23
 
52
  RUN git clone --depth 1 https://github.com/OpenTalker/SadTalker.git /app/SadTalker
53
 
54
  # ---------- Download SadTalker Checkpoints ----------
55
+ RUN cd /app/SadTalker && \
56
+ mkdir -p checkpoints && \
57
+ echo "πŸ“¦ Downloading SadTalker model checkpoints..." && \
58
+ wget --progress=bar:force:noscroll --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 -t 3 \
59
+ https://github.com/OpenTalker/SadTalker/releases/download/v0.0.2-rc/checkpoints.zip -O checkpoints.zip && \
60
+ echo "πŸ“¦ Extracting checkpoints..." && \
61
+ unzip -o checkpoints.zip && \
62
+ rm checkpoints.zip && \
63
+ echo "βœ… Checkpoints downloaded successfully" && \
64
+ ls -lh checkpoints/
65
 
66
  # Install SadTalker requirements with correct NumPy
67
  RUN cd /app/SadTalker && \
 
101
  EXPOSE 8501
102
  CMD ["streamlit", "run", "avatar_streamlit.py", "--server.port=8501", "--server.address=0.0.0.0"]
103
 
104
+ # FORCE_REBUILD: 2025-01-04-v13
avatar_streamlit.py CHANGED
@@ -47,26 +47,87 @@ def ensure_sadtalker_checkpoints():
47
  return True
48
 
49
  print("πŸ“¦ Downloading SadTalker checkpoints (first run only)...")
 
 
50
  try:
51
  import subprocess
52
  os.makedirs(checkpoint_dir, exist_ok=True)
53
 
54
- # Download checkpoints
55
  zip_path = '/tmp/sadtalker_checkpoints.zip'
56
  download_url = 'https://github.com/OpenTalker/SadTalker/releases/download/v0.0.2-rc/checkpoints.zip'
57
 
58
- subprocess.run(['wget', '-O', zip_path, download_url], check=True)
59
- subprocess.run(['unzip', '-o', zip_path, '-d', '/app/SadTalker/'], check=True)
60
- subprocess.run(['rm', zip_path], check=True)
61
 
62
- print("βœ… Checkpoints downloaded successfully")
63
- return True
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  except Exception as e:
 
65
  print(f"❌ Failed to download checkpoints: {e}")
 
66
  return False
67
 
68
- # Download checkpoints on startup
69
- SADTALKER_AVAILABLE = ensure_sadtalker_checkpoints()
 
70
 
71
  # ========== Helpers ==========
72
 
 
47
  return True
48
 
49
  print("πŸ“¦ Downloading SadTalker checkpoints (first run only)...")
50
+ print("⏳ This may take 2-3 minutes on first startup...")
51
+
52
  try:
53
  import subprocess
54
  os.makedirs(checkpoint_dir, exist_ok=True)
55
 
56
+ # Download checkpoints with better error handling
57
  zip_path = '/tmp/sadtalker_checkpoints.zip'
58
  download_url = 'https://github.com/OpenTalker/SadTalker/releases/download/v0.0.2-rc/checkpoints.zip'
59
 
60
+ print(f"🌐 Downloading from: {download_url}")
 
 
61
 
62
+ # Try wget with verbose output
63
+ result = subprocess.run(
64
+ ['wget', '--timeout=60', '--tries=3', '-O', zip_path, download_url],
65
+ capture_output=True,
66
+ text=True
67
+ )
68
+
69
+ if result.returncode != 0:
70
+ print(f"❌ wget failed: {result.stderr}")
71
+ # Try with curl as fallback
72
+ print("πŸ”„ Trying with curl...")
73
+ result = subprocess.run(
74
+ ['curl', '-L', '-o', zip_path, download_url],
75
+ capture_output=True,
76
+ text=True,
77
+ timeout=120
78
+ )
79
+ if result.returncode != 0:
80
+ print(f"❌ curl failed: {result.stderr}")
81
+ return False
82
+
83
+ # Check if file was downloaded
84
+ if not os.path.exists(zip_path):
85
+ print("❌ Download file not found")
86
+ return False
87
+
88
+ file_size = os.path.getsize(zip_path)
89
+ print(f"βœ… Downloaded {file_size / (1024*1024):.1f} MB")
90
+
91
+ if file_size < 1024 * 1024: # Less than 1MB is suspicious
92
+ print("❌ Downloaded file is too small, possibly corrupted")
93
+ return False
94
+
95
+ # Extract checkpoints
96
+ print("πŸ“¦ Extracting checkpoints...")
97
+ result = subprocess.run(
98
+ ['unzip', '-o', '-q', zip_path, '-d', '/app/SadTalker/'],
99
+ capture_output=True,
100
+ text=True
101
+ )
102
+
103
+ if result.returncode != 0:
104
+ print(f"❌ Extraction failed: {result.stderr}")
105
+ return False
106
+
107
+ # Clean up
108
+ os.remove(zip_path)
109
+
110
+ # Verify extraction
111
+ if os.path.exists(checkpoint_file):
112
+ print("βœ… Checkpoints downloaded and extracted successfully")
113
+ return True
114
+ else:
115
+ print(f"❌ Checkpoint file not found after extraction: {checkpoint_file}")
116
+ # List what was extracted
117
+ if os.path.exists(checkpoint_dir):
118
+ files = os.listdir(checkpoint_dir)
119
+ print(f"Files in checkpoints dir: {files}")
120
+ return False
121
+
122
  except Exception as e:
123
+ import traceback
124
  print(f"❌ Failed to download checkpoints: {e}")
125
+ print(traceback.format_exc())
126
  return False
127
 
128
+ # Download checkpoints on startup with progress indicator
129
+ with st.spinner("πŸ”„ Initializing SadTalker (first run may take 2-3 minutes)..."):
130
+ SADTALKER_AVAILABLE = ensure_sadtalker_checkpoints()
131
 
132
  # ========== Helpers ==========
133