Palette swapping not working

I’ve made a character with every pixel in a different color and laid out his clothing to create a template. I want this one to be a caveman, so I used the template and desired outcome should be this (the rest of the palette is for the back):
8378919--1104735--upload_2022-8-21_17-58-46.png8378919--1104732--upload_2022-8-21_17-58-36.png8378919--1104738--upload_2022-8-21_17-58-59.png8378919--1104741--upload_2022-8-21_17-59-15.png
Here’s the script for color changing(map is the colorful template, sheet is caveman clothing):

    public Texture2D map, sheet;
    Color[] sheetPixels, mapPixels;
    public static Dictionary<Color, Color> Colors = new Dictionary<Color, Color>();

    void Start()
    {
        sheetPixels = sheet.GetPixels();
        mapPixels = map.GetPixels();
        for (int i = 0; i < mapPixels.Length; i++)
        {
            if (mapPixels[i].a != 0)
            {
                Colors.Add(mapPixels[i], sheetPixels[i]);
            }
        }
        Texture2D currentTexture = GetComponent<SpriteRenderer>().sprite.texture;
        for (int y = 0; y < currentTexture.height; y++)
        {
            for (int x = 0; x < currentTexture.width; x++)
            {
                Color currentColor = currentTexture.GetPixel(x, y);
                if (Colors.ContainsKey(currentColor))
                {
                    currentTexture.SetPixel(x, y, Colors[currentColor]);
                }
            }
        }
        currentTexture.Apply();
    }

However, when I run it only some of the pixels get swapped. Do you have any idea why that happens and how to prevent that?
8378919--1104744--upload_2022-8-21_18-3-22.png

As I thought, the issue was float precision. I rounded up the RGB values and now it works perfectly.