Spaces:
Running
Running
maxuagi commited on
Commit ·
77772bc
1
Parent(s): 84108a8
update
Browse files- Dockerfile +10 -0
- app.py +106 -0
- requirements.txt +3 -0
- templates/index.html +492 -0
Dockerfile
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.9-slim
|
| 2 |
+
WORKDIR /code
|
| 3 |
+
COPY requirements.txt .
|
| 4 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 5 |
+
COPY . .
|
| 6 |
+
RUN useradd -m -u 1000 user
|
| 7 |
+
USER user
|
| 8 |
+
ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH
|
| 9 |
+
EXPOSE 7860
|
| 10 |
+
CMD ["python", "app.py"]
|
app.py
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import io
|
| 2 |
+
import base64
|
| 3 |
+
from flask import Flask, render_template, request
|
| 4 |
+
from datasets import load_dataset, Features, Value, Image, Sequence
|
| 5 |
+
from PIL import Image as PILImage # 给 PIL 的 Image 起个别名
|
| 6 |
+
|
| 7 |
+
app = Flask(__name__)
|
| 8 |
+
|
| 9 |
+
# 替换为你的数据集 ID
|
| 10 |
+
DATASET_ID = "ma-xu/fine-t2i"
|
| 11 |
+
|
| 12 |
+
def image_to_base64(pil_img):
|
| 13 |
+
# 兼容性处理:尝试获取新版本的 Resampling 属性,如果不存在则使用旧版本
|
| 14 |
+
try:
|
| 15 |
+
resampling_mode = PILImage.Resampling.LANCZOS
|
| 16 |
+
except AttributeError:
|
| 17 |
+
resampling_mode = PILImage.LANCZOS
|
| 18 |
+
|
| 19 |
+
# 1. 转换为缩略图提高加载速度,保持 aspect ratio
|
| 20 |
+
max_size = (800, 800)
|
| 21 |
+
pil_img.thumbnail(max_size, resampling_mode)
|
| 22 |
+
|
| 23 |
+
# 2. 转换为 RGB 模式(JPEG 不支持 RGBA)
|
| 24 |
+
if pil_img.mode in ("RGBA", "P"):
|
| 25 |
+
pil_img = pil_img.convert("RGB")
|
| 26 |
+
|
| 27 |
+
# 3. 编码为 Base64
|
| 28 |
+
byte_arr = io.BytesIO()
|
| 29 |
+
pil_img.save(byte_arr, format='JPEG', quality=85)
|
| 30 |
+
encoded_img = base64.b64encode(byte_arr.getvalue()).decode('utf-8')
|
| 31 |
+
return f"data:image/jpeg;base64,{encoded_img}"
|
| 32 |
+
|
| 33 |
+
@app.route('/', methods=['GET', 'POST'])
|
| 34 |
+
def index():
|
| 35 |
+
samples = []
|
| 36 |
+
filter_folder = request.form.get('folder', 'synthetic_enhanced_prompt_random_resolution')
|
| 37 |
+
print(f"filter_folder: {filter_folder}")
|
| 38 |
+
if filter_folder == "curated":
|
| 39 |
+
url_pattern = "https://huggingface.co/datasets/ma-xu/fine-t2i/resolve/main/curated/train-*.tar"
|
| 40 |
+
elif filter_folder == "enhanced_prompt_random_resolution":
|
| 41 |
+
url_pattern = "https://huggingface.co/datasets/ma-xu/fine-t2i/resolve/main/synthetic_enhanced_prompt_random_resolution/train-*.tar"
|
| 42 |
+
elif filter_folder == "enhanced_prompt_square_resolution":
|
| 43 |
+
url_pattern = "https://huggingface.co/datasets/ma-xu/fine-t2i/resolve/main/synthetic_enhanced_prompt_square_resolution/train-*.tar"
|
| 44 |
+
elif filter_folder == "original_prompt_random_resolution":
|
| 45 |
+
url_pattern = "https://huggingface.co/datasets/ma-xu/fine-t2i/resolve/main/synthetic_original_prompt_random_resolution/train-*.tar"
|
| 46 |
+
else:
|
| 47 |
+
url_pattern = "https://huggingface.co/datasets/ma-xu/fine-t2i/resolve/main/synthetic_original_prompt_square_resolution/train-*.tar"
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
if request.method == 'POST' or request.method == 'GET' :
|
| 51 |
+
json_feature = {
|
| 52 |
+
"aesthetic_predictor_v_2_5_score": Value("double"),
|
| 53 |
+
"enhanced_length": Value("int64"),
|
| 54 |
+
"enhanced_prompt": Value("string"),
|
| 55 |
+
"enhancer": Value("string"),
|
| 56 |
+
"id": Value("string"),
|
| 57 |
+
"image_aspect_ratio": Value("string"),
|
| 58 |
+
"image_generated_with_enhanced_prompt": Value("bool"),
|
| 59 |
+
"image_generator": Value("string"),
|
| 60 |
+
"image_resolution": Sequence(Value("int64")),
|
| 61 |
+
"length": Value("int64"),
|
| 62 |
+
"prompt": Value("string"),
|
| 63 |
+
"prompt_category": Value("string"),
|
| 64 |
+
"prompt_generator": Value("string"),
|
| 65 |
+
"style": Value("string"),
|
| 66 |
+
"task": Sequence(Value("string")) # 对应 list<item: string>
|
| 67 |
+
}
|
| 68 |
+
features = Features({
|
| 69 |
+
"__key__": Value("string"),
|
| 70 |
+
"__url__": Value("string"),
|
| 71 |
+
"jpg": Image(),
|
| 72 |
+
"txt": Value("string"),
|
| 73 |
+
"json": json_feature, # 这里对应报错中的 list<item: string>
|
| 74 |
+
# 如果 json 实际上是字典,可以改为 Value("string") 并在之后手动 json.loads
|
| 75 |
+
})
|
| 76 |
+
dataset = load_dataset(
|
| 77 |
+
"webdataset",
|
| 78 |
+
data_files={"train": url_pattern},
|
| 79 |
+
split="train",
|
| 80 |
+
features=features, # 强制指定特征
|
| 81 |
+
streaming=True # please do streaming, or you will download the whole dataset ~2TB
|
| 82 |
+
)
|
| 83 |
+
ds = dataset.shuffle(buffer_size=100, )
|
| 84 |
+
count = 0
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
for item in ds:
|
| 88 |
+
if count >= 100: break
|
| 89 |
+
print( count)
|
| 90 |
+
# 这里的字段名需对应你数据集中的 key (jpg, json, txt)
|
| 91 |
+
text_content = item.get('txt', '')
|
| 92 |
+
json_data = item.get('json', {})
|
| 93 |
+
|
| 94 |
+
samples.append({
|
| 95 |
+
"image": image_to_base64(item['jpg']),
|
| 96 |
+
"text": text_content,
|
| 97 |
+
"json": json_data,
|
| 98 |
+
"tar_file": item["__url__"]
|
| 99 |
+
})
|
| 100 |
+
count += 1
|
| 101 |
+
|
| 102 |
+
return render_template('index.html', samples=samples)
|
| 103 |
+
|
| 104 |
+
if __name__ == '__main__':
|
| 105 |
+
# HF Space 必须使用 7860 端口
|
| 106 |
+
app.run(host='0.0.0.0', port=7860)
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
flask
|
| 2 |
+
datasets
|
| 3 |
+
pillow
|
templates/index.html
ADDED
|
@@ -0,0 +1,492 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="zh-CN">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Fine-T2I Gallery Explorer</title>
|
| 7 |
+
<style>
|
| 8 |
+
:root {
|
| 9 |
+
--bg-color: #0d1117;
|
| 10 |
+
--card-bg: #161b22;
|
| 11 |
+
--header-bg: #21262d;
|
| 12 |
+
--text-main: #c9d1d9;
|
| 13 |
+
--text-bright: #ffffff;
|
| 14 |
+
--accent: #2f81f7;
|
| 15 |
+
--border-color: #30363d;
|
| 16 |
+
--json-color: #7ee787;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
body {
|
| 20 |
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
|
| 21 |
+
background-color: var(--bg-color);
|
| 22 |
+
color: var(--text-main);
|
| 23 |
+
margin: 0;
|
| 24 |
+
padding: 0;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
/* 顶部导航与搜索栏 */
|
| 28 |
+
header {
|
| 29 |
+
background-color: var(--header-bg);
|
| 30 |
+
padding: 20px;
|
| 31 |
+
border-bottom: 1px solid var(--border-color);
|
| 32 |
+
position: sticky;
|
| 33 |
+
top: 0;
|
| 34 |
+
z-index: 100;
|
| 35 |
+
box-shadow: 0 4px 12px rgba(0,0,0,0.5);
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
.search-container {
|
| 39 |
+
max-width: 1200px;
|
| 40 |
+
margin: 0 auto;
|
| 41 |
+
display: flex;
|
| 42 |
+
gap: 15px;
|
| 43 |
+
align-items: center;
|
| 44 |
+
justify-content: center;
|
| 45 |
+
flex-wrap: wrap;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
.search-container h2 {
|
| 49 |
+
margin: 0 20px 0 0;
|
| 50 |
+
color: var(--text-bright);
|
| 51 |
+
font-size: 1.2rem;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
select, input, button {
|
| 55 |
+
background: var(--bg-color);
|
| 56 |
+
border: 1px solid var(--border-color);
|
| 57 |
+
color: var(--text-main);
|
| 58 |
+
padding: 10px 15px;
|
| 59 |
+
border-radius: 6px;
|
| 60 |
+
font-size: 14px;
|
| 61 |
+
outline: none;
|
| 62 |
+
transition: border-color 0.2s;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
select:focus, input:focus {
|
| 66 |
+
border-color: var(--accent);
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
button {
|
| 70 |
+
background-color: var(--accent);
|
| 71 |
+
color: white;
|
| 72 |
+
border: none;
|
| 73 |
+
cursor: pointer;
|
| 74 |
+
font-weight: 600;
|
| 75 |
+
padding: 10px 25px;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
button:hover {
|
| 79 |
+
opacity: 0.9;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
/* 确保瀑布流容器有足够的间距 */
|
| 83 |
+
.gallery-wrapper {
|
| 84 |
+
max-width: 1600px;
|
| 85 |
+
margin: 40px auto; /* 增加与 Header 的间距 */
|
| 86 |
+
padding: 0 20px;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
.masonry-grid {
|
| 90 |
+
column-count: 4; /* 大屏幕4列 */
|
| 91 |
+
column-gap: 20px;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
@media (max-width: 1200px) { .masonry-grid { column-count: 3; } }
|
| 95 |
+
@media (max-width: 800px) { .masonry-grid { column-count: 2; } }
|
| 96 |
+
@media (max-width: 500px) { .masonry-grid { column-count: 1; } }
|
| 97 |
+
|
| 98 |
+
.card {
|
| 99 |
+
background: var(--card-bg);
|
| 100 |
+
margin-bottom: 20px;
|
| 101 |
+
break-inside: avoid; /* 核心:防止图片跨列截断 */
|
| 102 |
+
border-radius: 12px;
|
| 103 |
+
overflow: hidden;
|
| 104 |
+
border: 1px solid var(--border-color);
|
| 105 |
+
cursor: pointer;
|
| 106 |
+
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
.card:hover {
|
| 110 |
+
transform: translateY(-4px);
|
| 111 |
+
box-shadow: 0 8px 24px rgba(0,0,0,0.4);
|
| 112 |
+
border-color: var(--accent);
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
.card img {
|
| 116 |
+
width: 100%;
|
| 117 |
+
height: auto; /* 保持图片原始比例 */
|
| 118 |
+
display: block;
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
/* 弹窗样式 (Modal) */
|
| 122 |
+
.modal {
|
| 123 |
+
display: none;
|
| 124 |
+
position: fixed;
|
| 125 |
+
top: 0; left: 0; width: 100%; height: 100%;
|
| 126 |
+
background: rgba(0,0,0,0.9);
|
| 127 |
+
z-index: 2000;
|
| 128 |
+
justify-content: center;
|
| 129 |
+
align-items: center;
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
.modal-content {
|
| 133 |
+
background: var(--card-bg);
|
| 134 |
+
width: 95%;
|
| 135 |
+
max-width: 1300px;
|
| 136 |
+
height: 85vh;
|
| 137 |
+
display: flex;
|
| 138 |
+
border-radius: 16px;
|
| 139 |
+
overflow: hidden;
|
| 140 |
+
position: relative;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
.modal-left {
|
| 144 |
+
flex: 1.5;
|
| 145 |
+
background: #000;
|
| 146 |
+
display: flex;
|
| 147 |
+
align-items: center;
|
| 148 |
+
justify-content: center;
|
| 149 |
+
padding: 20px;
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
.modal-left img {
|
| 153 |
+
max-width: 100%;
|
| 154 |
+
max-height: 100%;
|
| 155 |
+
object-fit: contain;
|
| 156 |
+
box-shadow: 0 0 20px rgba(255,255,255,0.1);
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
.modal-right {
|
| 160 |
+
flex: 1;
|
| 161 |
+
padding: 30px;
|
| 162 |
+
overflow-y: auto;
|
| 163 |
+
border-left: 1px solid var(--border-color);
|
| 164 |
+
display: flex;
|
| 165 |
+
flex-direction: column;
|
| 166 |
+
gap: 20px;
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
.modal-right h3 {
|
| 170 |
+
margin-top: 0;
|
| 171 |
+
color: var(--accent);
|
| 172 |
+
font-size: 1rem;
|
| 173 |
+
text-transform: uppercase;
|
| 174 |
+
letter-spacing: 1px;
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
.text-box {
|
| 178 |
+
background: rgba(0,0,0,0.3);
|
| 179 |
+
padding: 15px;
|
| 180 |
+
border-radius: 8px;
|
| 181 |
+
font-size: 14px;
|
| 182 |
+
line-height: 1.6;
|
| 183 |
+
white-space: pre-wrap;
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
pre {
|
| 187 |
+
background: #000;
|
| 188 |
+
padding: 15px;
|
| 189 |
+
border-radius: 8px;
|
| 190 |
+
color: var(--json-color);
|
| 191 |
+
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
|
| 192 |
+
font-size: 13px;
|
| 193 |
+
overflow-x: auto;
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
.close-modal {
|
| 197 |
+
position: absolute;
|
| 198 |
+
top: 15px;
|
| 199 |
+
right: 20px;
|
| 200 |
+
font-size: 30px;
|
| 201 |
+
color: white;
|
| 202 |
+
cursor: pointer;
|
| 203 |
+
z-index: 2100;
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
/* 状态提示 */
|
| 207 |
+
.empty-state {
|
| 208 |
+
text-align: center;
|
| 209 |
+
padding: 100px;
|
| 210 |
+
font-size: 1.2rem;
|
| 211 |
+
color: #8b949e;
|
| 212 |
+
}
|
| 213 |
+
/* 独立 Header Block 样式 */
|
| 214 |
+
.project-header {
|
| 215 |
+
background-color: var(--header-bg);
|
| 216 |
+
padding: 80px 20px; /* 增加内边距,使其更像一个独立的 Hero Section */
|
| 217 |
+
border-bottom: 1px solid var(--border-color);
|
| 218 |
+
display: flex;
|
| 219 |
+
justify-content: center;
|
| 220 |
+
position: relative; /* 确保它随流布局,不固定 */
|
| 221 |
+
}
|
| 222 |
+
.header-container {
|
| 223 |
+
max-width: 1000px;
|
| 224 |
+
width: 100%;
|
| 225 |
+
text-align: center;
|
| 226 |
+
}
|
| 227 |
+
.search-block {
|
| 228 |
+
margin-top: 20px;
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
/* 标题样式保持大字号 */
|
| 232 |
+
.project-title {
|
| 233 |
+
font-size: 3rem; /* 稍微再加大一点,增强学术主页感 */
|
| 234 |
+
color: var(--text-bright);
|
| 235 |
+
margin: 0 0 25px 0;
|
| 236 |
+
line-height: 1.2;
|
| 237 |
+
font-weight: 800;
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
/* 作者:居中,字号加大 */
|
| 241 |
+
/* 作者区域样式优化 */
|
| 242 |
+
.author-list {
|
| 243 |
+
font-size: 1.3rem;
|
| 244 |
+
margin-bottom: 25px;
|
| 245 |
+
color: var(--text-main); /* 逗号的颜色 */
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
.author-list a {
|
| 249 |
+
/* 使用一种更柔和、有科技感的青蓝色 */
|
| 250 |
+
color: #58a6ff;
|
| 251 |
+
text-decoration: none;
|
| 252 |
+
margin: 0 10px;
|
| 253 |
+
font-weight: 500;
|
| 254 |
+
position: relative;
|
| 255 |
+
transition: color 0.3s ease;
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
/* 悬停效果:改变颜色并显示下划线 */
|
| 259 |
+
.author-list a:hover {
|
| 260 |
+
color: #a5d6ff; /* 悬停时颜色变浅 */
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
/* 可选:增加一个优雅的底部渐变线条 */
|
| 264 |
+
.author-list a::after {
|
| 265 |
+
content: '';
|
| 266 |
+
position: absolute;
|
| 267 |
+
width: 0;
|
| 268 |
+
height: 1px;
|
| 269 |
+
bottom: -2px;
|
| 270 |
+
left: 0;
|
| 271 |
+
background-color: #a5d6ff;
|
| 272 |
+
transition: width 0.3s ease;
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
.author-list a:hover::after {
|
| 276 |
+
width: 100%;
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
/* HF 按钮 */
|
| 280 |
+
.external-links {
|
| 281 |
+
margin-bottom: 30px;
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
.hf-btn {
|
| 285 |
+
display: inline-block;
|
| 286 |
+
font-size: 1.1rem;
|
| 287 |
+
padding: 12px 30px;
|
| 288 |
+
background: #238636;
|
| 289 |
+
color: white;
|
| 290 |
+
border-radius: 50px;
|
| 291 |
+
text-decoration: none;
|
| 292 |
+
font-weight: 600;
|
| 293 |
+
transition: transform 0.2s;
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
.hf-btn:hover {
|
| 297 |
+
transform: translateY(-2px);
|
| 298 |
+
background: #2ea043;
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
/* 优雅的分割线 */
|
| 302 |
+
.divider {
|
| 303 |
+
height: 2px;
|
| 304 |
+
background: linear-gradient(to right, transparent, var(--border-color), transparent);
|
| 305 |
+
margin: 40px auto;
|
| 306 |
+
width: 80%;
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
/* 搜索栏:独立且居中 */
|
| 310 |
+
.filter-form {
|
| 311 |
+
display: flex;
|
| 312 |
+
justify-content: center;
|
| 313 |
+
align-items: center;
|
| 314 |
+
gap: 20px;
|
| 315 |
+
flex-wrap: wrap;
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
.filter-group {
|
| 319 |
+
display: flex;
|
| 320 |
+
align-items: center;
|
| 321 |
+
gap: 10px;
|
| 322 |
+
}
|
| 323 |
+
|
| 324 |
+
.label-text {
|
| 325 |
+
font-weight: bold;
|
| 326 |
+
color: var(--text-main);
|
| 327 |
+
font-size: 1.1rem;
|
| 328 |
+
}
|
| 329 |
+
|
| 330 |
+
.filter-form select, .filter-form input {
|
| 331 |
+
font-size: 1rem;
|
| 332 |
+
padding: 10px 15px;
|
| 333 |
+
border-radius: 8px;
|
| 334 |
+
min-width: 250px;
|
| 335 |
+
}
|
| 336 |
+
|
| 337 |
+
.submit-btn {
|
| 338 |
+
font-size: 1rem;
|
| 339 |
+
padding: 10px 30px;
|
| 340 |
+
background-color: var(--accent);
|
| 341 |
+
color: white;
|
| 342 |
+
border: none;
|
| 343 |
+
cursor: pointer;
|
| 344 |
+
font-weight: bold;
|
| 345 |
+
border-radius: 8px;
|
| 346 |
+
}
|
| 347 |
+
/* 搜索提示语样式 */
|
| 348 |
+
.search-tips {
|
| 349 |
+
margin-top: 20px;
|
| 350 |
+
text-align: center;
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
.search-tips p {
|
| 354 |
+
margin: 5px 0;
|
| 355 |
+
font-size: 0.9rem; /* 稍微调小一点,不喧宾夺主 */
|
| 356 |
+
color: #8b949e; /* 经典的灰度色,既清晰又柔和 */
|
| 357 |
+
font-style: italic; /* 使用斜体增加提示感 */
|
| 358 |
+
}
|
| 359 |
+
</style>
|
| 360 |
+
</head>
|
| 361 |
+
<body>
|
| 362 |
+
|
| 363 |
+
<header class="project-header">
|
| 364 |
+
<div class="header-container">
|
| 365 |
+
<h1 class="project-title">Fine-T2I: An Open, Large-Scale, and Diverse Dataset for High-Quality T2I Fine-Tuning</h1>
|
| 366 |
+
<h1>(Dataset Explore)</h1>
|
| 367 |
+
<div class="author-list">
|
| 368 |
+
<a href="https://ma-xu.github.io/" target="_blank">Xu Ma</a>,
|
| 369 |
+
<a href="https://bespontaneous.github.io/homepage/" target="_blank">Yitian Zhang</a>,
|
| 370 |
+
<a href="https://dddraxxx.github.io/" target="_blank">Qihua Dong</a>,
|
| 371 |
+
<a href="https://www1.ece.neu.edu/~yunfu/" target="_blank">Yun Fu</a>
|
| 372 |
+
</div>
|
| 373 |
+
|
| 374 |
+
<div class="external-links">
|
| 375 |
+
<a href="https://huggingface.co/datasets/ma-xu/fine-t2i" target="_blank" class="hf-btn">
|
| 376 |
+
🤗 Hugging Face Dataset
|
| 377 |
+
</a>
|
| 378 |
+
</div>
|
| 379 |
+
|
| 380 |
+
<div class="divider"></div>
|
| 381 |
+
|
| 382 |
+
<div class="search-block">
|
| 383 |
+
<form method="post" class="filter-form">
|
| 384 |
+
<div class="filter-group">
|
| 385 |
+
<span class="label-text">Subset:</span>
|
| 386 |
+
<select name="folder">
|
| 387 |
+
{% set options = [
|
| 388 |
+
'enhanced_prompt_random_resolution',
|
| 389 |
+
'enhanced_prompt_square_resolution',
|
| 390 |
+
'original_prompt_random_resolution',
|
| 391 |
+
'original_prompt_square_resolution',
|
| 392 |
+
'curated'
|
| 393 |
+
] %}
|
| 394 |
+
{% for opt in options %}
|
| 395 |
+
<option value="{{ opt }}" {% if request.form.get('folder') == opt %}selected{% endif %}>{{ opt }}</option>
|
| 396 |
+
{% endfor %}
|
| 397 |
+
</select>
|
| 398 |
+
</div>
|
| 399 |
+
|
| 400 |
+
<button type="submit" class="submit-btn">Query Random 100 Samples</button>
|
| 401 |
+
</form>
|
| 402 |
+
<div class="search-tips">
|
| 403 |
+
<p>Notice: Images are compressed for faster loading speeds.</p>
|
| 404 |
+
<p>Wait time: Each query may take 1-2 minutes to load (curated subset longer), please be patient.</p>
|
| 405 |
+
</div>
|
| 406 |
+
</div>
|
| 407 |
+
</div>
|
| 408 |
+
</header>
|
| 409 |
+
|
| 410 |
+
<div class="gallery-wrapper">
|
| 411 |
+
{% if samples %}
|
| 412 |
+
<div class="masonry-grid">
|
| 413 |
+
{% for s in samples %}
|
| 414 |
+
<div class="card"
|
| 415 |
+
onclick='openModal(
|
| 416 |
+
"{{ s.image }}",
|
| 417 |
+
{{ s.text | tojson }},
|
| 418 |
+
{{ s.json | tojson }},
|
| 419 |
+
"{{ s.tar_file }}"
|
| 420 |
+
)'>
|
| 421 |
+
<img src="{{ s.image }}" alt="loading...">
|
| 422 |
+
</div>
|
| 423 |
+
{% endfor %}
|
| 424 |
+
</div>
|
| 425 |
+
{% else %}
|
| 426 |
+
<div class="empty-state">
|
| 427 |
+
{% if request.method == 'POST' %}
|
| 428 |
+
没有找到符合条件的 Sample。
|
| 429 |
+
{% else %}
|
| 430 |
+
请选择文件夹并点击查询。
|
| 431 |
+
{% endif %}
|
| 432 |
+
</div>
|
| 433 |
+
{% endif %}
|
| 434 |
+
</div>
|
| 435 |
+
|
| 436 |
+
<div id="imageModal" class="modal" onclick="closeModal()">
|
| 437 |
+
<span class="close-modal">×</span>
|
| 438 |
+
<div class="modal-content" onclick="event.stopPropagation()">
|
| 439 |
+
<div class="modal-left">
|
| 440 |
+
<img id="fullImg" src="" alt="large view">
|
| 441 |
+
</div>
|
| 442 |
+
<div class="modal-right">
|
| 443 |
+
<h3>Source Tar File</h3>
|
| 444 |
+
<div id="modalTar" style="font-size: 11px; color: #8b949e; background: #000; padding: 8px; border-radius: 4px; word-break: break-all; border: 1px dashed #30363d;"></div>
|
| 445 |
+
<h3>Prompt / TXT</h3>
|
| 446 |
+
<div id="fullText" class="text-box"></div>
|
| 447 |
+
|
| 448 |
+
<h3>JSON Metadata</h3>
|
| 449 |
+
<pre id="fullJson"></pre>
|
| 450 |
+
</div>
|
| 451 |
+
</div>
|
| 452 |
+
</div>
|
| 453 |
+
|
| 454 |
+
<script>
|
| 455 |
+
function openModal(imgSrc, text, jsonData, tarFile) {
|
| 456 |
+
console.log("Modal Triggered");
|
| 457 |
+
console.log("Text length:", text.length);
|
| 458 |
+
console.log("JSON keys:", Object.keys(jsonData));
|
| 459 |
+
|
| 460 |
+
const modal = document.getElementById('imageModal');
|
| 461 |
+
const modalImg = document.getElementById('fullImg');
|
| 462 |
+
const modalText = document.getElementById('fullText');
|
| 463 |
+
const modalJson = document.getElementById('fullJson');
|
| 464 |
+
const modalTar = document.getElementById('modalTar');
|
| 465 |
+
|
| 466 |
+
if (!modal || !modalImg || !modalText || !modalJson) {
|
| 467 |
+
console.error("Missing modal elements in HTML!");
|
| 468 |
+
return;
|
| 469 |
+
}
|
| 470 |
+
|
| 471 |
+
modalImg.src = imgSrc;
|
| 472 |
+
modalText.innerText = text;
|
| 473 |
+
modalTar.innerText = tarFile;
|
| 474 |
+
modalJson.innerText = JSON.stringify(jsonData, null, 2);
|
| 475 |
+
|
| 476 |
+
modal.style.display = 'flex';
|
| 477 |
+
document.body.style.overflow = 'hidden';
|
| 478 |
+
}
|
| 479 |
+
|
| 480 |
+
function closeModal() {
|
| 481 |
+
document.getElementById('imageModal').style.display = 'none';
|
| 482 |
+
document.body.style.overflow = 'auto';
|
| 483 |
+
}
|
| 484 |
+
|
| 485 |
+
// 处理键盘 ESC 退出
|
| 486 |
+
document.addEventListener('keydown', function(e) {
|
| 487 |
+
if (e.key === "Escape") closeModal();
|
| 488 |
+
});
|
| 489 |
+
</script>
|
| 490 |
+
|
| 491 |
+
</body>
|
| 492 |
+
</html>
|