Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -99,23 +99,43 @@ st.title("Model Structure Comparison Tool")
|
|
99 |
model_id1 = st.text_input("Enter the first HuggingFace Model ID")
|
100 |
model_id2 = st.text_input("Enter the second HuggingFace Model ID")
|
101 |
|
102 |
-
if
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
model_id1 = st.text_input("Enter the first HuggingFace Model ID")
|
100 |
model_id2 = st.text_input("Enter the second HuggingFace Model ID")
|
101 |
|
102 |
+
if "compare_button_clicked" not in st.session_state:
|
103 |
+
st.session_state.compare_button_clicked = False
|
104 |
+
|
105 |
+
if st.session_state.compare_button_clicked:
|
106 |
+
with st.spinner('Comparing models and loading tokenizers...'):
|
107 |
+
if model_id1 and model_id2:
|
108 |
+
struct1 = get_model_structure(model_id1)
|
109 |
+
struct2 = get_model_structure(model_id2)
|
110 |
+
|
111 |
+
diff = compare_structures(struct1, struct2)
|
112 |
+
left_html, right_html, diff_found = display_diff(diff)
|
113 |
+
|
114 |
+
st.write("### Comparison Result")
|
115 |
+
if not diff_found:
|
116 |
+
st.success("The model structures are identical.")
|
117 |
+
|
118 |
+
col1, col2 = st.columns([1.5, 1.5]) # Adjust the ratio to make columns wider
|
119 |
+
|
120 |
+
with col1:
|
121 |
+
st.write("### Model 1")
|
122 |
+
st.markdown(left_html, unsafe_allow_html=True)
|
123 |
+
|
124 |
+
with col2:
|
125 |
+
st.write("### Model 2")
|
126 |
+
st.markdown(right_html, unsafe_allow_html=True)
|
127 |
+
|
128 |
+
# Tokenizer verification
|
129 |
+
try:
|
130 |
+
tokenizer1 = AutoTokenizer.from_pretrained(model_id1)
|
131 |
+
tokenizer2 = AutoTokenizer.from_pretrained(model_id2)
|
132 |
+
st.write(f"**{model_id1} Tokenizer Vocab Size**: {tokenizer1.vocab_size}")
|
133 |
+
st.write(f"**{model_id2} Tokenizer Vocab Size**: {tokenizer2.vocab_size}")
|
134 |
+
except Exception as e:
|
135 |
+
st.error(f"Error loading tokenizers: {e}")
|
136 |
+
else:
|
137 |
+
st.error("Please enter both model IDs.")
|
138 |
+
st.session_state.compare_button_clicked = False
|
139 |
+
else:
|
140 |
+
if st.button("Compare Models"):
|
141 |
+
st.session_state.compare_button_clicked = True
|