marco/add_mention_birefnet_with_refactor
#4
by
mearco
- opened
app.py
CHANGED
|
@@ -49,6 +49,15 @@ commit_scheduler = CommitScheduler(
|
|
| 49 |
token=huggingface_token
|
| 50 |
) if is_running_in_space() else None
|
| 51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
def fetch_elo_scores():
|
| 53 |
"""Fetch and log Elo scores."""
|
| 54 |
try:
|
|
@@ -105,14 +114,8 @@ def select_new_image(last_used_indices):
|
|
| 105 |
sample = dataset[random_index]
|
| 106 |
input_image = sample['original_image']
|
| 107 |
|
| 108 |
-
segmented_images = [sample.get(key) for key in
|
| 109 |
-
|
| 110 |
-
'removebg_image', 'birefnet_image'
|
| 111 |
-
]]
|
| 112 |
-
segmented_sources = [
|
| 113 |
-
'Clipdrop', 'BRIA RMBG 2.0', 'Photoroom',
|
| 114 |
-
'RemoveBG', 'BiRefNet v2'
|
| 115 |
-
]
|
| 116 |
|
| 117 |
if segmented_images.count(None) > 2:
|
| 118 |
logging.error("Not enough segmented images found for: %s. Resampling another image.", sample['original_filename'])
|
|
@@ -140,10 +143,11 @@ def select_new_image(last_used_indices):
|
|
| 140 |
def get_notice_markdown():
|
| 141 |
"""Generate the notice markdown with dynamic vote count."""
|
| 142 |
total_votes = len(get_all_votes())
|
|
|
|
| 143 |
return f"""
|
| 144 |
|
| 145 |
## 📜 How It Works
|
| 146 |
-
- **Blind Test**: You will see two images with their background removed from two anonymous background removal models (
|
| 147 |
- **Vote for the Best**: Choose the best result, if none stand out choose "Tie".
|
| 148 |
|
| 149 |
## 📊 Stats
|
|
|
|
| 49 |
token=huggingface_token
|
| 50 |
) if is_running_in_space() else None
|
| 51 |
|
| 52 |
+
# Model configuration mapping
|
| 53 |
+
MODEL_CONFIG = {
|
| 54 |
+
'Clipdrop': 'clipdrop_image',
|
| 55 |
+
'BRIA RMBG 2.0': 'bria_image',
|
| 56 |
+
'Photoroom': 'photoroom_image',
|
| 57 |
+
'RemoveBG': 'removebg_image',
|
| 58 |
+
'BiRefNet v2': 'birefnet_image'
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
def fetch_elo_scores():
|
| 62 |
"""Fetch and log Elo scores."""
|
| 63 |
try:
|
|
|
|
| 114 |
sample = dataset[random_index]
|
| 115 |
input_image = sample['original_image']
|
| 116 |
|
| 117 |
+
segmented_images = [sample.get(key) for key in MODEL_CONFIG.values()]
|
| 118 |
+
segmented_sources = [MODEL_CONFIG.get(key) for key in MODEL_CONFIG.keys()]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
|
| 120 |
if segmented_images.count(None) > 2:
|
| 121 |
logging.error("Not enough segmented images found for: %s. Resampling another image.", sample['original_filename'])
|
|
|
|
| 143 |
def get_notice_markdown():
|
| 144 |
"""Generate the notice markdown with dynamic vote count."""
|
| 145 |
total_votes = len(get_all_votes())
|
| 146 |
+
model_list = ", ".join(MODEL_CONFIG.keys())
|
| 147 |
return f"""
|
| 148 |
|
| 149 |
## 📜 How It Works
|
| 150 |
+
- **Blind Test**: You will see two images with their background removed from two anonymous background removal models ({model_list}).
|
| 151 |
- **Vote for the Best**: Choose the best result, if none stand out choose "Tie".
|
| 152 |
|
| 153 |
## 📊 Stats
|