Spaces:
Running
on
Zero
Running
on
Zero
Update html_templates.py
Browse files- html_templates.py +42 -0
html_templates.py
CHANGED
|
@@ -67,6 +67,48 @@ def format_error_message(color: str, index: int) -> str:
|
|
| 67 |
</div>
|
| 68 |
'''
|
| 69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
def format_description_html(description: Dict[str, Any], breed: str) -> str:
|
| 71 |
"""Format basic breed description with tooltips."""
|
| 72 |
if not isinstance(description, dict):
|
|
|
|
| 67 |
</div>
|
| 68 |
'''
|
| 69 |
|
| 70 |
+
|
| 71 |
+
def format_unknown_breed_message(color: str, index: int) -> str:
|
| 72 |
+
"""
|
| 73 |
+
當狗的品種無法被辨識時(信心度低於0.2)使用此函數格式化錯誤訊息。
|
| 74 |
+
這種情況通常發生在:
|
| 75 |
+
1. 圖片品質不佳
|
| 76 |
+
2. 狗的品種不在我們的資料集中
|
| 77 |
+
3. 拍攝角度不理想
|
| 78 |
+
"""
|
| 79 |
+
return f'''
|
| 80 |
+
<div class="dog-info-card" style="border-left: 8px solid {color};">
|
| 81 |
+
<div class="dog-info-header" style="background-color: {color}10;">
|
| 82 |
+
<span class="dog-label" style="color: {color};">Dog {index}</span>
|
| 83 |
+
</div>
|
| 84 |
+
<div class="breed-info">
|
| 85 |
+
<div class="warning-message">
|
| 86 |
+
<span class="icon">⚠️</span>
|
| 87 |
+
Unable to identify the dog breed. This breed might not be included in the dataset.
|
| 88 |
+
</div>
|
| 89 |
+
</div>
|
| 90 |
+
</div>
|
| 91 |
+
'''
|
| 92 |
+
|
| 93 |
+
def format_not_dog_message(color: str, index: int) -> str:
|
| 94 |
+
"""
|
| 95 |
+
當YOLO模型檢測到物體不是狗時使用此函數格式化錯誤訊息。
|
| 96 |
+
這是第一層的過濾機制,在進行品種分類之前就先確認是否為狗。
|
| 97 |
+
"""
|
| 98 |
+
return f'''
|
| 99 |
+
<div class="dog-info-card" style="border-left: 8px solid {color};">
|
| 100 |
+
<div class="dog-info-header" style="background-color: {color}10;">
|
| 101 |
+
<span class="dog-label" style="color: {color};">Object {index}</span>
|
| 102 |
+
</div>
|
| 103 |
+
<div class="breed-info">
|
| 104 |
+
<div class="warning-message">
|
| 105 |
+
<span class="icon">❌</span>
|
| 106 |
+
This does not appear to be a dog. Please upload an image containing a dog.
|
| 107 |
+
</div>
|
| 108 |
+
</div>
|
| 109 |
+
</div>
|
| 110 |
+
'''
|
| 111 |
+
|
| 112 |
def format_description_html(description: Dict[str, Any], breed: str) -> str:
|
| 113 |
"""Format basic breed description with tooltips."""
|
| 114 |
if not isinstance(description, dict):
|