Nik Ska commited on
Commit
3f31a6c
1 Parent(s): 4764ad4

Added square/stories format

Browse files
Files changed (1) hide show
  1. app.py +20 -9
app.py CHANGED
@@ -32,15 +32,25 @@ def get_mask(img_in):
32
  if response.status_code == 200:
33
  result = response.json()
34
 
35
- mask = Image.open(io.BytesIO(base64.b64decode(
36
- result['mask']))).resize(img_in.size)
 
 
37
 
38
- return (mask, result['emotion'])
39
  else:
40
  print(f"ERROR: {response.json()['detail']}")
41
  raise gr.Error(response.json()['detail'])
42
 
43
 
 
 
 
 
 
 
 
 
44
  footer = r"""
45
  <center>
46
  <b>
@@ -50,18 +60,19 @@ DEMO FOR BG REMOVAL
50
  """
51
 
52
  with gr.Blocks(title="ARKA + TikTok Demo") as app:
53
- gr.HTML("<center><h1>ARKA Remove Background</h1></center>")
 
 
54
  with gr.Row():
55
  with gr.Column():
56
  input_img = gr.Image(type="pil", label="Input image")
57
- # new_img = gr.Image(type="pil", label="Custom background")
58
  with gr.Column():
59
- output_img = gr.Image(type="pil", label="result")
 
 
60
  emotion = gr.Label(label="emotion")
61
- with gr.Row():
62
- run_btn = gr.Button(variant="primary")
63
 
64
- run_btn.click(get_mask, [input_img], [output_img, emotion])
65
 
66
  with gr.Row():
67
  gr.HTML(footer)
 
32
  if response.status_code == 200:
33
  result = response.json()
34
 
35
+ img_square = Image.open(io.BytesIO(base64.b64decode(
36
+ result['square'])))
37
+ img_stories = Image.open(io.BytesIO(base64.b64decode(
38
+ result['stories'])))
39
 
40
+ return (img_square, img_stories, result['emotion'])
41
  else:
42
  print(f"ERROR: {response.json()['detail']}")
43
  raise gr.Error(response.json()['detail'])
44
 
45
 
46
+ header = r"""
47
+ <center>
48
+ <h1>ARKA Selfie App</h1>
49
+ <p>Send this app a selfie to add a custom background and elements to it.</p>
50
+ <p>It also detects and displays human emotions and works anywhere.</p>
51
+ </center>
52
+ """
53
+
54
  footer = r"""
55
  <center>
56
  <b>
 
60
  """
61
 
62
  with gr.Blocks(title="ARKA + TikTok Demo") as app:
63
+ gr.HTML(header)
64
+ with gr.Row():
65
+ run_btn = gr.Button(variant="primary", interactive=True, label="Run")
66
  with gr.Row():
67
  with gr.Column():
68
  input_img = gr.Image(type="pil", label="Input image")
 
69
  with gr.Column():
70
+ with gr.Row():
71
+ output_img = gr.Image(type="pil", label="result_square")
72
+ output_img1 = gr.Image(type="pil", label="result_stories")
73
  emotion = gr.Label(label="emotion")
 
 
74
 
75
+ run_btn.click(get_mask, [input_img], [output_img, output_img1, emotion])
76
 
77
  with gr.Row():
78
  gr.HTML(footer)