mirror of
https://github.com/iperov/DeepFaceLab.git
synced 2025-07-06 13:02:15 -07:00
added support of non-english characters in paths
This commit is contained in:
parent
0313fd9ae6
commit
5a1fb199f4
7 changed files with 47 additions and 23 deletions
22
utils/cv2_utils.py
Normal file
22
utils/cv2_utils.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
import cv2
|
||||
import numpy as np
|
||||
from pathlib import Path
|
||||
|
||||
#allows to open non-english characters path
|
||||
def cv2_imread(filename, flags=cv2.IMREAD_UNCHANGED):
|
||||
try:
|
||||
with open(filename, "rb") as stream:
|
||||
bytes = bytearray(stream.read())
|
||||
numpyarray = np.asarray(bytes, dtype=np.uint8)
|
||||
return cv2.imdecode(numpyarray, flags)
|
||||
except:
|
||||
return None
|
||||
|
||||
def cv2_imwrite(filename, img, *args):
|
||||
ret, buf = cv2.imencode( Path(filename).suffix, img, *args)
|
||||
if ret == True:
|
||||
try:
|
||||
with open(filename, "wb") as stream:
|
||||
stream.write( buf )
|
||||
except:
|
||||
pass
|
Loading…
Add table
Add a link
Reference in a new issue