Avoiding of opencv unicode paths bug in face_enhancer methods
This commit is contained in:
Pozitronik 2023-06-18 17:00:49 +04:00
parent e9e7e0c080
commit 8e1d29218e

View File

@ -2,6 +2,7 @@ from typing import Any, List
import cv2
import threading
import gfpgan
import numpy
import roop.globals
import roop.processors.frame.core
@ -57,17 +58,19 @@ def process_frame(source_face: Any, temp_frame: Any) -> Any:
def process_frames(source_path: str, temp_frame_paths: List[str], progress=None) -> None:
for temp_frame_path in temp_frame_paths:
temp_frame = cv2.imread(temp_frame_path)
temp_frame = cv2.imdecode(numpy.fromfile(temp_frame_path, dtype=numpy.uint8), cv2.IMREAD_UNCHANGED)
result = process_frame(None, temp_frame)
cv2.imwrite(temp_frame_path, result)
is_success, im_buf_arr = cv2.imencode(".png", result)
im_buf_arr.tofile(temp_frame_path)
if progress:
progress.update(1)
def process_image(source_path: str, target_path: str, output_path: str) -> None:
target_frame = cv2.imread(target_path)
target_frame = cv2.imdecode(numpy.fromfile(target_path, dtype=numpy.uint8), cv2.IMREAD_UNCHANGED)
result = process_frame(None, target_frame)
cv2.imwrite(output_path, result)
is_success, im_buf_arr = cv2.imencode(".png", result)
im_buf_arr.tofile(output_path)
def process_video(source_path: str, temp_frame_paths: List[str]) -> None: