Compare commits
21 Commits
e862ff1456
...
2f67e2f159
Author | SHA1 | Date |
---|---|---|
|
2f67e2f159 | |
|
a3af249ea6 | |
|
5bc3ada632 | |
|
650e89eb21 | |
|
4d2aea37b7 | |
|
28c4b34db1 | |
|
49e8f78513 | |
|
d753f5d4b0 | |
|
4fb69476d8 | |
|
f3adfd194d | |
|
e5f04cf917 | |
|
67394a3157 | |
|
186d155e1b | |
|
87081e78d0 | |
|
f79373d4db | |
|
513e413956 | |
|
f82cebf86e | |
|
d45dedc9a6 | |
|
2d489b57ec | |
|
ccc04983cf | |
|
2506c5a261 |
13
README.md
13
README.md
|
@ -49,7 +49,7 @@ Users are expected to use this software responsibly and legally. If using a real
|
||||||
2. Select which camera to use
|
2. Select which camera to use
|
||||||
3. Press live!
|
3. Press live!
|
||||||
|
|
||||||
## Features & Uses - Everything is real-time
|
## Features & Uses - Everything is in real-time
|
||||||
|
|
||||||
### Mouth Mask
|
### Mouth Mask
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ Users are expected to use this software responsibly and legally. If using a real
|
||||||
|
|
||||||
### Memes
|
### Memes
|
||||||
|
|
||||||
**Create Your most viral meme yet**
|
**Create Your Most Viral Meme Yet**
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="media/meme.gif" alt="show" width="450">
|
<img src="media/meme.gif" alt="show" width="450">
|
||||||
|
@ -93,6 +93,13 @@ Users are expected to use this software responsibly and legally. If using a real
|
||||||
<sub>Created using Many Faces feature in Deep-Live-Cam</sub>
|
<sub>Created using Many Faces feature in Deep-Live-Cam</sub>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
### Omegle
|
||||||
|
|
||||||
|
**Surprise people on Omegle**
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<video src="https://github.com/user-attachments/assets/2e9b9b82-fa04-4b70-9f56-b1f68e7672d0" width="450" controls></video>
|
||||||
|
</p>
|
||||||
|
|
||||||
## Installation (Manual)
|
## Installation (Manual)
|
||||||
|
|
||||||
|
@ -146,7 +153,7 @@ brew install python-tk@3.10
|
||||||
|
|
||||||
**CUDA Execution Provider (Nvidia)**
|
**CUDA Execution Provider (Nvidia)**
|
||||||
|
|
||||||
1. Install [CUDA Toolkit 11.8](https://developer.nvidia.com/cuda-11-8-0-download-archive) or [CUDA Toolkit 12.1.1](https://developer.nvidia.com/cuda-12-1-1-download-archive)
|
1. Install [CUDA Toolkit 12.1.1](https://developer.nvidia.com/cuda-12-1-1-download-archive)
|
||||||
2. Install dependencies:
|
2. Install dependencies:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
|
@ -39,13 +39,13 @@ def get_many_faces(frame: Frame) -> Any:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def has_valid_map() -> bool:
|
def has_valid_map() -> bool:
|
||||||
for map in modules.globals.souce_target_map:
|
for map in modules.globals.source_target_map:
|
||||||
if "source" in map and "target" in map:
|
if "source" in map and "target" in map:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def default_source_face() -> Any:
|
def default_source_face() -> Any:
|
||||||
for map in modules.globals.souce_target_map:
|
for map in modules.globals.source_target_map:
|
||||||
if "source" in map:
|
if "source" in map:
|
||||||
return map['source']['face']
|
return map['source']['face']
|
||||||
return None
|
return None
|
||||||
|
@ -53,7 +53,7 @@ def default_source_face() -> Any:
|
||||||
def simplify_maps() -> Any:
|
def simplify_maps() -> Any:
|
||||||
centroids = []
|
centroids = []
|
||||||
faces = []
|
faces = []
|
||||||
for map in modules.globals.souce_target_map:
|
for map in modules.globals.source_target_map:
|
||||||
if "source" in map and "target" in map:
|
if "source" in map and "target" in map:
|
||||||
centroids.append(map['target']['face'].normed_embedding)
|
centroids.append(map['target']['face'].normed_embedding)
|
||||||
faces.append(map['source']['face'])
|
faces.append(map['source']['face'])
|
||||||
|
@ -64,10 +64,10 @@ def simplify_maps() -> Any:
|
||||||
def add_blank_map() -> Any:
|
def add_blank_map() -> Any:
|
||||||
try:
|
try:
|
||||||
max_id = -1
|
max_id = -1
|
||||||
if len(modules.globals.souce_target_map) > 0:
|
if len(modules.globals.source_target_map) > 0:
|
||||||
max_id = max(modules.globals.souce_target_map, key=lambda x: x['id'])['id']
|
max_id = max(modules.globals.source_target_map, key=lambda x: x['id'])['id']
|
||||||
|
|
||||||
modules.globals.souce_target_map.append({
|
modules.globals.source_target_map.append({
|
||||||
'id' : max_id + 1
|
'id' : max_id + 1
|
||||||
})
|
})
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
@ -75,14 +75,14 @@ def add_blank_map() -> Any:
|
||||||
|
|
||||||
def get_unique_faces_from_target_image() -> Any:
|
def get_unique_faces_from_target_image() -> Any:
|
||||||
try:
|
try:
|
||||||
modules.globals.souce_target_map = []
|
modules.globals.source_target_map = []
|
||||||
target_frame = cv2.imread(modules.globals.target_path)
|
target_frame = cv2.imread(modules.globals.target_path)
|
||||||
many_faces = get_many_faces(target_frame)
|
many_faces = get_many_faces(target_frame)
|
||||||
i = 0
|
i = 0
|
||||||
|
|
||||||
for face in many_faces:
|
for face in many_faces:
|
||||||
x_min, y_min, x_max, y_max = face['bbox']
|
x_min, y_min, x_max, y_max = face['bbox']
|
||||||
modules.globals.souce_target_map.append({
|
modules.globals.source_target_map.append({
|
||||||
'id' : i,
|
'id' : i,
|
||||||
'target' : {
|
'target' : {
|
||||||
'cv2' : target_frame[int(y_min):int(y_max), int(x_min):int(x_max)],
|
'cv2' : target_frame[int(y_min):int(y_max), int(x_min):int(x_max)],
|
||||||
|
@ -96,7 +96,7 @@ def get_unique_faces_from_target_image() -> Any:
|
||||||
|
|
||||||
def get_unique_faces_from_target_video() -> Any:
|
def get_unique_faces_from_target_video() -> Any:
|
||||||
try:
|
try:
|
||||||
modules.globals.souce_target_map = []
|
modules.globals.source_target_map = []
|
||||||
frame_face_embeddings = []
|
frame_face_embeddings = []
|
||||||
face_embeddings = []
|
face_embeddings = []
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ def get_unique_faces_from_target_video() -> Any:
|
||||||
face['target_centroid'] = closest_centroid_index
|
face['target_centroid'] = closest_centroid_index
|
||||||
|
|
||||||
for i in range(len(centroids)):
|
for i in range(len(centroids)):
|
||||||
modules.globals.souce_target_map.append({
|
modules.globals.source_target_map.append({
|
||||||
'id' : i
|
'id' : i
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ def get_unique_faces_from_target_video() -> Any:
|
||||||
for frame in tqdm(frame_face_embeddings, desc=f"Mapping frame embeddings to centroids-{i}"):
|
for frame in tqdm(frame_face_embeddings, desc=f"Mapping frame embeddings to centroids-{i}"):
|
||||||
temp.append({'frame': frame['frame'], 'faces': [face for face in frame['faces'] if face['target_centroid'] == i], 'location': frame['location']})
|
temp.append({'frame': frame['frame'], 'faces': [face for face in frame['faces'] if face['target_centroid'] == i], 'location': frame['location']})
|
||||||
|
|
||||||
modules.globals.souce_target_map[i]['target_faces_in_frame'] = temp
|
modules.globals.source_target_map[i]['target_faces_in_frame'] = temp
|
||||||
|
|
||||||
# dump_faces(centroids, frame_face_embeddings)
|
# dump_faces(centroids, frame_face_embeddings)
|
||||||
default_target_face()
|
default_target_face()
|
||||||
|
@ -144,7 +144,7 @@ def get_unique_faces_from_target_video() -> Any:
|
||||||
|
|
||||||
|
|
||||||
def default_target_face():
|
def default_target_face():
|
||||||
for map in modules.globals.souce_target_map:
|
for map in modules.globals.source_target_map:
|
||||||
best_face = None
|
best_face = None
|
||||||
best_frame = None
|
best_frame = None
|
||||||
for frame in map['target_faces_in_frame']:
|
for frame in map['target_faces_in_frame']:
|
||||||
|
|
|
@ -9,7 +9,7 @@ file_types = [
|
||||||
("Video", ("*.mp4", "*.mkv")),
|
("Video", ("*.mp4", "*.mkv")),
|
||||||
]
|
]
|
||||||
|
|
||||||
souce_target_map = []
|
source_target_map = []
|
||||||
simple_map = {}
|
simple_map = {}
|
||||||
|
|
||||||
source_path = None
|
source_path = None
|
||||||
|
|
|
@ -117,12 +117,12 @@ def process_frame_v2(temp_frame: Frame, temp_frame_path: str = "") -> Frame:
|
||||||
if is_image(modules.globals.target_path):
|
if is_image(modules.globals.target_path):
|
||||||
if modules.globals.many_faces:
|
if modules.globals.many_faces:
|
||||||
source_face = default_source_face()
|
source_face = default_source_face()
|
||||||
for map in modules.globals.souce_target_map:
|
for map in modules.globals.source_target_map:
|
||||||
target_face = map["target"]["face"]
|
target_face = map["target"]["face"]
|
||||||
temp_frame = swap_face(source_face, target_face, temp_frame)
|
temp_frame = swap_face(source_face, target_face, temp_frame)
|
||||||
|
|
||||||
elif not modules.globals.many_faces:
|
elif not modules.globals.many_faces:
|
||||||
for map in modules.globals.souce_target_map:
|
for map in modules.globals.source_target_map:
|
||||||
if "source" in map:
|
if "source" in map:
|
||||||
source_face = map["source"]["face"]
|
source_face = map["source"]["face"]
|
||||||
target_face = map["target"]["face"]
|
target_face = map["target"]["face"]
|
||||||
|
@ -131,7 +131,7 @@ def process_frame_v2(temp_frame: Frame, temp_frame_path: str = "") -> Frame:
|
||||||
elif is_video(modules.globals.target_path):
|
elif is_video(modules.globals.target_path):
|
||||||
if modules.globals.many_faces:
|
if modules.globals.many_faces:
|
||||||
source_face = default_source_face()
|
source_face = default_source_face()
|
||||||
for map in modules.globals.souce_target_map:
|
for map in modules.globals.source_target_map:
|
||||||
target_frame = [
|
target_frame = [
|
||||||
f
|
f
|
||||||
for f in map["target_faces_in_frame"]
|
for f in map["target_faces_in_frame"]
|
||||||
|
@ -143,7 +143,7 @@ def process_frame_v2(temp_frame: Frame, temp_frame_path: str = "") -> Frame:
|
||||||
temp_frame = swap_face(source_face, target_face, temp_frame)
|
temp_frame = swap_face(source_face, target_face, temp_frame)
|
||||||
|
|
||||||
elif not modules.globals.many_faces:
|
elif not modules.globals.many_faces:
|
||||||
for map in modules.globals.souce_target_map:
|
for map in modules.globals.source_target_map:
|
||||||
if "source" in map:
|
if "source" in map:
|
||||||
target_frame = [
|
target_frame = [
|
||||||
f
|
f
|
||||||
|
|
|
@ -397,7 +397,7 @@ def analyze_target(start: Callable[[], None], root: ctk.CTk):
|
||||||
return
|
return
|
||||||
|
|
||||||
if modules.globals.map_faces:
|
if modules.globals.map_faces:
|
||||||
modules.globals.souce_target_map = []
|
modules.globals.source_target_map = []
|
||||||
|
|
||||||
if is_image(modules.globals.target_path):
|
if is_image(modules.globals.target_path):
|
||||||
update_status("Getting unique faces")
|
update_status("Getting unique faces")
|
||||||
|
@ -406,8 +406,8 @@ def analyze_target(start: Callable[[], None], root: ctk.CTk):
|
||||||
update_status("Getting unique faces")
|
update_status("Getting unique faces")
|
||||||
get_unique_faces_from_target_video()
|
get_unique_faces_from_target_video()
|
||||||
|
|
||||||
if len(modules.globals.souce_target_map) > 0:
|
if len(modules.globals.source_target_map) > 0:
|
||||||
create_source_target_popup(start, root, modules.globals.souce_target_map)
|
create_source_target_popup(start, root, modules.globals.source_target_map)
|
||||||
else:
|
else:
|
||||||
update_status("No faces found in target")
|
update_status("No faces found in target")
|
||||||
else:
|
else:
|
||||||
|
@ -696,17 +696,21 @@ def check_and_ignore_nsfw(target, destroy: Callable = None) -> bool:
|
||||||
|
|
||||||
|
|
||||||
def fit_image_to_size(image, width: int, height: int):
|
def fit_image_to_size(image, width: int, height: int):
|
||||||
if width is None and height is None:
|
if width is None or height is None or width <= 0 or height <= 0:
|
||||||
return image
|
return image
|
||||||
h, w, _ = image.shape
|
h, w, _ = image.shape
|
||||||
ratio_h = 0.0
|
ratio_h = 0.0
|
||||||
ratio_w = 0.0
|
ratio_w = 0.0
|
||||||
if width > height:
|
ratio_w = width / w
|
||||||
ratio_h = height / h
|
ratio_h = height / h
|
||||||
else:
|
# Use the smaller ratio to ensure the image fits within the given dimensions
|
||||||
ratio_w = width / w
|
ratio = min(ratio_w, ratio_h)
|
||||||
ratio = max(ratio_w, ratio_h)
|
|
||||||
new_size = (int(ratio * w), int(ratio * h))
|
# Compute new dimensions, ensuring they're at least 1 pixel
|
||||||
|
new_width = max(1, int(ratio * w))
|
||||||
|
new_height = max(1, int(ratio * h))
|
||||||
|
new_size = (new_width, new_height)
|
||||||
|
|
||||||
return cv2.resize(image, dsize=new_size)
|
return cv2.resize(image, dsize=new_size)
|
||||||
|
|
||||||
|
|
||||||
|
@ -787,9 +791,9 @@ def webcam_preview(root: ctk.CTk, camera_index: int):
|
||||||
return
|
return
|
||||||
create_webcam_preview(camera_index)
|
create_webcam_preview(camera_index)
|
||||||
else:
|
else:
|
||||||
modules.globals.souce_target_map = []
|
modules.globals.source_target_map = []
|
||||||
create_source_target_popup_for_webcam(
|
create_source_target_popup_for_webcam(
|
||||||
root, modules.globals.souce_target_map, camera_index
|
root, modules.globals.source_target_map, camera_index
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1199,4 +1203,4 @@ def update_webcam_target(
|
||||||
target_label_dict_live[button_num] = target_image
|
target_label_dict_live[button_num] = target_image
|
||||||
else:
|
else:
|
||||||
update_pop_live_status("Face could not be detected in last upload!")
|
update_pop_live_status("Face could not be detected in last upload!")
|
||||||
return map
|
return map
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
--extra-index-url https://download.pytorch.org/whl/cu121
|
--extra-index-url https://download.pytorch.org/whl/cu118
|
||||||
|
|
||||||
numpy>=1.23.5,<2
|
numpy>=1.23.5,<2
|
||||||
|
typing-extensions>=4.8.0
|
||||||
opencv-python==4.10.0.84
|
opencv-python==4.10.0.84
|
||||||
cv2_enumerate_cameras==1.1.15
|
cv2_enumerate_cameras==1.1.15
|
||||||
onnx==1.16.0
|
onnx==1.16.0
|
||||||
|
@ -9,13 +10,13 @@ psutil==5.9.8
|
||||||
tk==0.1.0
|
tk==0.1.0
|
||||||
customtkinter==5.2.2
|
customtkinter==5.2.2
|
||||||
pillow==11.1.0
|
pillow==11.1.0
|
||||||
torch==2.0.1+cu118; sys_platform != 'darwin'
|
torch==2.5.1+cu118; sys_platform != 'darwin'
|
||||||
torch==2.0.1; sys_platform == 'darwin'
|
torch==2.5.1+cu118; sys_platform == 'darwin'
|
||||||
torchvision==0.15.2+cu121; sys_platform != 'darwin'
|
torchvision==0.20.1; sys_platform != 'darwin'
|
||||||
torchvision==0.15.2; sys_platform == 'darwin'
|
torchvision==0.20.1+cu118; sys_platform == 'darwin'
|
||||||
onnxruntime-silicon==1.16.3; sys_platform == 'darwin' and platform_machine == 'arm64'
|
onnxruntime-silicon==1.16.3; sys_platform == 'darwin' and platform_machine == 'arm64'
|
||||||
onnxruntime-gpu==1.16.3; sys_platform != 'darwin'
|
onnxruntime-gpu==1.16.3; sys_platform != 'darwin'
|
||||||
tensorflow==2.12.1; sys_platform != 'darwin'
|
tensorflow; sys_platform != 'darwin'
|
||||||
opennsfw2==0.10.2
|
opennsfw2==0.10.2
|
||||||
protobuf==4.23.2
|
protobuf==4.23.2
|
||||||
tqdm==4.66.4
|
tqdm==4.66.4
|
||||||
|
|
Loading…
Reference in New Issue