Spaces:
Running
Running
sharper transition
Browse files
app.py
CHANGED
|
@@ -287,6 +287,7 @@ def _merge_style(old_style: str, updates: dict) -> str:
|
|
| 287 |
def get_gradient_color(confidence: float, threshold: float) -> str:
|
| 288 |
"""
|
| 289 |
Generate a gradient color from dark to bright green based on confidence.
|
|
|
|
| 290 |
|
| 291 |
Args:
|
| 292 |
confidence: Probability score (0-1)
|
|
@@ -299,9 +300,12 @@ def get_gradient_color(confidence: float, threshold: float) -> str:
|
|
| 299 |
return "#101418" # base color (no prediction)
|
| 300 |
|
| 301 |
# Normalize confidence to [0, 1] range starting from threshold
|
| 302 |
-
# This ensures threshold maps to darkest green, 1.0 maps to brightest
|
| 303 |
normalized = (confidence - threshold) / (1.0 - threshold)
|
| 304 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 305 |
# Define gradient from dark green to bright green
|
| 306 |
# Dark green: #1a5e3a, Bright green: #2ecc71
|
| 307 |
r_start, g_start, b_start = 0x1a, 0x5e, 0x3a # dark green
|
|
|
|
| 287 |
def get_gradient_color(confidence: float, threshold: float) -> str:
|
| 288 |
"""
|
| 289 |
Generate a gradient color from dark to bright green based on confidence.
|
| 290 |
+
Uses a power function for sharper contrast.
|
| 291 |
|
| 292 |
Args:
|
| 293 |
confidence: Probability score (0-1)
|
|
|
|
| 300 |
return "#101418" # base color (no prediction)
|
| 301 |
|
| 302 |
# Normalize confidence to [0, 1] range starting from threshold
|
|
|
|
| 303 |
normalized = (confidence - threshold) / (1.0 - threshold)
|
| 304 |
|
| 305 |
+
# Apply power function for sharper gradient (higher power = sharper)
|
| 306 |
+
# You can adjust the exponent: 2.0 = moderate sharp, 3.0 = very sharp
|
| 307 |
+
normalized = normalized ** 2.5
|
| 308 |
+
|
| 309 |
# Define gradient from dark green to bright green
|
| 310 |
# Dark green: #1a5e3a, Bright green: #2ecc71
|
| 311 |
r_start, g_start, b_start = 0x1a, 0x5e, 0x3a # dark green
|