duongthienz commited on
Commit
687b576
·
verified ·
1 Parent(s): 76701a8

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +1 -20
utils.py CHANGED
@@ -376,32 +376,13 @@ def _voice_color_map(df5_labels, speaker_color_map):
376
  return color_map
377
 
378
 
379
- def _dim_color_map(color_map, sat_factor=0.75, val_factor=0.88):
380
- """Reduce saturation/brightness of all colors in a map to match bar/timeline rendering."""
381
- import colorsys
382
- result = {}
383
- for lbl, hex_color in color_map.items():
384
- try:
385
- h = hex_color.lstrip('#')
386
- r, g, b = int(h[0:2],16)/255, int(h[2:4],16)/255, int(h[4:6],16)/255
387
- hue, sat, val = colorsys.rgb_to_hsv(r, g, b)
388
- sat = min(sat * sat_factor, 1.0)
389
- val = min(val * val_factor, 1.0)
390
- r2, g2, b2 = colorsys.hsv_to_rgb(hue, sat, val)
391
- result[lbl] = f"#{int(r2*255):02X}{int(g2*255):02X}{int(b2*255):02X}"
392
- except Exception:
393
- result[lbl] = hex_color
394
- return result
395
-
396
-
397
  def build_fig_sunburst(df5, catTypeColors, speaker_color_map, get_display_name_fn, currFile):
398
  """Sunburst voice-category chart."""
399
  df5 = df5.copy()
400
  df5["labels"] = df5["labels"].apply(lambda s: get_display_name_fn(s, currFile))
401
  df5["parentNames"] = df5["parentNames"].apply(lambda s: get_display_name_fn(s, currFile))
402
 
403
- # Dim colors to match the visual brightness of bar/timeline charts
404
- color_map = _dim_color_map(_voice_color_map(df5["labels"], speaker_color_map))
405
 
406
  fig = px.sunburst(
407
  df5,
 
376
  return color_map
377
 
378
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
379
  def build_fig_sunburst(df5, catTypeColors, speaker_color_map, get_display_name_fn, currFile):
380
  """Sunburst voice-category chart."""
381
  df5 = df5.copy()
382
  df5["labels"] = df5["labels"].apply(lambda s: get_display_name_fn(s, currFile))
383
  df5["parentNames"] = df5["parentNames"].apply(lambda s: get_display_name_fn(s, currFile))
384
 
385
+ color_map = _voice_color_map(df5["labels"], speaker_color_map)
 
386
 
387
  fig = px.sunburst(
388
  df5,