MCPcopy
hub / github.com/sczhou/CodeFormer / imwrite

Function imwrite

facelib/utils/misc.py:33–49  ·  view source on GitHub ↗

Write image to file. Args: img (ndarray): Image array to be written. file_path (str): Image file path. params (None or list): Same as opencv's :func:`imwrite` interface. auto_mkdir (bool): If the parent folder of `file_path` does not exist, whether to

(img, file_path, params=None, auto_mkdir=True)

Source from the content-addressed store, hash-verified

31
32
33def imwrite(img, file_path, params=None, auto_mkdir=True):
34 """Write image to file.
35
36 Args:
37 img (ndarray): Image array to be written.
38 file_path (str): Image file path.
39 params (None or list): Same as opencv's :func:`imwrite` interface.
40 auto_mkdir (bool): If the parent folder of `file_path` does not exist,
41 whether to create it automatically.
42
43 Returns:
44 bool: Successful or not.
45 """
46 if auto_mkdir:
47 dir_name = os.path.abspath(os.path.dirname(file_path))
48 os.makedirs(dir_name, exist_ok=True)
49 return cv2.imwrite(file_path, img, params)
50
51
52def img2tensor(imgs, bgr2rgb=True, float32=True):

Callers 3

align_warp_faceMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected