MCPcopy Create free account
hub / github.com/MeiGen-AI/InfiniteTalk / cache_image

Function cache_image

wan/utils/utils.py:98–125  ·  view source on GitHub ↗
(tensor,
                save_file,
                nrow=8,
                normalize=True,
                value_range=(-1, 1),
                retry=5)

Source from the content-addressed store, hash-verified

96
97
98def cache_image(tensor,
99 save_file,
100 nrow=8,
101 normalize=True,
102 value_range=(-1, 1),
103 retry=5):
104 # cache file
105 suffix = osp.splitext(save_file)[1]
106 if suffix.lower() not in [
107 '.jpg', '.jpeg', '.png', '.tiff', '.gif', '.webp'
108 ]:
109 suffix = '.png'
110
111 # save to cache
112 error = None
113 for _ in range(retry):
114 try:
115 tensor = tensor.clamp(min(value_range), max(value_range))
116 torchvision.utils.save_image(
117 tensor,
118 save_file,
119 nrow=nrow,
120 normalize=normalize,
121 value_range=value_range)
122 return save_file
123 except Exception as e:
124 error = e
125 continue
126
127def convert_video_to_h264(input_video_path, output_video_path):
128 subprocess.run(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected