abdullahalioo commited on
Commit
db67721
·
verified ·
1 Parent(s): fa74d23

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -10
app.py CHANGED
@@ -3,18 +3,29 @@ from transformers import pipeline
3
  from PIL import Image
4
 
5
  def remove_background(image):
6
- pipe = pipeline('image-segmentation', model='briaai/RMBG-1.4',trust_remote_code=True)
7
- pillow_mask = pipe(image, return_mask=True)
8
- pillow_image = pipe(image)
9
- return pillow_image
10
 
 
11
  app = gr.Interface(
12
- fn= remove_background, #função
13
- inputs= gr.components.Image(type='pil'), #entrada (anexo do usuário)
14
- outputs= gr.components.Image(type='pil', format='png'), #saida (download da imagem sem fundo no formato PNG)
15
- title= 'Remove image background',
16
- description= 'Remove backgrounds from photos automatically in seconds - 100% free, no watermarks, works on any device!'
17
  )
18
 
 
 
 
 
 
 
19
  if __name__ == "__main__":
20
- app.launch(share=True) # Disables the API option
 
 
 
 
 
3
  from PIL import Image
4
 
5
  def remove_background(image):
6
+ pipe = pipeline('image-segmentation', model='briaai/RMBG-1.4', trust_remote_code=True)
7
+ pillow_mask = pipe(image, return_mask=True)
8
+ pillow_image = pipe(image)
9
+ return pillow_image
10
 
11
+ # Custom CSS to hide Gradio branding and adjust margins
12
  app = gr.Interface(
13
+ fn=remove_background,
14
+ inputs=gr.components.Image(type='pil'),
15
+ outputs=gr.components.Image(type='pil', format='png'),
16
+ title='Remove image background',
17
+ description='Remove backgrounds from photos automatically in seconds - 100% free, no watermarks, works on any device!'
18
  )
19
 
20
+ # Remove Gradio footer and API options
21
+ app.css = """
22
+ footer {display: none !important;}
23
+ .gradio-container {margin-bottom: 0 !important;}
24
+ """
25
+
26
  if __name__ == "__main__":
27
+ app.launch(
28
+ share=True, # Optional: Remove if you don't need sharing
29
+ show_api=False, # Hides the "Use via API" option
30
+ show_tips=False # Disables Gradio tips for cleaner UI
31
+ )