Nik Ska commited on
Commit
24a1a2f
1 Parent(s): 4e11f86

Moved BG to API site

Browse files
.DS_Store CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
 
app.py CHANGED
@@ -13,7 +13,6 @@ from dotenv import load_dotenv
13
 
14
  load_dotenv()
15
 
16
-
17
  def get_mask(img_in):
18
 
19
  # print(f"{img_in=}")
@@ -33,34 +32,32 @@ def get_mask(img_in):
33
  if 'error' in response.json():
34
  print(f"ERROR: {response.json()['error']}")
35
  raise gr.Error(response.json()['error'])
36
- return (None, None)
37
 
38
  result = response.json()
39
  # print('Result:', result)
40
 
41
- all_bgs = list(Path("examples").glob("*.jpg"))
42
 
43
- bg_img = Image.open(choice(all_bgs)).convert(
44
- "RGBA").resize(img_in.size)
45
 
46
- bg_img = ImageOps.fit(
47
- bg_img,
48
- img_in.size,
49
- Image.ANTIALIAS
50
- )
51
 
52
  mask = Image.open(io.BytesIO(base64.b64decode(
53
  result['mask']))).resize(img_in.size)
54
 
55
- img_in = ImageOps.autocontrast(img_in, cutoff=0.1).convert("RGBA")
56
- img_in.putalpha(mask)
57
 
58
- img_in = Image.alpha_composite(bg_img, img_in)
59
 
60
- return (img_in, result['emotion'])
61
  else:
62
  raise gr.Error(response.text)
63
- return (None, None)
64
 
65
 
66
  footer = r"""
@@ -71,7 +68,7 @@ DEMO FOR BG REMOVAL
71
  </center>
72
  """
73
 
74
- with gr.Blocks(title="Face Shine") as app:
75
  gr.HTML("<center><h1>ARKA Remove Background</h1></center>")
76
  with gr.Row():
77
  with gr.Column():
 
13
 
14
  load_dotenv()
15
 
 
16
  def get_mask(img_in):
17
 
18
  # print(f"{img_in=}")
 
32
  if 'error' in response.json():
33
  print(f"ERROR: {response.json()['error']}")
34
  raise gr.Error(response.json()['error'])
 
35
 
36
  result = response.json()
37
  # print('Result:', result)
38
 
39
+ # all_bgs = list(Path("examples").glob("*.jpg"))
40
 
41
+ # bg_img = Image.open(choice(all_bgs)).convert(
42
+ # "RGBA")
43
 
44
+ # bg_img = ImageOps.fit(
45
+ # bg_img,
46
+ # img_in.size,
47
+ # Image.ANTIALIAS
48
+ # )
49
 
50
  mask = Image.open(io.BytesIO(base64.b64decode(
51
  result['mask']))).resize(img_in.size)
52
 
53
+ # img_in = ImageOps.autocontrast(img_in, cutoff=0.1).convert("RGBA")
54
+ # img_in.putalpha(mask)
55
 
56
+ # img_in = Image.alpha_composite(bg_img, img_in)
57
 
58
+ return (mask, result['emotion'])
59
  else:
60
  raise gr.Error(response.text)
 
61
 
62
 
63
  footer = r"""
 
68
  </center>
69
  """
70
 
71
+ with gr.Blocks(title="ARKA + TikTok Demo") as app:
72
  gr.HTML("<center><h1>ARKA Remove Background</h1></center>")
73
  with gr.Row():
74
  with gr.Column():
examples/.DS_Store DELETED
Binary file (6.15 kB)
 
examples/bg_0.jpg DELETED
Binary file (85.5 kB)
 
examples/bg_1.jpg DELETED
Binary file (103 kB)
 
examples/bg_10.jpg DELETED
Binary file (418 kB)
 
examples/bg_11.jpg DELETED
Binary file (445 kB)
 
examples/bg_12.jpg DELETED
Binary file (263 kB)
 
examples/bg_13.jpg DELETED
Binary file (101 kB)
 
examples/bg_14.jpg DELETED
Binary file (77.3 kB)
 
examples/bg_15.jpg DELETED
Binary file (149 kB)
 
examples/bg_16.jpg DELETED
Binary file (81.8 kB)
 
examples/bg_17.jpg DELETED
Binary file (177 kB)
 
examples/bg_2.jpg DELETED
Binary file (87.9 kB)
 
examples/bg_3.jpg DELETED
Binary file (153 kB)
 
examples/bg_4.jpg DELETED
Binary file (134 kB)
 
examples/bg_5.jpg DELETED
Binary file (87 kB)
 
examples/bg_6.jpg DELETED
Binary file (93.2 kB)
 
examples/bg_7.jpg DELETED
Binary file (68.8 kB)
 
examples/bg_8.jpg DELETED
Binary file (115 kB)
 
examples/bg_9.jpg DELETED
Binary file (97.4 kB)