Skip to content

Commit

Permalink
style: fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
elanmart committed Dec 19, 2022
1 parent 988291d commit 95dcd36
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
7 changes: 4 additions & 3 deletions cbp_translate/components/alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ def jaccard(s0: set, s1: set):
end = min(end, n_frames - 1)
for i in range(start + 1, end):
voices[segment.id_].add(i)



face_appears = defaultdict(set)

for i, sublist in enumerate(faces):
Expand All @@ -69,7 +68,9 @@ def jaccard(s0: set, s1: set):
ret = {}

for face_id in face_appears:
speaker = max(voices, key=lambda speaker: jaccard(voices[speaker], face_appears[face_id]))
speaker = max(
voices, key=lambda speaker: jaccard(voices[speaker], face_appears[face_id])
)
ret[face_id] = speaker

return ret
Expand Down
4 changes: 3 additions & 1 deletion cbp_translate/components/faces.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,9 @@ def detect_faces(path_in: str) -> list[OnFrameDetected]:

def recognize_faces(detected: list[OnFrameDetected]):
# Cluster the embeddings
cluster_centers = face_clustering(detected, metric="cosine", linkage="average", threshold=0.3)
cluster_centers = face_clustering(
detected, metric="cosine", linkage="average", threshold=0.3
)

# Assign a unique ID to each face
recognized = assign_face_ids.map(
Expand Down
2 changes: 1 addition & 1 deletion cbp_translate/components/subtitles.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def add_subtitles(

def add_borders(frame: Arr, size: float = 0.1) -> tuple[Arr, int]:
"""Add black borders to the top and bottom of a frame. That's where the subtitles will be displayed."""

height, width, _ = frame.shape
border_h = int(round(size * height))
border = np.zeros((border_h, width, 3), np.uint8)
Expand Down
3 changes: 1 addition & 2 deletions cbp_translate/components/translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ def translate_segments(
# Debug
if not auth_key:
return [
TranslatedSegment(s.start, s.end, s.text_src, s.text_src)
for s in segments
TranslatedSegment(s.start, s.end, s.text_src, s.text_src) for s in segments
]

# We feed the entire text to DeepL at once, even though it might come from multiple speakers
Expand Down

0 comments on commit 95dcd36

Please sign in to comment.