marquesafonso commited on
Commit
1f7b6ee
·
1 Parent(s): 13e08a8

switch to matplotlib t_hex function

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -2,19 +2,18 @@ import gradio as gr
2
  import numpy as np
3
  import matplotlib.pyplot as plt
4
  from matplotlib.animation import FuncAnimation
 
5
  import librosa
6
  import tempfile
7
 
8
- def rgba_to_hex(r, g, b, a):
9
- return f'#{r:02x}{g:02x}{b:02x}{a:02x}'
10
-
11
  def check_rgba(string:str):
12
  if '#' in string:
13
  return string
14
  else:
15
  clean_str_list = string.split("(")[1].split(")")[0].split(",")
16
- print(clean_str_list)
17
- hex = rgba_to_hex(float(clean_str_list[0].strip()), float(clean_str_list[1].strip()), float(clean_str_list[2].strip()), float(clean_str_list[3].strip()))
 
18
  print(hex)
19
  return hex
20
 
 
2
  import numpy as np
3
  import matplotlib.pyplot as plt
4
  from matplotlib.animation import FuncAnimation
5
+ from matplotlib.colors import to_hex
6
  import librosa
7
  import tempfile
8
 
 
 
 
9
  def check_rgba(string:str):
10
  if '#' in string:
11
  return string
12
  else:
13
  clean_str_list = string.split("(")[1].split(")")[0].split(",")
14
+ clean_list = [float(i.strip()) for i in clean_str_list]
15
+ print(clean_list)
16
+ hex = to_hex(clean_list, keep_alpha=True)
17
  print(hex)
18
  return hex
19