Enjoy!
Thanks for giving us this guide to the colors they use for the labels here.
@Francis60 that is interesting and I think the code you used to pull this would be fair to share-- But I am left wondering a little what is the distinction between âNoneâ and âAnyâ ? That seems a little weirdâŠ
*Or even âOtherâ for that matterâŠ
Hello,
CARLA would say something subtle, I suppose:
Any: I see something but I canât tell which class it belongs to.
None: I donât see anything
- Get a list of color classes from first channel thru all the masks:
All classes from 1 to 22 an are used.
Note the Python nonsense ordered set.
- Find the previous version list on stackoverflow or CARLA site.
Here they used âAnyâ class for personalized object category in C code.
The latest version includes many more classes, such as different types of vehicle.
- The code :
colors = [âNoneâ, âBuildingsâ, âFencesâ, âOtherâ,âPedestriansâ, âPolesâ, âRoadLinesâ,
âRoadsâ, âSidewalksâ, âVegetationâ, âVehiclesâ, âWallsâ, âTrafficSignsâ, âSkyâ,
âGroundâ, âBridgeâ, âRailTrackâ, âGuardRailâ, âTrafficLightâ,
âStaticâ, âDynamicâ, âWaterâ, âTerrainâ, âAnyâ]fig, arr = plt.subplots(5, 5, figsize=(6, 4))
for c, ax in enumerate(arr.flat):
if c != 0 and c < len(colors)-1:
name = colors[c]
area = np.full((1, 2), c, dtype=np.uint8)
ax.imshow(area, vmin=1, vmax=22) # specify range !
ax.set_title(name, fontsize=12)
ax.axis(âoffâ)
elif c != len(colors):
name = colors[c]
area = np.full((1, 2, 1), 1, dtype=np.uint8) * [122, 122, 122] # grey
ax.imshow(area)
ax.set_title(name, fontsize=12)
ax.axis(âoffâ)
else:
ax.axis(âoffâ) # empty cellplt.tight_layout()
# Save the plot to a file (e.g., PNG)
plt.savefig(âpalette.pngâ)plt.show()
Unfortunately I was not able to adapt the display()
function given in the Lab to actually use the exact range of colors, resulting in a wrong mapping of colors.
defauft âviridisâ cmap parameter used in plt.imshow()
.
Still the mapping is correct as soon as you have âBuildingsâ and âTerrainâ pixels into the mask
Here you go!
def display(display_list):
plt.figure(figsize=(15, 15))title = ['Input Image', 'True Mask', 'Predicted Mask'] for i in range(len(display_list)): plt.subplot(1, len(display_list), i+1) plt.title(title[i]) if i == 0: plt.imshow(tf.keras.preprocessing.image.array_to_img(display_list[i])) else: mask = display_list[i] mask = tf.math.reduce_max(mask, axis=-1, keepdims=True) plt.imshow(mask[:, :, 0], cmap=cmap, vmin=1, vmax=22) plt.axis('off') plt.show()