Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -47,11 +47,12 @@ def get_complementary_color(rgb_color):
|
|
| 47 |
def get_monochromatic_palette(color_name, num_shades=3):
|
| 48 |
rgb_color = mcolors.CSS4_COLORS[color_name]
|
| 49 |
r, g, b = mcolors.hex2color(rgb_color)
|
| 50 |
-
|
|
|
|
| 51 |
for i in range(1, num_shades):
|
| 52 |
-
hsv_colors.append((
|
| 53 |
hex_palette = [mcolors.rgb2hex(colorsys.hsv_to_rgb(*hsv)) for hsv in hsv_colors]
|
| 54 |
-
named_palette = [mcolors.
|
| 55 |
|
| 56 |
return named_palette
|
| 57 |
|
|
@@ -79,7 +80,7 @@ def predict(image):
|
|
| 79 |
output += "\n"
|
| 80 |
output += f"Monochromatic options:"
|
| 81 |
for color in monochromatic_options:
|
| 82 |
-
output += f" {
|
| 83 |
output = output[:-1] # Removes the last comma
|
| 84 |
output += "."
|
| 85 |
|
|
|
|
| 47 |
def get_monochromatic_palette(color_name, num_shades=3):
|
| 48 |
rgb_color = mcolors.CSS4_COLORS[color_name]
|
| 49 |
r, g, b = mcolors.hex2color(rgb_color)
|
| 50 |
+
hsv_color = colorsys.rgb_to_hsv(r, g, b)
|
| 51 |
+
hsv_colors = [hsv_color]
|
| 52 |
for i in range(1, num_shades):
|
| 53 |
+
hsv_colors.append((hsv_color[0], hsv_color[1], hsv_color[2] * (1 - 0.2 * i)))
|
| 54 |
hex_palette = [mcolors.rgb2hex(colorsys.hsv_to_rgb(*hsv)) for hsv in hsv_colors]
|
| 55 |
+
named_palette = [mcolors.CSS4_COLORS.get(hex_color, hex_color) for hex_color in hex_palette]
|
| 56 |
|
| 57 |
return named_palette
|
| 58 |
|
|
|
|
| 80 |
output += "\n"
|
| 81 |
output += f"Monochromatic options:"
|
| 82 |
for color in monochromatic_options:
|
| 83 |
+
output += f" {color},"
|
| 84 |
output = output[:-1] # Removes the last comma
|
| 85 |
output += "."
|
| 86 |
|