not-lain commited on
Commit
81b6033
1 Parent(s): 90613ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -1,18 +1,26 @@
1
  import gradio as gr
2
  from gradio_imageslider import ImageSlider
3
- from PIL import ImageFilter
4
-
 
5
 
6
  def fn(im):
7
  if not im or not im[0]:
8
  return im
9
- return (im[0], im[0].filter(filter=ImageFilter.GaussianBlur(radius=10)))
 
 
 
 
 
 
10
 
11
 
12
  with gr.Blocks() as demo:
 
13
  with gr.Group():
14
- img1 = ImageSlider(label="Blur image", type="pil")
15
  img1.upload(fn, inputs=img1, outputs=img1)
16
 
17
  if __name__ == "__main__":
18
- demo.launch()
 
1
  import gradio as gr
2
  from gradio_imageslider import ImageSlider
3
+ from loadimg import load_img
4
+ from transformers import pipeline
5
+ pipe = pipeline("image-segmentation", model="briaai/RMBG-1.4", trust_remote_code=True)
6
 
7
  def fn(im):
8
  if not im or not im[0]:
9
  return im
10
+ # avoid problems when working with images that are actually RGBA
11
+ im = im[0].convert('RGB')
12
+ path = load_img(im,output_type="str")
13
+ rmbg = pipe(path)
14
+ # rmbg_path = load_img(rmbg,output_type="str")
15
+ out = (im,rmbg)
16
+ return out
17
 
18
 
19
  with gr.Blocks() as demo:
20
+ gr.Markdown("# RMBG1.4 tutorial")
21
  with gr.Group():
22
+ img1 = ImageSlider(label="RMBG", type="pil")
23
  img1.upload(fn, inputs=img1, outputs=img1)
24
 
25
  if __name__ == "__main__":
26
+ demo.launch(debug=True)