File size: 5,961 Bytes
4946c0b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
import ast
import pandas as pd
import streamlit as st
st.set_page_config(layout="wide")
SHORT_CAPTIONS = [
'ALIGN:align-base:coyo700m', 'OpenCLIP:ViT-B-32:openai', 'OpenCLIP:ViT-B-16:openai',
'OpenCLIP:ViT-L-14:openai', 'OpenCLIP:ViT-L-14-336:openai',
'OpenCLIP:ViT-B-32:laion2b_s34b_b79k', 'OpenCLIP:ViT-B-16:laion2b_s34b_b88k',
'OpenCLIP:ViT-L-14:laion2b_s32b_b82k', 'OpenCLIP:ViT-g-14:laion2b_s34b_b88k',
'OpenCLIP:ViT-H-14:laion2b_s32b_b79k', 'OpenCLIP:roberta-ViT-B-32:laion2b_s12b_b32k',
'OpenCLIP:ViT-B-16-SigLIP:webli', 'OpenCLIP:ViT-B-16-SigLIP-384:webli',
'OpenCLIP:ViT-L-16-SigLIP-256:webli', 'OpenCLIP:ViT-L-16-SigLIP-384:webli',
'OpenCLIP:ViT-SO400M-14-SigLIP:webli', 'OpenCLIP:coca_ViT-B-32:laion2b_s13b_b90k',
'OpenCLIP:coca_ViT-L-14:laion2b_s13b_b90k'
]
LONG_CAPTIONS = [
'DreamLIP:dreamlip-vitb16:cc3m-long', 'DreamLIP:dreamlip-vitb16:cc12m-long',
'DreamLIP:dreamlip-vitb16:yfcc15m-long', 'DreamLIP:dreamlip-vitb16:cc30m-long',
"FLAIR:flair-vitb16:cc3m-recap", "FLAIR:flair-vitb16:cc12m-recap",
"FLAIR:flair-vitb16:yfcc15m-recap", "FLAIR:flair-vitb16:cc30m-recap",
'CLIPS:CLIPS-Large-14-224:recap-datacomp1b', 'CLIPS:CLIPS-Large-14-336:recap-datacomp1b',
'CLIPS:CLIPS-Huge-14-224:recap-datacomp1b', 'LoTLIP:LoTLIP-ViT-B-32:lotlip100m',
'LoTLIP:LoTLIP-ViT-B-16:lotlip100m', 'Recap-CLIP:ViT-L-16-HTxt-Recap-CLIP:recap-datacomp1b',
'LongCLIP:longclip-vitb32:sharegpt4v-1m', 'LongCLIP:longclip-vitb16:sharegpt4v-1m',
'LongCLIP:longclip-vitl14:sharegpt4v-1m', 'LongCLIP:longclip-vitl14_336px:sharegpt4v-1m',
'Jina-CLIP:jina-clip-v1:jinaai', 'Jina-CLIP:jina-clip-v2:jinaai'
]
COMPOSITIONALITY = [
'OpenCLIP:ViT-B-32:openai', 'StructuredCLIP:NegCLIP-ViT-B-32:coco-ft',
'StructuredCLIP:CE-CLIP-ViT-B-32:coco-ft', 'StructuredCLIP:DAC-LLM-ViT-B-32:cc3m-ft',
'StructuredCLIP:DAC-SAM-ViT-B-32:cc3m-ft', 'FSC-CLIP:fsc-clip-ViT-B-32:laioncoco-ft',
'FSC-CLIP:fsc-clip-ViT-B-16:laioncoco-ft', 'FSC-CLIP:fsc-clip-ViT-L-14:laioncoco-ft'
]
DECODERS = [
'vqascore:instructblip-flant5-xl:none', 'vqascore:clip-flant5-xl:none',
'vqascore:llava-v1.5-7b:none', 'vqascore:sharegpt4v-7b:none',
'visualgptscore:instructblip-flant5-xl:none', 'visualgptscore:clip-flant5-xl:none',
'visualgptscore:llava-v1.5-7b:none', 'visualgptscore:sharegpt4v-7b:none'
]
MODEL_GROUPS = {
"short_captions": SHORT_CAPTIONS,
"long_captions": LONG_CAPTIONS,
"compositionality": COMPOSITIONALITY
}
def render_mi_table(df, level0_cols):
# HTML 스타일 정의
table_style = """
<style>
table {
width: 100%;
border-collapse: collapse;
}
th, td {
border: 1px solid black;
text-align: center;
padding: 8px;
}
th {
background-color: #262730;
}
</style>
"""
# 상위 헤더 (레벨 0)
header_html = "<tr>"
for col in level0_cols:
colspan = len(df.xs(col, axis=1, level=0).columns) if col else 1
header_html += f'<th colspan="{colspan}" style="text-align: center;">{col if col else ""}</th>'
header_html += "</tr>"
# 하위 헤더 (레벨 1)
sub_header_html = "<tr>"
for col in df.columns:
sub_header_html += f"<th style='text-align: center;'>{col[1] if len(col) > 1 else col[0]}</th>"
sub_header_html += "</tr>"
# 데이터 HTML 생성
def map_val(value):
try:
value = f"{float(value):.1f}"
except:
value = value
return value
rows_html = ""
for _, row in df.iterrows():
rows_html += "<tr>" + "".join(f"<td>{map_val(value)}</td>" for value in row) + "</tr>"
# 최종 HTML 합치기
table_html = f"""
{table_style}
<table>
{header_html}
{sub_header_html}
{rows_html}
</table>
"""
return table_html
def format_df(df):
cols = []
for col in df.columns:
if col in [("Model", "family"), ("Model", "model"), ("Model", "tag")]:
continue
cols.append(col)
formatted_df = df.style.format({col: "{:.1f}" for col in cols})
return formatted_df
def print_table(df):
level0_cols = []
for col in df.columns:
if col[0] not in level0_cols:
level0_cols.append(col[0])
st.markdown(render_mi_table(df, level0_cols), unsafe_allow_html=True)
def print_table_summary(df, model_names):
columns = [("Model", "family"), ("Model", "model"), ("Model", "tag")]
named_rows = df[columns].apply(lambda row: ":".join(row), axis=1)
new_rows = []
for name in model_names:
new_rows.append(df[named_rows == name])
new_rows = pd.concat(new_rows, axis=0)
new_rows.columns = pd.MultiIndex.from_tuples(new_rows.columns)
print_table(new_rows)
# Streamlit app
def main():
st.title("Interface")
df = pd.read_csv("data/250126/summary.csv")
df.columns = [ast.literal_eval(col) for col in df.columns]
for group, model_names in MODEL_GROUPS.items():
st.markdown(f"## {group} models")
if group == "short_captions":
pass
if group == "long_captions":
pass
if group == "compositionality":
pass
print_table_summary(df, model_names)
df = pd.read_csv("data/250126/decoder_summary_valid.csv")
df.columns = [ast.literal_eval(col) for col in df.columns]
st.markdown("## Decoder-based models (VALID SAMPLES)")
print_table_summary(df, DECODERS)
df = pd.read_csv("data/250126/decoder_summary_invalid.csv")
df.columns = [ast.literal_eval(col) for col in df.columns]
st.markdown("## Decoder-based models (INVALID SAMPLES)")
print_table_summary(df, DECODERS)
if __name__ == "__main__":
main()
|