Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -35,32 +35,49 @@ with open("gpt4o_50.json", "r") as file:
|
|
35 |
|
36 |
st.title("JSON Data Visualization")
|
37 |
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
-
#
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
# 遍历数据并将内容分配到列
|
46 |
-
for idx, (qwen, gpt) in enumerate(zip(qwen_data, gpt_data)):
|
47 |
image_name, image_url, description, qwen_category = qwen
|
48 |
_, _, _, gpt_category = gpt
|
49 |
|
50 |
-
# 将内容添加到对应列的内容列表中
|
51 |
-
col_idx = idx % columns_per_row
|
52 |
content = f"""
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
59 |
"""
|
60 |
-
|
61 |
-
|
62 |
-
# 渲染每列内容
|
63 |
-
for col_idx, col_content in enumerate(content_list):
|
64 |
-
with columns[col_idx]:
|
65 |
-
for item in col_content:
|
66 |
-
st.markdown(item)
|
|
|
35 |
|
36 |
st.title("JSON Data Visualization")
|
37 |
|
38 |
+
# 定义 CSS 样式
|
39 |
+
st.markdown("""
|
40 |
+
<style>
|
41 |
+
.row {
|
42 |
+
display: flex;
|
43 |
+
flex-wrap: wrap;
|
44 |
+
justify-content: space-between;
|
45 |
+
}
|
46 |
+
.column {
|
47 |
+
flex: 1 1 calc(25% - 20px); /* 固定为 4 列,每列占 25% 减去间距 */
|
48 |
+
max-width: calc(25% - 20px);
|
49 |
+
margin: 10px;
|
50 |
+
box-sizing: border-box;
|
51 |
+
}
|
52 |
+
.content {
|
53 |
+
height: 100%;
|
54 |
+
display: flex;
|
55 |
+
flex-direction: column;
|
56 |
+
justify-content: space-between;
|
57 |
+
background-color: #f9f9f9;
|
58 |
+
padding: 10px;
|
59 |
+
border: 1px solid #ddd;
|
60 |
+
border-radius: 5px;
|
61 |
+
}
|
62 |
+
</style>
|
63 |
+
""", unsafe_allow_html=True)
|
64 |
|
65 |
+
# 渲染内容
|
66 |
+
st.markdown('<div class="row">', unsafe_allow_html=True)
|
67 |
+
for qwen, gpt in zip(qwen_data, gpt_data):
|
|
|
|
|
|
|
68 |
image_name, image_url, description, qwen_category = qwen
|
69 |
_, _, _, gpt_category = gpt
|
70 |
|
|
|
|
|
71 |
content = f"""
|
72 |
+
<div class="column">
|
73 |
+
<div class="content">
|
74 |
+
<h4>{image_name}</h4>
|
75 |
+
<img src="{image_url}" style="width:100%;" alt="{description}">
|
76 |
+
<p><strong>Description:</strong> {description}</p>
|
77 |
+
<p><strong>Qwen_Category:</strong> {qwen_category}</p>
|
78 |
+
<p><strong>GPT_Category:</strong> {gpt_category}</p>
|
79 |
+
</div>
|
80 |
+
</div>
|
81 |
"""
|
82 |
+
st.markdown(content, unsafe_allow_html=True)
|
83 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|