我在这里安装了稳定扩散的 GUI 版本。有了它,我能够使用具有 8 GB 内存的 GeForce RTX 3070 GPU 制作 512 x 512 像素的图像:
但是,当我尝试使用命令行界面执行相同的操作时,内存不足:
输入:
>> C:\SD\stable-diffusion-main>python scripts/txt2img.py --prompt "a close-up portrait of a cat by pablo picasso, vivid, abstract art, colorful, vibrant" --plms --n_iter 3 --n_samples 1 --H 512 --W 512
错误:
RuntimeError: CUDA out of memory. Tried to allocate 1024.00 MiB (GPU 0; 8.00 GiB total capacity; 6.13 GiB already allocated; 0 bytes free; 6.73 GiB reserved in total by PyTorch) If reserved memory is …
区域的颜色并不重要,我想要实现的是沿着 Voronoi 区域的边缘的可变“厚度”(特别是,它们看起来像一个更大的圆形斑点,在拐角处相交,在拐角处相交处更薄)他们的中间点)。
我尝试根据到每个质心的最小距离“手动绘制”每个像素(每个像素与一种颜色相关联):
n_centroids = 10
centroids = [(random.randint(0, h), random.randint(0, w)) for _ in range(n_centroids)]
colors = np.array([np.random.choice(range(256), size=3) for _ in range(n_centroids)]) / 255
for x, y in it.product(range(h), range(w)):
distances = np.sqrt([(x - c[0])**2 + (y - c[1])**2 for c in centroids])
centroid_i = np.argmin(distances)
img[x, y] = colors[centroid_i]
plt.imshow(img, cmap='gray')
Run Code Online (Sandbox Code Playgroud)
或者通过scipy.spatial.Voronoi
,这也给了我顶点,尽管我仍然不知道如何以所需的可变厚度通过它们画一条线。
from scipy.spatial import Voronoi, voronoi_plot_2d
# make up data points
points = [(random.randint(0, 10), random.randint(0, 10)) for _ in range(10)]
# …
Run Code Online (Sandbox Code Playgroud) 当我学习创建循环生成艺术 GIF 的方法时,我遇到了两种不同的制作噪声循环的方法。
Etienne Jacob 在其教程中的示例代码使用 4D OpenSimplex Noise,如下所示。
(float)noise.eval(scl * x, scl * y, R * cos(TWO_PI * t), R * sin(TWO_PI * t));
Daniel Shiffman 在其教程中的示例代码使用 2D Perlin 噪声,如下所示。
噪声(cos(a)+ 1,sin(a)+ 1);
我的理解是,两者都是通过在噪声空间中“绕圈行走”来实现循环的,如上面的 gif 所示。但我不清楚两者之间的区别。选择 4D OpenSimplex 而不是 2D Perlin Noise 来创建循环噪声的目的是什么?
python ×2
javascript ×1
matplotlib ×1
opencv ×1
p5.js ×1
perlin-noise ×1
processing ×1
pytorch ×1
voronoi ×1