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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Image Ranking</title>
|
| 7 |
+
<style>
|
| 8 |
+
body {
|
| 9 |
+
font-family: Arial, sans-serif;
|
| 10 |
+
padding: 20px;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
.rank-btn {
|
| 14 |
+
padding: 5px 15px;
|
| 15 |
+
cursor: pointer;
|
| 16 |
+
border: 2px solid #4CAF50;
|
| 17 |
+
background-color: white;
|
| 18 |
+
color: #4CAF50;
|
| 19 |
+
border-radius: 4px;
|
| 20 |
+
font-weight: bold;
|
| 21 |
+
min-width: 60px;
|
| 22 |
+
}
|
| 23 |
+
.rank-btn.ranked {
|
| 24 |
+
background-color: #4CAF50;
|
| 25 |
+
color: white;
|
| 26 |
+
border-color: #4CAF50;
|
| 27 |
+
}
|
| 28 |
+
.rank-btn:hover {
|
| 29 |
+
opacity: 0.8;
|
| 30 |
+
}
|
| 31 |
+
.submit-btn {
|
| 32 |
+
margin-top: 20px;
|
| 33 |
+
padding: 10px 30px;
|
| 34 |
+
background-color: #2196F3;
|
| 35 |
+
color: white;
|
| 36 |
+
border: none;
|
| 37 |
+
border-radius: 4px;
|
| 38 |
+
cursor: pointer;
|
| 39 |
+
font-size: 16px;
|
| 40 |
+
}
|
| 41 |
+
.submit-btn:hover {
|
| 42 |
+
background-color: #0b7dda;
|
| 43 |
+
}
|
| 44 |
+
.submit-btn:disabled {
|
| 45 |
+
background-color: #cccccc;
|
| 46 |
+
cursor: not-allowed;
|
| 47 |
+
}
|
| 48 |
+
.show-annotation-btn {
|
| 49 |
+
margin-top: 10px;
|
| 50 |
+
padding: 8px 20px;
|
| 51 |
+
background-color: #FF9800;
|
| 52 |
+
color: white;
|
| 53 |
+
border: none;
|
| 54 |
+
border-radius: 4px;
|
| 55 |
+
cursor: pointer;
|
| 56 |
+
font-size: 14px;
|
| 57 |
+
}
|
| 58 |
+
.show-annotation-btn:hover {
|
| 59 |
+
background-color: #F57C00;
|
| 60 |
+
}
|
| 61 |
+
.annotation-status {
|
| 62 |
+
display: inline-block;
|
| 63 |
+
margin-left: 15px;
|
| 64 |
+
padding: 5px 12px;
|
| 65 |
+
background-color: #4CAF50;
|
| 66 |
+
color: white;
|
| 67 |
+
border-radius: 4px;
|
| 68 |
+
font-size: 14px;
|
| 69 |
+
font-weight: bold;
|
| 70 |
+
}
|
| 71 |
+
/* 消息提示样式 */
|
| 72 |
+
.message-box {
|
| 73 |
+
position: fixed;
|
| 74 |
+
top: 20px;
|
| 75 |
+
right: 20px;
|
| 76 |
+
padding: 15px 25px;
|
| 77 |
+
border-radius: 4px;
|
| 78 |
+
font-size: 16px;
|
| 79 |
+
font-weight: bold;
|
| 80 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
| 81 |
+
z-index: 1000;
|
| 82 |
+
display: none;
|
| 83 |
+
animation: slideIn 0.3s ease-out;
|
| 84 |
+
}
|
| 85 |
+
.message-box.success {
|
| 86 |
+
background-color: #4CAF50;
|
| 87 |
+
color: white;
|
| 88 |
+
}
|
| 89 |
+
.message-box.error {
|
| 90 |
+
background-color: #f44336;
|
| 91 |
+
color: white;
|
| 92 |
+
}
|
| 93 |
+
.message-box.show {
|
| 94 |
+
display: block;
|
| 95 |
+
}
|
| 96 |
+
@keyframes slideIn {
|
| 97 |
+
from {
|
| 98 |
+
transform: translateX(100%);
|
| 99 |
+
opacity: 0;
|
| 100 |
+
}
|
| 101 |
+
to {
|
| 102 |
+
transform: translateX(0);
|
| 103 |
+
opacity: 1;
|
| 104 |
+
}
|
| 105 |
+
}
|
| 106 |
+
@keyframes slideOut {
|
| 107 |
+
from {
|
| 108 |
+
transform: translateX(0);
|
| 109 |
+
opacity: 1;
|
| 110 |
+
}
|
| 111 |
+
to {
|
| 112 |
+
transform: translateX(100%);
|
| 113 |
+
opacity: 0;
|
| 114 |
+
}
|
| 115 |
+
}
|
| 116 |
+
.message-box.hiding {
|
| 117 |
+
animation: slideOut 0.3s ease-out;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
/* 固定在右上角的分页条 */
|
| 121 |
+
.page-control {
|
| 122 |
+
position: fixed;
|
| 123 |
+
top: 20px;
|
| 124 |
+
right: 20px;
|
| 125 |
+
background: rgba(255,255,255,0.9);
|
| 126 |
+
border: 1px solid #ddd;
|
| 127 |
+
padding: 8px 12px;
|
| 128 |
+
border-radius: 6px;
|
| 129 |
+
box-shadow: 0 2px 6px rgba(0,0,0,0.1);
|
| 130 |
+
z-index: 999;
|
| 131 |
+
display: flex;
|
| 132 |
+
align-items: center;
|
| 133 |
+
gap: 8px;
|
| 134 |
+
font-size: 14px;
|
| 135 |
+
}
|
| 136 |
+
.page-control input {
|
| 137 |
+
width: 60px;
|
| 138 |
+
padding: 3px 5px;
|
| 139 |
+
border: 1px solid #ccc;
|
| 140 |
+
border-radius: 4px;
|
| 141 |
+
}
|
| 142 |
+
.page-control button {
|
| 143 |
+
padding: 4px 8px;
|
| 144 |
+
background-color: #2196F3;
|
| 145 |
+
color: white;
|
| 146 |
+
border: none;
|
| 147 |
+
border-radius: 4px;
|
| 148 |
+
cursor: pointer;
|
| 149 |
+
}
|
| 150 |
+
.page-control button:hover {
|
| 151 |
+
background-color: #0b7dda;
|
| 152 |
+
}
|
| 153 |
+
</style>
|
| 154 |
+
<script>
|
| 155 |
+
let rankCounter = 1;
|
| 156 |
+
const rankedImages = new Map();
|
| 157 |
+
let allCompareImages = [];
|
| 158 |
+
|
| 159 |
+
function initializeCompareImages() {
|
| 160 |
+
allCompareImages = [];
|
| 161 |
+
const rankButtons = document.querySelectorAll('.rank-btn');
|
| 162 |
+
rankButtons.forEach(btn => {
|
| 163 |
+
const imagePath = btn.getAttribute('data-image');
|
| 164 |
+
const filename = imagePath.split('/').pop();
|
| 165 |
+
if (!allCompareImages.includes(filename)) {
|
| 166 |
+
allCompareImages.push(filename);
|
| 167 |
+
}
|
| 168 |
+
});
|
| 169 |
+
}
|
| 170 |
+
window.addEventListener('DOMContentLoaded', function() {
|
| 171 |
+
initializeCompareImages();
|
| 172 |
+
});
|
| 173 |
+
|
| 174 |
+
/* 这里省略 rankImage、loadExistingAnnotation、showMessage、submitRanking 的原有实现 */
|
| 175 |
+
/* ... 你的原始脚本保持不变 ... */
|
| 176 |
+
|
| 177 |
+
// 新增跳转函数
|
| 178 |
+
function jumpToPage(event) {
|
| 179 |
+
event.preventDefault();
|
| 180 |
+
const input = document.getElementById('pageInput');
|
| 181 |
+
let page = parseInt(input.value);
|
| 182 |
+
if (isNaN(page) || page < 1) page = 1;
|
| 183 |
+
if (page > {{ total_pages }}) page = {{ total_pages }};
|
| 184 |
+
window.location.href = "/?page=" + page;
|
| 185 |
+
return false;
|
| 186 |
+
}
|
| 187 |
+
</script>
|
| 188 |
+
</head>
|
| 189 |
+
<body>
|
| 190 |
+
<!-- 消息提示框 -->
|
| 191 |
+
<div id="messageBox" class="message-box"></div>
|
| 192 |
+
|
| 193 |
+
<!-- 固定在右上角的分页控制条 -->
|
| 194 |
+
<div class="page-control">
|
| 195 |
+
<span>{{ page }}/{{ total_pages }}</span>
|
| 196 |
+
<form id="pageJumpForm" onsubmit="return jumpToPage(event)" style="display:inline;">
|
| 197 |
+
<input type="number" id="pageInput" min="1" max="{{ total_pages }}" value="{{ page }}">
|
| 198 |
+
<button type="submit">跳转</button>
|
| 199 |
+
</form>
|
| 200 |
+
</div>
|
| 201 |
+
|
| 202 |
+
<h1>Image Ranking</h1>
|
| 203 |
+
<form id="rankingForm" action="/sort" method="POST" onsubmit="return submitRanking(event)">
|
| 204 |
+
{% for item in data %}
|
| 205 |
+
<div>
|
| 206 |
+
{% if item.prompt %}
|
| 207 |
+
<div style="background-color: #f0f0f0; padding: 15px; margin-bottom: 20px; border-radius: 4px; border-left: 4px solid #2196F3;">
|
| 208 |
+
<h2 style="margin-top: 0; color: #333;">Prompt:</h2>
|
| 209 |
+
<p style="font-size: 16px; line-height: 1.6; margin-bottom: 0; color: #555;">{{ item.prompt }}</p>
|
| 210 |
+
</div>
|
| 211 |
+
{% endif %}
|
| 212 |
+
<h3>Reference Image: {{ item.ref_image }}
|
| 213 |
+
{% if item.is_annotated %}
|
| 214 |
+
<span class="annotation-status">已标注</span>
|
| 215 |
+
{% endif %}
|
| 216 |
+
</h3>
|
| 217 |
+
<p>Folder: {{ item.folder }}</p>
|
| 218 |
+
<img src="{{ item.ref_image }}" alt="ref_image" width="200">
|
| 219 |
+
<input type="hidden" name="ref_image" value="{{ item.ref_image }}">
|
| 220 |
+
{% if item.is_annotated %}
|
| 221 |
+
<button type="button" class="show-annotation-btn"
|
| 222 |
+
data-loaded="false"
|
| 223 |
+
onclick='loadExistingAnnotation(this, "{{ item.folder }}", "{{ item.ref_image.split("/")[-1] }}", {{ item.existing_rank_images|tojson|safe }})'>
|
| 224 |
+
显示已有标注
|
| 225 |
+
</button>
|
| 226 |
+
{% endif %}
|
| 227 |
+
<h4>Compare Images:</h4>
|
| 228 |
+
<div style="display: flex; gap: 15px; flex-wrap: wrap; align-items: flex-start;">
|
| 229 |
+
{% for compare_image in item.compare_images %}
|
| 230 |
+
<div class="image-item" style="display: flex; flex-direction: column; align-items: center; gap: 5px;">
|
| 231 |
+
<img src="{{ compare_image }}" alt="compare_image" width="100">
|
| 232 |
+
<button type="button"
|
| 233 |
+
class="rank-btn"
|
| 234 |
+
data-image="{{ compare_image }}"
|
| 235 |
+
onclick="rankImage(this, '{{ compare_image }}')">
|
| 236 |
+
排序
|
| 237 |
+
</button>
|
| 238 |
+
</div>
|
| 239 |
+
{% endfor %}
|
| 240 |
+
</div>
|
| 241 |
+
</div>
|
| 242 |
+
{% endfor %}
|
| 243 |
+
<button type="submit" class="submit-btn">提交排序</button>
|
| 244 |
+
</form>
|
| 245 |
+
|
| 246 |
+
<div style="margin-top: 20px;">
|
| 247 |
+
{% if page > 1 %}
|
| 248 |
+
<a href="/?page={{ page - 1 }}" style="margin-right: 10px;">上一页</a>
|
| 249 |
+
{% endif %}
|
| 250 |
+
{% if page < total_pages %}
|
| 251 |
+
<a href="/?page={{ page + 1 }}">下一页</a>
|
| 252 |
+
{% endif %}
|
| 253 |
+
</div>
|
| 254 |
+
</body>
|
| 255 |
+
</html>
|