Update app.py
Browse files
app.py
CHANGED
@@ -24,6 +24,8 @@ fdic = {
|
|
24 |
"weight": "bold"
|
25 |
}
|
26 |
|
|
|
|
|
27 |
label_color_dict = {}
|
28 |
|
29 |
def query_data(in_pil_img: Image.Image):
|
@@ -57,7 +59,7 @@ def get_annotated_image(in_pil_img):
|
|
57 |
box = prediction['box']
|
58 |
label = prediction['label']
|
59 |
score = round(prediction['score'] * 100, 1)
|
60 |
-
if score <
|
61 |
continue # 过滤掉低置信度的预测结果
|
62 |
|
63 |
if label not in label_color_dict: # 为每个类别随机分配颜色, 后续维持一致
|
@@ -72,7 +74,7 @@ def get_annotated_image(in_pil_img):
|
|
72 |
font = ImageFont.truetype(font="arial.ttf", size=font_size) # 确保你有可用的字体文件
|
73 |
|
74 |
# 获取文本边界框
|
75 |
-
text = f"{label}: {score}%"
|
76 |
text_bbox = draw.textbbox((0, 0), text, font=font)
|
77 |
|
78 |
# 绘制矩形
|
|
|
24 |
"weight": "bold"
|
25 |
}
|
26 |
|
27 |
+
threshold = 80 # 置信度阈值
|
28 |
+
|
29 |
label_color_dict = {}
|
30 |
|
31 |
def query_data(in_pil_img: Image.Image):
|
|
|
59 |
box = prediction['box']
|
60 |
label = prediction['label']
|
61 |
score = round(prediction['score'] * 100, 1)
|
62 |
+
if score < threshold:
|
63 |
continue # 过滤掉低置信度的预测结果
|
64 |
|
65 |
if label not in label_color_dict: # 为每个类别随机分配颜色, 后续维持一致
|
|
|
74 |
font = ImageFont.truetype(font="arial.ttf", size=font_size) # 确保你有可用的字体文件
|
75 |
|
76 |
# 获取文本边界框
|
77 |
+
text = f"{label}: {score}%"
|
78 |
text_bbox = draw.textbbox((0, 0), text, font=font)
|
79 |
|
80 |
# 绘制矩形
|