chawin.chen commited on
Commit ·
8d16a3c
1
Parent(s): 662f3d9
fix gamma值调整评分
Browse files
test/{test_score_adjustment_demo.py → score_adjustment_demo_test.py}
RENAMED
|
@@ -2,29 +2,29 @@ def adjust_score(score, threshold, gamma):
|
|
| 2 |
"""根据阈值和gamma值调整评分"""
|
| 3 |
if score < threshold:
|
| 4 |
adjusted = threshold - gamma * (threshold - score)
|
| 5 |
-
return round(min(
|
| 6 |
return score
|
| 7 |
|
| 8 |
-
# 默认参数
|
| 9 |
-
default_threshold =
|
| 10 |
default_gamma = 0.5
|
| 11 |
|
| 12 |
-
# 新参数1
|
| 13 |
-
new_threshold_1 =
|
| 14 |
-
new_gamma_1 = 0.
|
| 15 |
|
| 16 |
-
# 新参数2
|
| 17 |
-
new_threshold_2 =
|
| 18 |
new_gamma_2 = 0.8
|
| 19 |
|
| 20 |
-
print(f"原始分\tT={default_threshold},
|
| 21 |
print("-----\t----------\t----------\t----------")
|
| 22 |
|
| 23 |
-
# 从
|
| 24 |
-
for i in range(
|
| 25 |
score = i / 10.0
|
| 26 |
default_adjusted = adjust_score(score, default_threshold, default_gamma)
|
| 27 |
new_adjusted_1 = adjust_score(score, new_threshold_1, new_gamma_1)
|
| 28 |
new_adjusted_2 = adjust_score(score, new_threshold_2, new_gamma_2)
|
| 29 |
-
# 确保显示小数点
|
| 30 |
-
print(f"{score:.
|
|
|
|
| 2 |
"""根据阈值和gamma值调整评分"""
|
| 3 |
if score < threshold:
|
| 4 |
adjusted = threshold - gamma * (threshold - score)
|
| 5 |
+
return round(min(100.0, max(0.0, adjusted)), 2)
|
| 6 |
return score
|
| 7 |
|
| 8 |
+
# 默认参数
|
| 9 |
+
default_threshold = 90.0
|
| 10 |
default_gamma = 0.5
|
| 11 |
|
| 12 |
+
# 新参数1
|
| 13 |
+
new_threshold_1 = 90.0
|
| 14 |
+
new_gamma_1 = 0.55
|
| 15 |
|
| 16 |
+
# 新参数2
|
| 17 |
+
new_threshold_2 = 90.0
|
| 18 |
new_gamma_2 = 0.8
|
| 19 |
|
| 20 |
+
print(f"原始分\tT={default_threshold},g={default_gamma}\tT={new_threshold_1},g={new_gamma_1}\tT={new_threshold_2},g={new_gamma_2}")
|
| 21 |
print("-----\t----------\t----------\t----------")
|
| 22 |
|
| 23 |
+
# 从10.0到100.0,以0.1为步长
|
| 24 |
+
for i in range(100, 1001):
|
| 25 |
score = i / 10.0
|
| 26 |
default_adjusted = adjust_score(score, default_threshold, default_gamma)
|
| 27 |
new_adjusted_1 = adjust_score(score, new_threshold_1, new_gamma_1)
|
| 28 |
new_adjusted_2 = adjust_score(score, new_threshold_2, new_gamma_2)
|
| 29 |
+
# 确保显示2位小数点
|
| 30 |
+
print(f"{score:.2f}\t\t\t{default_adjusted:.2f}\t\t\t\t\t{new_adjusted_1:.2f}\t\t\t\t\t{new_adjusted_2:.2f}")
|
test/test_score.py
CHANGED
|
@@ -19,7 +19,7 @@ def default_converter(o):
|
|
| 19 |
logging.basicConfig(level=logging.INFO)
|
| 20 |
logger = logging.getLogger(__name__)
|
| 21 |
|
| 22 |
-
resp = RetinaFace.detect_faces("~/
|
| 23 |
|
| 24 |
logger.info(
|
| 25 |
"search results: " + json.dumps(resp, ensure_ascii=False, default=default_converter)
|
|
|
|
| 19 |
logging.basicConfig(level=logging.INFO)
|
| 20 |
logger = logging.getLogger(__name__)
|
| 21 |
|
| 22 |
+
resp = RetinaFace.detect_faces("~/Pictures/face/face3.png")
|
| 23 |
|
| 24 |
logger.info(
|
| 25 |
"search results: " + json.dumps(resp, ensure_ascii=False, default=default_converter)
|