MCPcopy Create free account
hub / github.com/CiaraStrawberry/TemporalKit / numpy_array_to_temp_url

Function numpy_array_to_temp_url

scripts/sd-TemporalKit-UI.py:265–285  ·  view source on GitHub ↗
(img_array)

Source from the content-addressed store, hash-verified

263 return data_uri
264
265def numpy_array_to_temp_url(img_array):
266 # create a filename for the temporary file
267 filename = 'generatedsquare.png'
268 extension_path = os.path.abspath(__file__)
269 extension_dir = os.path.dirname(os.path.dirname(extension_path))
270 extension_folder = os.path.join(extension_dir,"squares")
271 if not os.path.exists(extension_folder):
272 os.makedirs(extension_folder)
273 # create a path for the temporary file
274 file_path = os.path.join(extension_folder, filename)
275
276 # convert the array to an image using PIL
277 img = Image.fromarray(img_array)
278
279 # save the image to the temporary file as PNG
280 img.save(file_path, format='PNG')
281
282 # create a URL for the temporary file
283 #url = 'file://' + file_path
284
285 return file_path
286
287def display_interface(interface):
288 return interface.display()

Callers 1

preprocess_videoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected