Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
add deps for backend dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
cainky committed Sep 23, 2023
1 parent d245634 commit c63f661
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ A simple GUI app to synchronize recorded audio with video lip movements using th
## Docker
- In the root project directory, run
```bash
docker-compose build
docker-compose up
```


Expand Down
3 changes: 2 additions & 1 deletion backend/docker/Dockerfile.backend
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ FROM pytorch/pytorch:1.8.1-cuda11.1-cudnn8-runtime
WORKDIR /backend

# Install system dependencies
RUN apt-get update && apt-get install -y git wget && \
RUN apt-get update && apt-get install -y git wget libgl1-mesa-glx && \
rm -rf /var/lib/apt/lists/*


# Install backend dependencies
RUN pip install poetry

Expand Down
5 changes: 4 additions & 1 deletion backend/docker/download_models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import gdown

base_directory = "/backend/wav2lip-hq/"
checkpoints_directory = base_directory + "checkpoints/"

urls = {
"wav2lip_gan.pth": "10Iu05Modfti3pDbxCFPnofmfVlbkvrCm",
"face_segmentation.pth": "154JgKpzCPW82qINcVieuPH3fZ2e0P812",
Expand All @@ -8,6 +11,6 @@

for name, id in urls.items():
url = f"https://drive.google.com/uc?id={id}"
output = f"checkpoints/{name}"
output = checkpoints_directory + name
gdown.download(url, output, quiet=False)
print(f"Loaded {name}")
10 changes: 6 additions & 4 deletions backend/services/wav2lip_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ def run_command(cmd, workdir=None):
cmd, text=True, cwd=workdir, stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
if result.returncode != 0:
raise Exception(
f"Command {cmd[0]} failed with return code {result.returncode}."
)
error_details = f"Command '{' '.join(cmd)}' failed with return code {result.returncode}. "
error_details += f"STDOUT: {result.stdout} "
error_details += f"STDERR: {result.stderr}"
raise Exception(error_details)
return result



def convert_webm_to_wav(input_path, output_path):
cmd = ["ffmpeg", "-y", "-i", input_path, output_path]
run_command(cmd)
Expand Down Expand Up @@ -71,6 +73,6 @@ def run_wav2lip_inference(face_path, audio_path, outfile_path):

if not os.path.exists(outfile_path):
error_msg = result.stderr if result.stderr else result.stdout
raise Exception(f"Output video not found after processing. Error: {error_msg}")
raise Exception(f"Error: {error_msg}")

return outfile_path
7 changes: 4 additions & 3 deletions backend/tests/services/test_wav2lip_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@ def test_wav2lip_inference_processing_error(self, mock_run, mock_exists):

with self.assertRaises(Exception) as context:
run_wav2lip_inference(self.face, self.audio, self.outfile)

self.assertTrue(str(context.exception).startswith(f"Command 'ffmpeg -y -i test_audio.webm test_audio.wav' failed with return code 1."))
self.assertTrue("Error in Wav2Lip" in str(context.exception))


self.assertTrue(
"Command ffmpeg failed with return code 1." in str(context.exception)
)

@patch("os.path.exists", return_value=True)
@patch(
Expand Down
1 change: 1 addition & 0 deletions frontend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BACKEND_URL=http://localhost:5000

0 comments on commit c63f661

Please sign in to comment.