dvir-bria commited on
Commit
45299c9
·
verified ·
1 Parent(s): 5c1f39b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -13
app.py CHANGED
@@ -22,14 +22,14 @@ def download_image(url):
22
  response = requests.get(url)
23
  return Image.open(BytesIO(response.content)).convert("RGB")
24
 
25
- def eraser_api_call(image_base64_file, mask_base64_file, mask_type):
26
 
27
- url = "http://engine.prod.bria-api.com/v1/eraser"
28
 
29
  payload = {
30
  "file": image_base64_file,
31
  "mask_file": mask_base64_file,
32
- "mask_type": mask_type,
33
  }
34
  response = requests.post(url, json=payload, headers=auth_headers)
35
  response = response.json()
@@ -47,7 +47,7 @@ def predict(dict):
47
  mask_base64_file = convert_mask_image_to_base64_string(mask)
48
 
49
  mask_type = "manual"
50
- gen_img = eraser_api_call(image_base64_file, mask_base64_file, mask_type)
51
 
52
  return gen_img
53
 
@@ -102,12 +102,12 @@ div#share-btn-container > div {flex-direction: row;background: black;align-items
102
  image_blocks = gr.Blocks(css=css, elem_id="total-container")
103
  with image_blocks as demo:
104
  with gr.Column(elem_id="col-container"):
105
- gr.Markdown("## BRIA Eraser API")
106
  gr.HTML('''
107
  <p style="margin-bottom: 10px; font-size: 94%">
108
- This demo showcases the BRIA Eraser capability, which allows users to remove specific elements or objects from images.<br>
109
  The pipeline comprises multiple components, including <a href="https://huggingface.co/briaai/BRIA-2.3" target="_blank">briaai/BRIA-2.3</a>,
110
- <a href="https://huggingface.co/briaai/BRIA-2.3-ControlNet-Inpainting" target="_blank">briaai/BRIA-2.3-ControlNet-Inpainting</a>,
111
  and <a href="https://huggingface.co/briaai/BRIA-2.3-FAST-LORA" target="_blank">briaai/BRIA-2.3-FAST-LORA</a>, all trained on licensed data.<br>
112
  This ensures full legal liability coverage for copyright and privacy infringement.<br>
113
  Notes:<br>
@@ -115,21 +115,22 @@ with image_blocks as demo:
115
  - For multiple masks, results are better if all masks are included in inference.<br>
116
  </p>
117
  ''')
 
118
  with gr.Row():
119
  with gr.Column():
120
  image = gr.ImageEditor(sources=["upload"], layers=False, transforms=[],
121
  brush=gr.Brush(colors=["#000000"], color_mode="fixed"),
122
  )
 
123
  with gr.Row(elem_id="prompt-container", equal_height=True):
124
- with gr.Column(): # Wrap the button inside a Column
125
- btn = gr.Button("Erase!", elem_id="run_button")
126
 
127
  with gr.Column():
128
  image_out = gr.Image(label="Output", elem_id="output-img")
129
 
130
- # Button click will trigger the inpainting function (no prompt required)
131
- btn.click(fn=predict, inputs=[image], outputs=[image_out], api_name='run')
132
-
133
 
134
  gr.HTML(
135
  """
@@ -140,4 +141,4 @@ with image_blocks as demo:
140
  """
141
  )
142
 
143
- image_blocks.queue(max_size=25,api_open=False).launch(show_api=False)
 
22
  response = requests.get(url)
23
  return Image.open(BytesIO(response.content)).convert("RGB")
24
 
25
+ def gen_fill_api_call(image_base64_file, mask_base64_file, prompt):
26
 
27
+ url = "http://engine.int.bria-api.com/v1/gen_fill"
28
 
29
  payload = {
30
  "file": image_base64_file,
31
  "mask_file": mask_base64_file,
32
+ "prompt": prompt,
33
  }
34
  response = requests.post(url, json=payload, headers=auth_headers)
35
  response = response.json()
 
47
  mask_base64_file = convert_mask_image_to_base64_string(mask)
48
 
49
  mask_type = "manual"
50
+ gen_img = gen_fill_api_call(image_base64_file, mask_base64_file, mask_type)
51
 
52
  return gen_img
53
 
 
102
  image_blocks = gr.Blocks(css=css, elem_id="total-container")
103
  with image_blocks as demo:
104
  with gr.Column(elem_id="col-container"):
105
+ gr.Markdown("## BRIA Generative Fill API")
106
  gr.HTML('''
107
  <p style="margin-bottom: 10px; font-size: 94%">
108
+ This demo showcases the BRIA Generative Fill capability, which allows users to remove specific elements or objects from images.<br>
109
  The pipeline comprises multiple components, including <a href="https://huggingface.co/briaai/BRIA-2.3" target="_blank">briaai/BRIA-2.3</a>,
110
+ <a href="https://huggingface.co/briaai/BRIA-2.3-ControlNet-Generative-Fill" target="_blank">briaai/BRIA-2.3-ControlNet-Generative-Fill</a>,
111
  and <a href="https://huggingface.co/briaai/BRIA-2.3-FAST-LORA" target="_blank">briaai/BRIA-2.3-FAST-LORA</a>, all trained on licensed data.<br>
112
  This ensures full legal liability coverage for copyright and privacy infringement.<br>
113
  Notes:<br>
 
115
  - For multiple masks, results are better if all masks are included in inference.<br>
116
  </p>
117
  ''')
118
+
119
  with gr.Row():
120
  with gr.Column():
121
  image = gr.ImageEditor(sources=["upload"], layers=False, transforms=[],
122
  brush=gr.Brush(colors=["#000000"], color_mode="fixed"),
123
  )
124
+ prompt = gr.Textbox(label="Prompt", placeholder="Enter your prompt here...")
125
  with gr.Row(elem_id="prompt-container", equal_height=True):
126
+ with gr.Column():
127
+ btn = gr.Button("Fill!", elem_id="run_button")
128
 
129
  with gr.Column():
130
  image_out = gr.Image(label="Output", elem_id="output-img")
131
 
132
+ # Button click will trigger the inpainting function (now with prompt included)
133
+ btn.click(fn=predict, inputs=[image, prompt], outputs=[image_out], api_name='run')
 
134
 
135
  gr.HTML(
136
  """
 
141
  """
142
  )
143
 
144
+ image_blocks.queue(max_size=25, api_open=False).launch(show_api=False)