Syntax Error In Random 2 Shapes

I have had an undergraduate project to do and recently i just have to find a way to random shape more than one shape and recently i have try to declare it in many ways is till got error don’t get me wrong i’m new to this image processing i’m just an undergraduate student who had to find a way on my own
so ijust want to random only triangle and rectangle here’s my code

# Let's start simple and generate a 128x128 image
# with a single grayscale rectangle.
result = random_shapes((128, 128), min_shapes=1,max_shapes=8, shape=({'rectangle','triangle'}),
                       channel_axis=None, random_seed=0)

# We get back a tuple consisting of (1) the image with the generated shapes
# and (2) a list of label tuples with the kind of shape (e.g. circle,
# rectangle) and ((r0, r1), (c0, c1)) coordinates.
image, labels = result
print(f'Image shape: {image.shape}\nLabels: {labels}')

# We can visualize the images.
fig, axes = plt.subplots(nrows=2, ncols=3)
ax = axes.ravel()
ax[0].imshow(image, cmap='gray')
ax[0].set_title('Grayscale shape')

Here It Said
TypeError: unhashable type: 'set'
P.S. I also have an issue about this when i change into list it also got TypeError I’m really blind with this.

Hi @LAUGHY-PTPK, and welcome!

Yes, unfortunately random_shapes does not accept multiple shapes as an argument (this could be an excellent first contribution :wink: ).

So, you can try something like this:

import skimage as ski
import matplotlib.pyplot as plt

triangles, tri_labels = ski.draw.random_shapes(
    (128, 128), min_shapes=1, max_shapes=8, shape='triangle',
    channel_axis=None, random_seed=0
)

rectangles, rect_labels = ski.draw.random_shapes(
    (128, 128), min_shapes=1, max_shapes=8, shape='rectangle',
    channel_axis=None, random_seed=0
)

image = triangles + rectangles

fig, ax = plt.subplots()
ax.imshow(image, cmap='gray')
ax.set_title('Grayscale shape')
plt.show()