Spaces:
fantos
/
Runtime error

arxivgpt kim commited on
Commit
5801493
·
verified ·
1 Parent(s): dc146a8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -10
app.py CHANGED
@@ -22,7 +22,7 @@ def resize_image(image, model_input_size=(1024, 1024)):
22
  image = image.resize(model_input_size, Image.BILINEAR)
23
  return image
24
 
25
- def process(image):
26
  # prepare input
27
  orig_image = Image.fromarray(image).convert("RGBA")
28
  w, h = orig_im_size = orig_image.size
@@ -47,7 +47,7 @@ def process(image):
47
  final_image = Image.new("RGBA", orig_image.size)
48
  final_image.paste(orig_image, mask=mask_image)
49
 
50
- return final_image
51
 
52
 
53
  def merge_images(background_image, foreground_image):
@@ -74,17 +74,13 @@ def merge_images(background_image, foreground_image):
74
  return background
75
 
76
 
77
- # Gradio 인터페이스 정의
78
  demo = gr.Interface(
79
  fn=process,
80
  inputs=[
81
- gr.Image(type="numpy", label="Image to remove background"),
82
- gr.Image(type="pil", label="Optional: Background Image")
83
  ],
84
  outputs="image",
85
- title="Background Removal",
86
- description="This is a demo for BRIA RMBG 1.4 that uses the BRIA RMBG-1.4 image matting model as backbone."
87
  )
88
-
89
- if __name__ == "__main__":
90
- demo.launch()
 
22
  image = image.resize(model_input_size, Image.BILINEAR)
23
  return image
24
 
25
+ def process(image, background_image=None):
26
  # prepare input
27
  orig_image = Image.fromarray(image).convert("RGBA")
28
  w, h = orig_im_size = orig_image.size
 
47
  final_image = Image.new("RGBA", orig_image.size)
48
  final_image.paste(orig_image, mask=mask_image)
49
 
50
+ return new_im # or any other variable you wish to return
51
 
52
 
53
  def merge_images(background_image, foreground_image):
 
74
  return background
75
 
76
 
 
77
  demo = gr.Interface(
78
  fn=process,
79
  inputs=[
80
+ gr.Image(type="numpy", label="Image to remove background"), # 첫 번째 인자
81
+ gr.Image(type="pil", label="Optional: Background Image", optional=True) # 두 번째 인자, 선택적
82
  ],
83
  outputs="image",
84
+ title=title,
85
+ description=description
86
  )