separate description from model name
Browse files
app.py
CHANGED
|
@@ -7,6 +7,20 @@ import time
|
|
| 7 |
# Set up logging
|
| 8 |
logging.basicConfig(level=logging.INFO)
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
def hex_to_rgba(hex_color):
|
| 11 |
hex_color = hex_color.lstrip('#')
|
| 12 |
if len(hex_color) == 6:
|
|
@@ -72,19 +86,12 @@ iface = gr.Interface(
|
|
| 72 |
fn=remove_background,
|
| 73 |
inputs=[
|
| 74 |
gr.Image(type="pil"),
|
| 75 |
-
gr.ColorPicker(label="Background Color", value=None),
|
| 76 |
-
gr.Dropdown(choices=
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
"silueta | A reduced-size version of u2net (43MB)",
|
| 82 |
-
"sam | A pre-trained model for any use case",
|
| 83 |
-
"unet | lightweight version of u2net model",
|
| 84 |
-
"u2netp | A lightweight version of u2net model",
|
| 85 |
-
"u2net_human_seg | A pre-trained model for human segmentation",
|
| 86 |
-
"u2net_cloth_seg | A pre-trained model for cloth parsing in human portraits",
|
| 87 |
-
], label="Model Selection", value=""),
|
| 88 |
gr.Checkbox(label="Enable Alpha Matting", value=False),
|
| 89 |
gr.Checkbox(label="Post-Process Mask (to post process the mask to get better results)", value=False),
|
| 90 |
gr.Checkbox(label="Only Return Mask ", value=False)
|
|
@@ -93,10 +100,10 @@ iface = gr.Interface(
|
|
| 93 |
gr.Image(type="pil", label="Output Image"),
|
| 94 |
gr.File(label="Download the output image")
|
| 95 |
],
|
| 96 |
-
title="Advanced Background Remover v2.
|
| 97 |
description="Upload an image to remove the background. Customize the result with different options, including background color, model selection, alpha matting, and more.",
|
| 98 |
allow_flagging="never",
|
| 99 |
)
|
| 100 |
|
| 101 |
if __name__ == "__main__":
|
| 102 |
-
iface.launch()
|
|
|
|
| 7 |
# Set up logging
|
| 8 |
logging.basicConfig(level=logging.INFO)
|
| 9 |
|
| 10 |
+
# Define model options with separate names and descriptions
|
| 11 |
+
MODEL_OPTIONS = {
|
| 12 |
+
"": "Select a model",
|
| 13 |
+
"u2net": "A pre-trained model for general use cases (default)",
|
| 14 |
+
"isnet-general-use": "A new pre-trained model for general use cases",
|
| 15 |
+
"isnet-anime": "High-accuracy segmentation for anime characters",
|
| 16 |
+
"silueta": "A reduced-size version of u2net (43MB)",
|
| 17 |
+
"sam": "A pre-trained model for any use case",
|
| 18 |
+
"unet": "Lightweight version of u2net model",
|
| 19 |
+
"u2netp": "A lightweight version of u2net model",
|
| 20 |
+
"u2net_human_seg": "A pre-trained model for human segmentation",
|
| 21 |
+
"u2net_cloth_seg": "A pre-trained model for cloth parsing in human portraits",
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
def hex_to_rgba(hex_color):
|
| 25 |
hex_color = hex_color.lstrip('#')
|
| 26 |
if len(hex_color) == 6:
|
|
|
|
| 86 |
fn=remove_background,
|
| 87 |
inputs=[
|
| 88 |
gr.Image(type="pil"),
|
| 89 |
+
gr.ColorPicker(label="Background Color", value=None),
|
| 90 |
+
gr.Dropdown(choices=list(MODEL_OPTIONS.keys()),
|
| 91 |
+
label="Model Selection",
|
| 92 |
+
value="",
|
| 93 |
+
type="value",
|
| 94 |
+
info=lambda x: MODEL_OPTIONS[x] if x in MODEL_OPTIONS else ""),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
gr.Checkbox(label="Enable Alpha Matting", value=False),
|
| 96 |
gr.Checkbox(label="Post-Process Mask (to post process the mask to get better results)", value=False),
|
| 97 |
gr.Checkbox(label="Only Return Mask ", value=False)
|
|
|
|
| 100 |
gr.Image(type="pil", label="Output Image"),
|
| 101 |
gr.File(label="Download the output image")
|
| 102 |
],
|
| 103 |
+
title="Advanced Background Remover v2.4",
|
| 104 |
description="Upload an image to remove the background. Customize the result with different options, including background color, model selection, alpha matting, and more.",
|
| 105 |
allow_flagging="never",
|
| 106 |
)
|
| 107 |
|
| 108 |
if __name__ == "__main__":
|
| 109 |
+
iface.launch()
|