amirgame197 commited on
Commit
f7ecb0c
1 Parent(s): baa4127

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -14,9 +14,16 @@ from transparent_background import Remover
14
  @spaces.GPU()
15
  def doo(video, color, mode, progress=gr.Progress()):
16
  print(color)
17
- color = color.lstrip('#')
18
- rgb = tuple(int(color[i:i+2], 16) for i in (0, 2, 4))
19
- color = str(list(rgb))
 
 
 
 
 
 
 
20
  if mode == 'Fast':
21
  remover = Remover(mode='fast')
22
  else:
 
14
  @spaces.GPU()
15
  def doo(video, color, mode, progress=gr.Progress()):
16
  print(color)
17
+ if color.startswith('#'):
18
+ color = color.lstrip('#')
19
+ rgb = tuple(int(color[i:i+2], 16) for i in (0, 2, 4))
20
+ color = str(list(rgb))
21
+ elif color.startswith('rgba'):
22
+ rgba_match = re.match(r'rgba\((\d+), (\d+), (\d+), ([\d.]+)\)', color)
23
+ if rgba_match:
24
+ r, g, b, _ = rgba_match.groups()
25
+ color = str([int(r), int(g), int(b)])
26
+ print(color)
27
  if mode == 'Fast':
28
  remover = Remover(mode='fast')
29
  else: