Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -22,14 +22,17 @@ def compare_structures(struct1, struct2):
|
|
22 |
def display_diff(diff):
|
23 |
left_lines = []
|
24 |
right_lines = []
|
|
|
25 |
|
26 |
for line in diff:
|
27 |
if line.startswith('- '):
|
28 |
left_lines.append(f'<span style="background-color: #ffdddd;">{line[2:]}</span>')
|
29 |
right_lines.append('')
|
|
|
30 |
elif line.startswith('+ '):
|
31 |
right_lines.append(f'<span style="background-color: #ddffdd;">{line[2:]}</span>')
|
32 |
left_lines.append('')
|
|
|
33 |
elif line.startswith(' '):
|
34 |
left_lines.append(line[2:])
|
35 |
right_lines.append(line[2:])
|
@@ -39,7 +42,7 @@ def display_diff(diff):
|
|
39 |
left_html = "<br>".join(left_lines)
|
40 |
right_html = "<br>".join(right_lines)
|
41 |
|
42 |
-
return left_html, right_html
|
43 |
|
44 |
st.title("Model Structure Comparison Tool")
|
45 |
model_id1 = st.text_input("Enter the first HuggingFace Model ID")
|
@@ -50,18 +53,21 @@ if model_id1 and model_id2:
|
|
50 |
struct2 = get_model_structure(model_id2)
|
51 |
|
52 |
diff = compare_structures(struct1, struct2)
|
53 |
-
left_html, right_html = display_diff(diff)
|
54 |
|
55 |
st.write("### Comparison Result")
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
st.
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
65 |
|
66 |
# Apply custom CSS for wider layout
|
67 |
st.markdown(
|
|
|
22 |
def display_diff(diff):
|
23 |
left_lines = []
|
24 |
right_lines = []
|
25 |
+
diff_found = False
|
26 |
|
27 |
for line in diff:
|
28 |
if line.startswith('- '):
|
29 |
left_lines.append(f'<span style="background-color: #ffdddd;">{line[2:]}</span>')
|
30 |
right_lines.append('')
|
31 |
+
diff_found = True
|
32 |
elif line.startswith('+ '):
|
33 |
right_lines.append(f'<span style="background-color: #ddffdd;">{line[2:]}</span>')
|
34 |
left_lines.append('')
|
35 |
+
diff_found = True
|
36 |
elif line.startswith(' '):
|
37 |
left_lines.append(line[2:])
|
38 |
right_lines.append(line[2:])
|
|
|
42 |
left_html = "<br>".join(left_lines)
|
43 |
right_html = "<br>".join(right_lines)
|
44 |
|
45 |
+
return left_html, right_html, diff_found
|
46 |
|
47 |
st.title("Model Structure Comparison Tool")
|
48 |
model_id1 = st.text_input("Enter the first HuggingFace Model ID")
|
|
|
53 |
struct2 = get_model_structure(model_id2)
|
54 |
|
55 |
diff = compare_structures(struct1, struct2)
|
56 |
+
left_html, right_html, diff_found = display_diff(diff)
|
57 |
|
58 |
st.write("### Comparison Result")
|
59 |
+
if not diff_found:
|
60 |
+
st.success("The model structures are identical.")
|
61 |
+
else:
|
62 |
+
col1, col2 = st.columns([1.5, 1.5]) # Adjust the ratio to make columns wider
|
63 |
+
|
64 |
+
with col1:
|
65 |
+
st.write("### Model 1")
|
66 |
+
st.markdown(left_html, unsafe_allow_html=True)
|
67 |
+
|
68 |
+
with col2:
|
69 |
+
st.write("### Model 2")
|
70 |
+
st.markdown(right_html, unsafe_allow_html=True)
|
71 |
|
72 |
# Apply custom CSS for wider layout
|
73 |
st.markdown(
|