LPX
commited on
Commit
·
d789973
1
Parent(s):
57b2083
reformat generate_results_html function for maintainable HTML generation
Browse files- moved HTML template strings into separate functions for each HTML tile
- added header color generation as a function
```ruby
¸ base-ui]: update image prediction to return HTML content
- modified predict_image function to return HTML content
- added predict_image_with_html function which calls predict_image and then generate_results_html to produce final HTML
```
app.py
CHANGED
|
@@ -123,6 +123,7 @@ def predict_image(img, confidence_threshold):
|
|
| 123 |
combined_outputs = [result_1output, result_2output, result_3output, result_4output, result_5output, result_5boutput]
|
| 124 |
return img_pil, combined_outputs
|
| 125 |
# Define a function to generate the HTML content
|
|
|
|
| 126 |
def generate_results_html(results):
|
| 127 |
def get_header_color(label):
|
| 128 |
if label == 'AI':
|
|
@@ -135,236 +136,69 @@ def generate_results_html(results):
|
|
| 135 |
return 'bg-blue-500 text-blue-700', 'bg-blue-400', 'bg-blue-100', 'bg-blue-700 text-blue-700', 'bg-blue-200'
|
| 136 |
else:
|
| 137 |
return 'bg-gray-300 text-gray-700', 'bg-gray-400', 'bg-gray-100', 'bg-gray-700 text-gray-700', 'bg-gray-200'
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
html_content = f"""
|
| 141 |
-
|
| 142 |
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
|
|
|
|
|
|
|
|
|
| 148 |
<div
|
| 149 |
-
class="
|
| 150 |
-
<
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
<p class="whitespace-nowrap text-lg leading-normal font-bold text-center self-center align-middle py-px">{results[0][-1]}</p>
|
| 160 |
-
</span>
|
| 161 |
-
</div>
|
| 162 |
-
<div>
|
| 163 |
-
<div class="mt-4 relative -mx-4 bg-gray-800">
|
| 164 |
-
<div class="w-full bg-gray-400 rounded-none h-8">
|
| 165 |
-
<div class="inline-flex whitespace-nowrap bg-green-400 h-full rounded-none" style="width: {results[0][2] * 100:.2f}%;">
|
| 166 |
-
<p class="p-2 px-4 text-xs self-center align-middle">Conf:
|
| 167 |
-
<span class="ml-1 font-medium font-mono">{results[0][2]:.4f}</span>
|
| 168 |
-
</p>
|
| 169 |
-
</div>
|
| 170 |
-
</div>
|
| 171 |
-
</div>
|
| 172 |
-
<div class="relative -mx-4 bg-gray-800">
|
| 173 |
-
<div class="w-full bg-gray-400 rounded-none h-8">
|
| 174 |
-
<div class="inline-flex whitespace-nowrap bg-red-400 h-full rounded-none" style="width: {results[0][3] * 100:.2f}%;">
|
| 175 |
-
<p class="p-2 px-4 text-xs self-center align-middle">Conf:
|
| 176 |
-
<span class="ml-1 font-medium font-mono">{results[0][3]:.4f}</span>
|
| 177 |
-
</p>
|
| 178 |
-
</div>
|
| 179 |
-
</div>
|
| 180 |
-
</div>
|
| 181 |
-
</div>
|
| 182 |
-
<div class="flex flex-col items-start">
|
| 183 |
-
<h4 class="mt-4 text-sm font-semibold tracking-wide">SwinV2 Based</h4>
|
| 184 |
-
|
| 185 |
-
<div class="text-xs font-mono">Real: {results[0][2]:.4f}, AI: {results[0][3]:.4f}</div>
|
| 186 |
-
|
| 187 |
-
<a class="mt-2 text-xs tracking-wide">@haywoodsloan / more info</a>
|
| 188 |
-
</div>
|
| 189 |
-
</div>
|
| 190 |
-
<!-- Tile 2: ViT/AI-vs-Real -->
|
| 191 |
-
<div
|
| 192 |
-
class="flex flex-col bg-gray-800 rounded-sm p-4 m-1 border border-gray-800 shadow-xs transition hover:shadow-lg dark:shadow-gray-700/25">
|
| 193 |
-
<div
|
| 194 |
-
class="-m-4 h-24 {get_header_color(results[1][-1])[0]} rounded-sm rounded-b-none transition border group-hover:border-gray-100 group-hover:shadow-lg group-hover:{get_header_color(results[1][-1])[4]}">
|
| 195 |
-
<span class="text-gray-300 font-mono tracking-widest p-4 pb-3 block text-xs text-center">MODEL 2:</span>
|
| 196 |
-
<span
|
| 197 |
-
class="flex w-24 mx-auto tracking-wide items-center justify-center rounded-full {get_header_color(results[1][-1])[2]} px-1 py-0.5 {get_header_color(results[1][-1])[3]}"
|
| 198 |
-
>
|
| 199 |
-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="3" stroke="currentColor" class="w-4 h-4 mr-2 -ml-3 group-hover:animate group-hover:animate-pulse">
|
| 200 |
-
{'<path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />' if results[1][-1] == 'REAL' else '<path stroke-linecap="round" stroke-linejoin="round" d="m9.75 9.75 4.5 4.5m0-4.5-4.5 4.5M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />'}
|
| 201 |
-
</svg>
|
| 202 |
-
<p class="whitespace-nowrap text-lg leading-normal font-bold text-center self-center align-middle py-px">{results[1][-1]}</p>
|
| 203 |
-
</span>
|
| 204 |
-
</div>
|
| 205 |
-
<div>
|
| 206 |
-
<div class="mt-4 relative -mx-4 bg-gray-800">
|
| 207 |
-
<div class="w-full bg-gray-400 rounded-none h-8">
|
| 208 |
-
<div class="inline-flex whitespace-nowrap bg-green-400 h-full rounded-none" style="width: {results[1][2] * 100:.2f}%;">
|
| 209 |
-
<p class="p-2 px-4 text-xs self-center align-middle">Conf:
|
| 210 |
-
<span class="ml-1 font-medium font-mono">{results[1][2]:.4f}</span>
|
| 211 |
-
</p>
|
| 212 |
-
</div>
|
| 213 |
-
</div>
|
| 214 |
-
</div>
|
| 215 |
-
<div class="relative -mx-4 bg-gray-800">
|
| 216 |
-
<div class="w-full bg-gray-400 rounded-none h-8">
|
| 217 |
-
<div class="inline-flex whitespace-nowrap bg-red-400 h-full rounded-none" style="width: {results[1][3] * 100:.2f}%;">
|
| 218 |
-
<p class="p-2 px-4 text-xs self-center align-middle">Conf:
|
| 219 |
-
<span class="ml-1 font-medium font-mono">{results[1][3]:.4f}</span>
|
| 220 |
-
</p>
|
| 221 |
-
</div>
|
| 222 |
-
</div>
|
| 223 |
-
</div>
|
| 224 |
-
</div>
|
| 225 |
-
<div class="flex flex-col items-start">
|
| 226 |
-
<h4 class="mt-4 text-sm font-semibold tracking-wide">ViT Based</h4>
|
| 227 |
-
|
| 228 |
-
<div class="text-xs font-mono">Real: {results[1][2]:.4f}, AI: {results[1][3]:.4f}</div>
|
| 229 |
-
|
| 230 |
-
<a class="mt-2 text-xs tracking-wide">@Heem2 / more info</a>
|
| 231 |
-
</div>
|
| 232 |
</div>
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
class="flex w-24 mx-auto tracking-wide items-center justify-center rounded-full {get_header_color(results[2][-1])[2]} px-1 py-0.5 {get_header_color(results[2][-1])[3]}"
|
| 241 |
-
>
|
| 242 |
-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="3" stroke="currentColor" class="w-4 h-4 mr-2 -ml-3 group-hover:animate group-hover:animate-pulse">
|
| 243 |
-
{'<path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />' if results[2][-1] == 'REAL' else '<path stroke-linecap="round" stroke-linejoin="round" d="m9.75 9.75 4.5 4.5m0-4.5-4.5 4.5M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />'}
|
| 244 |
-
</svg>
|
| 245 |
-
<p class="whitespace-nowrap text-lg leading-normal font-bold text-center self-center align-middle py-px">{results[2][-1]}</p>
|
| 246 |
-
</span>
|
| 247 |
-
</div>
|
| 248 |
-
<div>
|
| 249 |
-
<div class="mt-4 relative -mx-4 bg-gray-800">
|
| 250 |
-
<div class="w-full bg-gray-400 rounded-none h-8">
|
| 251 |
-
<div class="inline-flex whitespace-nowrap bg-green-400 h-full rounded-none" style="width: {results[2][2] * 100:.2f}%;">
|
| 252 |
-
<p class="p-2 px-4 text-xs self-center align-middle">Conf:
|
| 253 |
-
<span class="ml-1 font-medium font-mono">{results[2][2]:.4f}</span>
|
| 254 |
-
</p>
|
| 255 |
-
</div>
|
| 256 |
-
</div>
|
| 257 |
-
</div>
|
| 258 |
-
<div class="relative -mx-4 bg-gray-800">
|
| 259 |
-
<div class="w-full bg-gray-400 rounded-none h-8">
|
| 260 |
-
<div class="inline-flex whitespace-nowrap bg-red-400 h-full rounded-none" style="width: {results[2][3] * 100:.2f}%;">
|
| 261 |
-
<p class="p-2 px-4 text-xs self-center align-middle">Conf:
|
| 262 |
-
<span class="ml-1 font-medium font-mono">{results[2][3]:.4f}</span>
|
| 263 |
-
</p>
|
| 264 |
-
</div>
|
| 265 |
</div>
|
| 266 |
</div>
|
| 267 |
</div>
|
| 268 |
-
<div class="
|
| 269 |
-
<
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
</div>
|
| 275 |
-
</div>
|
| 276 |
-
<!-- Tile 4: Swin/SDXL-FLUX -->
|
| 277 |
-
<div
|
| 278 |
-
class="flex flex-col bg-gray-800 rounded-sm p-4 m-1 border border-gray-800 shadow-xs transition hover:shadow-lg dark:shadow-gray-700/25">
|
| 279 |
-
<div
|
| 280 |
-
class="-m-4 h-24 {get_header_color(results[3][-1])[0]} rounded-sm rounded-b-none transition border group-hover:border-gray-100 group-hover:shadow-lg group-hover:{get_header_color(results[3][-1])[4]}">
|
| 281 |
-
<span class="text-gray-300 font-mono tracking-widest p-4 pb-3 block text-xs text-center">MODEL 4:</span>
|
| 282 |
-
<span
|
| 283 |
-
class="flex w-24 mx-auto tracking-wide items-center justify-center rounded-full {get_header_color(results[3][-1])[2]} px-1 py-0.5 {get_header_color(results[3][-1])[3]}"
|
| 284 |
-
>
|
| 285 |
-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="3" stroke="currentColor" class="w-4 h-4 mr-2 -ml-3 group-hover:animate group-hover:animate-pulse">
|
| 286 |
-
{'<path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />' if results[3][-1] == 'REAL' else '<path stroke-linecap="round" stroke-linejoin="round" d="m9.75 9.75 4.5 4.5m0-4.5-4.5 4.5M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />'}
|
| 287 |
-
</svg>
|
| 288 |
-
<p class="whitespace-nowrap text-lg leading-normal font-bold text-center self-center align-middle py-px">{results[3][-1]}</p>
|
| 289 |
-
</span>
|
| 290 |
-
</div>
|
| 291 |
-
<div>
|
| 292 |
-
<div class="mt-4 relative -mx-4 bg-gray-800">
|
| 293 |
-
<div class="w-full bg-gray-400 rounded-none h-8">
|
| 294 |
-
<div class="inline-flex whitespace-nowrap bg-green-400 h-full rounded-none" style="width: {results[3][2] * 100:.2f}%;">
|
| 295 |
-
<p class="p-2 px-4 text-xs self-center align-middle">Conf:
|
| 296 |
-
<span class="ml-1 font-medium font-mono">{results[3][2]:.4f}</span>
|
| 297 |
-
</p>
|
| 298 |
-
</div>
|
| 299 |
</div>
|
| 300 |
</div>
|
| 301 |
-
<div class="relative -mx-4 bg-gray-800">
|
| 302 |
-
<div class="w-full bg-gray-400 rounded-none h-8">
|
| 303 |
-
<div class="inline-flex whitespace-nowrap bg-red-400 h-full rounded-none" style="width: {results[3][3] * 100:.2f}%;">
|
| 304 |
-
<p class="p-2 px-4 text-xs self-center align-middle">Conf:
|
| 305 |
-
<span class="ml-1 font-medium font-mono">{results[3][3]:.4f}</span>
|
| 306 |
-
</p>
|
| 307 |
-
</div>
|
| 308 |
-
</div>
|
| 309 |
-
</div>
|
| 310 |
-
</div>
|
| 311 |
-
<div class="flex flex-col items-start">
|
| 312 |
-
<h4 class="mt-4 text-sm font-semibold tracking-wide">SDXL + FLUX</h4>
|
| 313 |
-
|
| 314 |
-
<div class="text-xs font-mono">Real: {results[3][2]:.4f}, AI: {results[3][3]:.4f}</div>
|
| 315 |
-
|
| 316 |
-
<a class="mt-2 text-xs tracking-wide">@cmckinle / more info</a>
|
| 317 |
</div>
|
| 318 |
</div>
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
class="
|
| 322 |
-
<
|
| 323 |
-
class="-m-4 h-24 {get_header_color(results[4][-1])[0]} rounded-sm rounded-b-none transition border group-hover:border-gray-100 group-hover:shadow-lg group-hover:{get_header_color(results[4][-1])[4]}">
|
| 324 |
-
<span class="text-gray-300 font-mono tracking-widest p-4 pb-3 block text-xs text-center">MODEL 5:</span>
|
| 325 |
-
<span
|
| 326 |
-
class="flex w-24 mx-auto tracking-wide items-center justify-center rounded-full {get_header_color(results[4][-1])[2]} px-1 py-0.5 {get_header_color(results[4][-1])[3]}"
|
| 327 |
-
>
|
| 328 |
-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="3" stroke="currentColor" class="w-4 h-4 mr-2 -ml-3 group-hover:animate group-hover:animate-pulse">
|
| 329 |
-
{'<path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />' if results[4][-1] == 'REAL' else '<path stroke-linecap="round" stroke-linejoin="round" d="m9.75 9.75 4.5 4.5m0-4.5-4.5 4.5M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />'}
|
| 330 |
-
</svg>
|
| 331 |
-
<p class="whitespace-nowrap text-lg leading-normal font-bold text-center self-center align-middle py-px">{results[4][-1]}</p>
|
| 332 |
-
</span>
|
| 333 |
-
</div>
|
| 334 |
-
<div>
|
| 335 |
-
<div class="mt-4 relative -mx-4 bg-gray-800">
|
| 336 |
-
<div class="w-full bg-gray-400 rounded-none h-8">
|
| 337 |
-
<div class="inline-flex whitespace-nowrap bg-green-400 h-full rounded-none" style="width: {results[4][2] * 100:.2f}%;">
|
| 338 |
-
<p class="p-2 px-4 text-xs self-center align-middle">Conf:
|
| 339 |
-
<span class="ml-1 font-medium font-mono">{results[4][2]:.4f}</span>
|
| 340 |
-
</p>
|
| 341 |
-
</div>
|
| 342 |
-
</div>
|
| 343 |
-
</div>
|
| 344 |
-
<div class="relative -mx-4 bg-gray-800">
|
| 345 |
-
<div class="w-full bg-gray-400 rounded-none h-8">
|
| 346 |
-
<div class="inline-flex whitespace-nowrap bg-red-400 h-full rounded-none" style="width: {results[4][3] * 100:.2f}%;">
|
| 347 |
-
<p class="p-2 px-4 text-xs self-center align-middle">Conf:
|
| 348 |
-
<span class="ml-1 font-medium font-mono">{results[4][3]:.4f}</span>
|
| 349 |
-
</p>
|
| 350 |
-
</div>
|
| 351 |
-
</div>
|
| 352 |
-
</div>
|
| 353 |
-
</div>
|
| 354 |
-
<div class="flex flex-col items-start">
|
| 355 |
-
<h4 class="mt-4 text-sm font-semibold tracking-wide">Vits Model</h4>
|
| 356 |
-
|
| 357 |
-
<div class="text-xs font-mono">Real: {results[4][2]:.4f}, AI: {results[4][3]:.4f}</div>
|
| 358 |
-
<div class="text-xs font-mono">Real: {results[5][2]:.4f}, AI: {results[5][3]:.4f}</div>
|
| 359 |
-
|
| 360 |
-
<a class="mt-2 text-xs tracking-wide">@prithivMLmods / more info</a>
|
| 361 |
-
</div>
|
| 362 |
</div>
|
| 363 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 364 |
</div>
|
| 365 |
"""
|
| 366 |
return html_content
|
| 367 |
-
|
| 368 |
# Modify the predict_image function to return the HTML content
|
| 369 |
def predict_image_with_html(img, confidence_threshold):
|
| 370 |
img_pil, results = predict_image(img, confidence_threshold)
|
|
|
|
| 123 |
combined_outputs = [result_1output, result_2output, result_3output, result_4output, result_5output, result_5boutput]
|
| 124 |
return img_pil, combined_outputs
|
| 125 |
# Define a function to generate the HTML content
|
| 126 |
+
|
| 127 |
def generate_results_html(results):
|
| 128 |
def get_header_color(label):
|
| 129 |
if label == 'AI':
|
|
|
|
| 136 |
return 'bg-blue-500 text-blue-700', 'bg-blue-400', 'bg-blue-100', 'bg-blue-700 text-blue-700', 'bg-blue-200'
|
| 137 |
else:
|
| 138 |
return 'bg-gray-300 text-gray-700', 'bg-gray-400', 'bg-gray-100', 'bg-gray-700 text-gray-700', 'bg-gray-200'
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
|
| 140 |
+
def generate_tile_html(index, result, model_name, contributor):
|
| 141 |
+
label = result[-1]
|
| 142 |
+
header_colors = get_header_color(label)
|
| 143 |
+
real_conf = result[2]
|
| 144 |
+
ai_conf = result[3]
|
| 145 |
+
return f"""
|
| 146 |
+
<div
|
| 147 |
+
class="flex flex-col bg-gray-800 rounded-sm p-4 m-1 border border-gray-800 shadow-xs transition hover:shadow-lg dark:shadow-gray-700/25">
|
| 148 |
<div
|
| 149 |
+
class="-m-4 h-24 {header_colors[0]} rounded-sm rounded-b-none transition border group-hover:border-gray-100 group-hover:shadow-lg group-hover:{header_colors[4]}">
|
| 150 |
+
<span class="text-gray-300 font-mono tracking-widest p-4 pb-3 block text-xs text-center">MODEL {index + 1}:</span>
|
| 151 |
+
<span
|
| 152 |
+
class="flex w-24 mx-auto tracking-wide items-center justify-center rounded-full {header_colors[2]} px-1 py-0.5 {header_colors[3]}"
|
| 153 |
+
>
|
| 154 |
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="3" stroke="currentColor" class="w-4 h-4 mr-2 -ml-3 group-hover:animate group-hover:animate-pulse">
|
| 155 |
+
{'<path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />' if label == 'REAL' else '<path stroke-linecap="round" stroke-linejoin="round" d="m9.75 9.75 4.5 4.5m0-4.5-4.5 4.5M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />'}
|
| 156 |
+
</svg>
|
| 157 |
+
<p class="whitespace-nowrap text-lg leading-normal font-bold text-center self-center align-middle py-px">{label}</p>
|
| 158 |
+
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
</div>
|
| 160 |
+
<div>
|
| 161 |
+
<div class="mt-4 relative -mx-4 bg-gray-800">
|
| 162 |
+
<div class="w-full bg-gray-400 rounded-none h-8">
|
| 163 |
+
<div class="inline-flex whitespace-nowrap bg-green-400 h-full rounded-none" style="width: {real_conf * 100:.2f}%;">
|
| 164 |
+
<p class="p-2 px-4 text-xs self-center align-middle">Conf:
|
| 165 |
+
<span class="ml-1 font-medium font-mono">{real_conf:.4f}</span>
|
| 166 |
+
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
</div>
|
| 168 |
</div>
|
| 169 |
</div>
|
| 170 |
+
<div class="relative -mx-4 bg-gray-800">
|
| 171 |
+
<div class="w-full bg-gray-400 rounded-none h-8">
|
| 172 |
+
<div class="inline-flex whitespace-nowrap bg-red-400 h-full rounded-none" style="width: {ai_conf * 100:.2f}%;">
|
| 173 |
+
<p class="p-2 px-4 text-xs self-center align-middle">Conf:
|
| 174 |
+
<span class="ml-1 font-medium font-mono">{ai_conf:.4f}</span>
|
| 175 |
+
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
</div>
|
| 177 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
</div>
|
| 179 |
</div>
|
| 180 |
+
<div class="flex flex-col items-start">
|
| 181 |
+
<h4 class="mt-4 text-sm font-semibold tracking-wide">{model_name}</h4>
|
| 182 |
+
<div class="text-xs font-mono">Real: {real_conf:.4f}, AI: {ai_conf:.4f}</div>
|
| 183 |
+
<a class="mt-2 text-xs tracking-wide">@{contributor} / more info</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
</div>
|
| 185 |
</div>
|
| 186 |
+
"""
|
| 187 |
+
|
| 188 |
+
html_content = f"""
|
| 189 |
+
<link href="https://unpkg.com/[email protected]/dist/tailwind.min.css" rel="stylesheet">
|
| 190 |
+
<div class="container mx-auto">
|
| 191 |
+
<div class="grid xl:grid-cols-5 md:grid-cols-5 grid-cols-1 gap-1">
|
| 192 |
+
{generate_tile_html(0, results[0], "SwinV2 Based", "haywoodsloan")}
|
| 193 |
+
{generate_tile_html(1, results[1], "ViT Based", "Heem2")}
|
| 194 |
+
{generate_tile_html(2, results[2], "SDXL Dataset", "Organika")}
|
| 195 |
+
{generate_tile_html(3, results[3], "SDXL + FLUX", "cmckinle")}
|
| 196 |
+
{generate_tile_html(4, results[4], "Newcomer", "YourContributorName")}
|
| 197 |
+
{generate_tile_html(5, results[5], "Newcomer 2", "YourContributorName")}
|
| 198 |
+
</div>
|
| 199 |
</div>
|
| 200 |
"""
|
| 201 |
return html_content
|
|
|
|
| 202 |
# Modify the predict_image function to return the HTML content
|
| 203 |
def predict_image_with_html(img, confidence_threshold):
|
| 204 |
img_pil, results = predict_image(img, confidence_threshold)
|