显示numpy数组的工具。
displayarra的Python项目详细描述
在Python中将数组显示为视频的库。在
更新阵列时显示阵列
from displayarray import display import numpy as np arr = np.random.normal(0.5, 0.1, (100, 100, 3)) with display(arr) as d: while d: arr[:] += np.random.normal(0.001, 0.0005, (100, 100, 3)) arr %= 1.0
当张量通过张量流或Pythorch时显示它们
# see test_display_tensorflow in test_simple_apy for full code. ... autoencoder.compile(loss="mse", optimizer="adam") while displayer: grab = tf.convert_to_tensor( displayer.FRAME_DICT["fractal test.mp4frame"][np.newaxis, ...].astype(np.float32) / 255.0 ) grab_noise = tf.convert_to_tensor( (((displayer.FRAME_DICT["fractal test.mp4frame"][np.newaxis, ...].astype( np.float32) + np.random.uniform(0, 255, grab.shape)) / 2) % 255) / 255.0 ) displayer.update((grab_noise.numpy()[0] * 255.0).astype(np.uint8), "uid for grab noise") autoencoder.fit(grab_noise, grab, steps_per_epoch=1, epochs=1) output_image = autoencoder.predict(grab, steps=1) displayer.update((output_image[0] * 255.0).astype(np.uint8), "uid for autoencoder output")
处理输入事件
鼠标在窗口上移动时捕获的鼠标事件:
event:0 x,y:133,387 flags:0 param:None
代码:
from displayarray.input import mouse_loop from displayarray import display @mouse_loop def print_mouse_thread(mouse_event): print(mouse_event) display("fractal test.mp4", blocking=True)
安装
displayarray作为 python3.6+和PyPy中的通用wheel。在
$ pip install displayarray
- 项目
标签: