Skip to content

Instantly share code, notes, and snippets.

@PkuRainBow
Forked from xinyangli/image_grid_gen.py
Created November 14, 2023 13:49
Show Gist options
  • Save PkuRainBow/2b1fa2845246b9812ad420485fa247c9 to your computer and use it in GitHub Desktop.
Save PkuRainBow/2b1fa2845246b9812ad420485fa247c9 to your computer and use it in GitHub Desktop.
import json
from collections import Counter
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?xxxxxxxxxx"
if_file = f"https://internblob.blob.core.windows.net/v-lixinyang/canva-data/benchmark/if/{index+1}.png?xxxxxxxxx"
sdxl_file = f"https://internblob.blob.core.windows.net/v-lixinyang/canva-data/benchmark/sdxl/{index+1}.png?xxxxxxxxx"
gt_file = f"https://internblob.blob.core.windows.net/v-lixinyang/canva-data/benchmark/{item['_id']}.png?xxxxxxxxx"
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