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