ghostsInTheMachine commited on
Commit
63d9326
·
verified ·
1 Parent(s): 6bafd2d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -10
app.py CHANGED
@@ -16,8 +16,18 @@ class WhiteTheme(Base):
16
  self,
17
  *,
18
  primary_hue: colors.Color | str = colors.orange,
19
- font: fonts.Font | str = fonts.GoogleFont("Inter"),
20
- font_mono: fonts.Font | str = fonts.GoogleFont("Inter")
 
 
 
 
 
 
 
 
 
 
21
  ):
22
  super().__init__(
23
  primary_hue=primary_hue,
@@ -34,24 +44,21 @@ class WhiteTheme(Base):
34
  block_border_color="white",
35
  panel_border_color="white",
36
  input_border_color="lightgray",
 
37
  button_primary_background_fill="*primary_500",
38
  button_primary_background_fill_hover="*primary_600",
39
  button_primary_text_color="white",
40
  button_secondary_background_fill="white",
41
  button_secondary_border_color="lightgray",
42
- block_shadow="none",
43
- button_shadow="none",
44
- input_shadow="none",
45
  slider_color="*primary_500",
46
- slider_track_color="lightgray",
47
  )
48
 
49
- # Your existing setup code
50
  torch.set_float32_matmul_precision('high')
51
  torch.jit.script = lambda f: f
 
52
  device = "cuda" if torch.cuda.is_available() else "cpu"
53
 
54
- # Keep all your existing functions unchanged
55
  def refine_foreground(image, mask, r=90):
56
  if mask.size != image.size:
57
  mask = mask.resize(image.size)
@@ -149,12 +156,11 @@ custom_css = """
149
  animation: gradient-animation 15s ease infinite;
150
  border-radius: 12px;
151
  color: black;
152
- font-family: 'Inter', sans-serif;
153
  }
154
  """
155
 
156
- # Create the interface with the custom theme
157
  with gr.Blocks(css=custom_css, theme=WhiteTheme()) as demo:
 
158
  with gr.Row():
159
  with gr.Column():
160
  image_input = gr.Image(type="numpy", sources=['upload'], label="Upload Image")
@@ -165,6 +171,7 @@ with gr.Blocks(css=custom_css, theme=WhiteTheme()) as demo:
165
  output_foreground_mask = gr.Image(type="pil", label="Foreground Mask")
166
  output_background_mask = gr.Image(type="pil", label="Background Mask")
167
 
 
168
  btn.click(fn=remove_background_wrapper, inputs=image_input, outputs=[
169
  output_foreground, output_background, output_foreground_mask, output_background_mask])
170
 
 
16
  self,
17
  *,
18
  primary_hue: colors.Color | str = colors.orange,
19
+ font: fonts.Font | str | tuple[fonts.Font | str, ...] = (
20
+ fonts.GoogleFont("Inter"),
21
+ "ui-sans-serif",
22
+ "system-ui",
23
+ "sans-serif",
24
+ ),
25
+ font_mono: fonts.Font | str | tuple[fonts.Font | str, ...] = (
26
+ fonts.GoogleFont("Inter"),
27
+ "ui-monospace",
28
+ "system-ui",
29
+ "monospace",
30
+ )
31
  ):
32
  super().__init__(
33
  primary_hue=primary_hue,
 
44
  block_border_color="white",
45
  panel_border_color="white",
46
  input_border_color="lightgray",
47
+ shadow_drop="none",
48
  button_primary_background_fill="*primary_500",
49
  button_primary_background_fill_hover="*primary_600",
50
  button_primary_text_color="white",
51
  button_secondary_background_fill="white",
52
  button_secondary_border_color="lightgray",
 
 
 
53
  slider_color="*primary_500",
54
+ slider_track_color="lightgray"
55
  )
56
 
 
57
  torch.set_float32_matmul_precision('high')
58
  torch.jit.script = lambda f: f
59
+
60
  device = "cuda" if torch.cuda.is_available() else "cpu"
61
 
 
62
  def refine_foreground(image, mask, r=90):
63
  if mask.size != image.size:
64
  mask = mask.resize(image.size)
 
156
  animation: gradient-animation 15s ease infinite;
157
  border-radius: 12px;
158
  color: black;
 
159
  }
160
  """
161
 
 
162
  with gr.Blocks(css=custom_css, theme=WhiteTheme()) as demo:
163
+ # Interface setup with input and output
164
  with gr.Row():
165
  with gr.Column():
166
  image_input = gr.Image(type="numpy", sources=['upload'], label="Upload Image")
 
171
  output_foreground_mask = gr.Image(type="pil", label="Foreground Mask")
172
  output_background_mask = gr.Image(type="pil", label="Background Mask")
173
 
174
+ # Link the button to the processing function
175
  btn.click(fn=remove_background_wrapper, inputs=image_input, outputs=[
176
  output_foreground, output_background, output_foreground_mask, output_background_mask])
177