juancopi81 commited on
Commit
11e63a0
1 Parent(s): 9f994e9

Use of Tableau color

Browse files
Files changed (2) hide show
  1. app.py +1 -11
  2. utils.py +4 -4
app.py CHANGED
@@ -127,14 +127,4 @@ with demo:
127
  gr.Markdown(article)
128
 
129
 
130
- demo.launch()
131
-
132
- """ gr.Interface(
133
- inference,
134
- gr.inputs.Audio(type="filepath", label="Input"),
135
- [gr.outputs.File(label="Output")],
136
- title=title,
137
- description=description,
138
- article=article,
139
- examples=examples,
140
- ).launch().queue() """
 
127
  gr.Markdown(article)
128
 
129
 
130
+ demo.launch()
 
 
 
 
 
 
 
 
 
 
utils.py CHANGED
@@ -3,6 +3,7 @@ import collections
3
 
4
  import pandas as pd
5
  import matplotlib.pyplot as plt
 
6
  from matplotlib.patches import Rectangle
7
  from PIL import Image
8
 
@@ -21,7 +22,7 @@ def sequence_to_pandas_dataframe(sequence):
21
  pd_dict["end_time"].append(note.end_time)
22
  pd_dict["duration"].append(note.end_time - note.start_time)
23
  pd_dict["pitch"].append(note.pitch)
24
- pd_dict['instrument'].append(note.instrument)
25
 
26
  return pd.DataFrame(pd_dict)
27
 
@@ -29,9 +30,8 @@ def dataframe_to_pianoroll_img(df):
29
  fig = plt.figure(figsize=(8, 5))
30
  ax = fig.add_subplot(111)
31
  ax.scatter(df.start_time, df.pitch, c="white")
32
- colors = plt.get_cmap("tab20")
33
- print(df["instrument"].unique())
34
- colordict = {inst: colors[i] for i, inst in enumerate(df["instrument"].unique())}
35
  for _, row in df.iterrows():
36
  ax.add_patch(Rectangle((row["start_time"],
37
  row["pitch"]-0.4),
 
3
 
4
  import pandas as pd
5
  import matplotlib.pyplot as plt
6
+ import matplotlib.colors as mcolors
7
  from matplotlib.patches import Rectangle
8
  from PIL import Image
9
 
 
22
  pd_dict["end_time"].append(note.end_time)
23
  pd_dict["duration"].append(note.end_time - note.start_time)
24
  pd_dict["pitch"].append(note.pitch)
25
+ pd_dict["instrument"].append(note.instrument)
26
 
27
  return pd.DataFrame(pd_dict)
28
 
 
30
  fig = plt.figure(figsize=(8, 5))
31
  ax = fig.add_subplot(111)
32
  ax.scatter(df.start_time, df.pitch, c="white")
33
+ print(mcolors.TABLEAU_COLORS)
34
+ colordict = {inst: mcolors.TABLEAU_COLORS[i] for i, inst in enumerate(df["instrument"].unique())}
 
35
  for _, row in df.iterrows():
36
  ax.add_patch(Rectangle((row["start_time"],
37
  row["pitch"]-0.4),