Skip to content

Commit

Permalink
Add video and image swap to the GUI (#116)
Browse files Browse the repository at this point in the history
* Add video and image swap to the GUI

* Update CHANGELOG.md

* Restore CHANGELOG.md

* Restore ui.py

* Update ui

* Update ui

* Update CHANGELOG.md

* Update executable
  • Loading branch information
Ghassen-Chaabouni authored May 27, 2024
1 parent d90c083 commit 981027f
Show file tree
Hide file tree
Showing 4 changed files with 268 additions and 169 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

* Add video and image swap to the GUI by @Ghassen-Chaabouni in https://github.com/sensity-ai/dot/pull/116

## [1.3.0] - 2024-02-19

## What's Changed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Supported methods:
Download and run the dot executable for your OS:

- Windows (Tested on Windows 10 and 11):
- Download `dot.zip` from [here](https://drive.google.com/file/d/10LXgtE721YPXdHfzcDUp6ba-9klueocR/view), unzip it and then run `dot.exe`
- Download `dot.zip` from [here](https://drive.google.com/file/d/1IgMaaKzFw4lBKa8MWnsH7nKwBQtrtLGJ/view), unzip it and then run `dot.exe`
- Ubuntu:
- ToDo
- Mac (Tested on Apple M2 Sonoma 14.0):
Expand Down
13 changes: 5 additions & 8 deletions src/dot/commons/video/video_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import mediapipe as mp
import numpy as np
from mediapipe.python.solutions.drawing_utils import _normalized_to_pixel_coordinates
from tqdm import tqdm

from ..pose.head_pose import pose_estimation
from ..utils import expand_bbox, find_files_from_path
Expand Down Expand Up @@ -120,7 +119,7 @@ def video_pipeline(
print("Total number of face-swaps: ", len(swaps_combination))

# iterate on each source-target pair
for (source, target) in tqdm(swaps_combination):
for (source, target) in swaps_combination:
img_a_whole = cv2.imread(source)
img_a_whole = _crop_and_pose(img_a_whole, estimate_pose=head_pose)
if isinstance(img_a_whole, int):
Expand All @@ -138,11 +137,9 @@ def video_pipeline(
cap = cv2.VideoCapture(target)

fps = int(cap.get(cv2.CAP_PROP_FPS))
if crop_size == 256: # fomm
frame_width = frame_height = crop_size
else:
frame_width = int(cap.get(3))
frame_height = int(cap.get(4))

frame_width = int(cap.get(3))
frame_height = int(cap.get(4))

total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
# trim original video length
Expand All @@ -164,7 +161,7 @@ def video_pipeline(
)

# process each frame individually
for _ in tqdm(range(total_frames)):
for _ in range(total_frames):
ret, frame = cap.read()
if ret is True:
frame = cv2.flip(frame, 1)
Expand Down
Loading

0 comments on commit 981027f

Please sign in to comment.