Last active
November 22, 2023 07:10
-
-
Save xinyangli/c40aa1266d4de3bbe4568927fa1adeb6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from collections import Counter | |
SAS = "" # e.g sp=r&st=... | |
with open("canva.benchmark.json", "r") as f: | |
data = json.load(f) | |
print(""" | |
<html> | |
<head> | |
<style> | |
.row { | |
display: flex; | |
flex-direction: row; | |
justify-content: start; | |
align-items: center; | |
margin-bottom: 16px; | |
} | |
.column { | |
flex: 15%; | |
padding: 0 16px; | |
} | |
</style> | |
</head> | |
<body> | |
""") | |
for index, item in enumerate(data): | |
# NOTE: replace xxxxxxxxx with SAS! | |
file = f"https://internblob.blob.core.windows.net/v-lixinyang/canva-data/benchmark/dalle/{index+1}_0.jpg?{SAS}" | |
if_file = f"https://internblob.blob.core.windows.net/v-lixinyang/canva-data/benchmark/if/{index+1}.png?{SAS}" | |
sdxl_file = f"https://internblob.blob.core.windows.net/v-lixinyang/canva-data/benchmark/sdxl/{index+1}.png?{SAS}" | |
gt_file = f"https://internblob.blob.core.windows.net/v-lixinyang/canva-data/benchmark/{item['_id']}.png?{SAS}" | |
if index % 1 == 0: | |
print('<div class="row">') | |
print(f""" | |
<div class="column"> | |
<img src="{gt_file}" alt="image" style="max-width: 100%;"> | |
</div> | |
<div class="column"> | |
<img src="{file}" alt="image" style="max-width: 100%;"> | |
</div> | |
<div class="column"> | |
<img src="{if_file}" alt="image" style="max-width: 100%;"> | |
</div> | |
<div class="column"> | |
<img src="{sdxl_file}" alt="image" style="max-width: 100%;"> | |
</div> | |
""") | |
if index % 1 == 0: | |
print('</div>') | |
print(f""" | |
<div class="row"> | |
<p>Index: {index} <br> | |
Category: {item["category"]} <br> | |
{item["caption"]} <br> | |
Tags: {item["tags"]} <br> | |
Texts: {item["texts"]}</p> | |
</div> | |
""") | |
print(""" | |
</body> | |
</html> | |
""") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment