TSC4 commited on
Commit
e764d27
·
verified ·
1 Parent(s): 0ef9422

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +13 -0
app.py CHANGED
@@ -65,6 +65,19 @@ def remove_background_color(image, hex_color, tolerance):
65
  alpha_channel = np.where(mask, 0, 255)
66
  data[:, :, 3] = alpha_channel
67
  return data
 
 
 
 
 
 
 
 
 
 
 
 
 
68
 
69
  # Deploy using Gradio Client
70
  iface = gr.Interface(
 
65
  alpha_channel = np.where(mask, 0, 255)
66
  data[:, :, 3] = alpha_channel
67
  return data
68
+ def color_remover_interface(image, hex_color, tolerance, _=None):
69
+ """
70
+ Gradio interface function for color removal.
71
+ """
72
+ try:
73
+ if image is None:
74
+ raise ValueError("Please upload an image")
75
+ hex_color = sanitize_hex_color(hex_color)
76
+ processed_image = remove_background_color(image, hex_color, tolerance)
77
+ return processed_image # Return only the processed image
78
+ except Exception as e:
79
+ gr.Warning(str(e))
80
+ return image # Return original image in case of error
81
 
82
  # Deploy using Gradio Client
83
  iface = gr.Interface(