vaniv commited on
Commit
764e2fe
·
verified ·
1 Parent(s): dd0e817

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
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
- hsv_colors = [colorsys.rgb_to_hsv(r, g, b)]
 
51
  for i in range(1, num_shades):
52
- hsv_colors.append((hsv_colors[-1][0], hsv_colors[-1][1], hsv_colors[-1][2] * (1 - 0.2 * i)))
53
  hex_palette = [mcolors.rgb2hex(colorsys.hsv_to_rgb(*hsv)) for hsv in hsv_colors]
54
- named_palette = [mcolors.rgb2hex(mcolors.hsv_to_rgb(*colorsys.rgb_to_hsv(*mcolors.hex2color(hex_color)))) for hex_color in hex_palette]
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" {mcolors.CSS4_COLORS.get(color, color)},"
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