Skip to content

Commit

Permalink
Bugfix: UTF-8 loading support affected image format
Browse files Browse the repository at this point in the history
  • Loading branch information
C0untFloyd committed Apr 1, 2024
1 parent ac3a9b5 commit a456bdb
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
8 changes: 3 additions & 5 deletions roop/ProcessMgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,15 @@ def initialize(self, input_faces, target_faces, options):
print(f"Not using {module}")


if self.options.imagemask is not None and "layers" in self.options.imagemask and len(self.options.imagemask["layers"]) > 0:
self.options.imagemask = self.options.imagemask["layers"][0]
if isinstance(self.options.imagemask, dict) and self.options.imagemask.get("layers") and len(self.options.imagemask["layers"]) > 0:
self.options.imagemask = self.options.imagemask.get("layers")[0]
# Get rid of alpha
self.options.imagemask = cv2.cvtColor(self.options.imagemask, cv2.COLOR_RGBA2GRAY)
if np.any(self.options.imagemask):
mo = self.input_face_datas[0].faces[0].mask_offsets
self.options.imagemask = self.blur_area(self.options.imagemask, mo[4], mo[5])
self.options.imagemask = self.options.imagemask.astype(np.float32) / 255
self.options.imagemask = cv2.cvtColor(self.options.imagemask, cv2.COLOR_GRAY2RGB)
#mask_blur = 5
#self.options.imagemask = cv2.GaussianBlur(self.options.imagemask, (mask_blur*2+1,mask_blur*2+1), 0)
else:
self.options.imagemask = None

Expand Down Expand Up @@ -154,7 +152,7 @@ def process_frames(self, source_files: List[str], target_files: List[str], curre
return

# Decode the byte array into an OpenCV image
temp_frame = cv2.imdecode(np.fromfile(f, dtype=np.uint8), cv2.IMREAD_UNCHANGED)
temp_frame = cv2.imdecode(np.fromfile(f, dtype=np.uint8), cv2.IMREAD_COLOR)
if temp_frame is not None:
resimg = self.process_frame(temp_frame)
if resimg is not None:
Expand Down
2 changes: 1 addition & 1 deletion roop/capturer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

def get_image_frame(filename: str):
try:
return cv2.imdecode(np.fromfile(filename, dtype=np.uint8), cv2.IMREAD_UNCHANGED)
return cv2.imdecode(np.fromfile(filename, dtype=np.uint8), cv2.IMREAD_COLOR)
except:
print(f"Exception reading {filename}")
return None
Expand Down
2 changes: 1 addition & 1 deletion roop/face_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def extract_face_images(source_filename, video_info, extra_padding=-1.0):
else:
return face_data
else:
source_image = cv2.imdecode(np.fromfile(source_filename, dtype=np.uint8), cv2.IMREAD_UNCHANGED)
source_image = cv2.imdecode(np.fromfile(source_filename, dtype=np.uint8), cv2.IMREAD_COLOR)

faces = get_all_faces(source_image)
if faces is None:
Expand Down
2 changes: 1 addition & 1 deletion roop/metadata.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
name = 'roop unleashed'
version = '3.6.6'
version = '3.6.7'

0 comments on commit a456bdb

Please sign in to comment.