Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,32 +19,99 @@ def load_model(model_name, model_class, is_bc=False):
|
|
| 19 |
# Set up page configuration
|
| 20 |
st.set_page_config(page_title="SemViQA Demo", layout="wide")
|
| 21 |
|
| 22 |
-
# Custom CSS and
|
| 23 |
st.markdown(
|
| 24 |
"""
|
| 25 |
<style>
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
| 31 |
overflow-y: auto;
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
}
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
}
|
| 38 |
</style>
|
| 39 |
-
<script>
|
| 40 |
-
// JavaScript to make the sidebar sticky
|
| 41 |
-
window.addEventListener('scroll', function() {
|
| 42 |
-
const sidebar = document.querySelector('.stSidebar');
|
| 43 |
-
if (sidebar) {
|
| 44 |
-
sidebar.style.top = `${window.scrollY}px`;
|
| 45 |
-
}
|
| 46 |
-
});
|
| 47 |
-
</script>
|
| 48 |
""",
|
| 49 |
unsafe_allow_html=True,
|
| 50 |
)
|
|
@@ -187,9 +254,9 @@ with st.container():
|
|
| 187 |
<div class='result-box'>
|
| 188 |
<p><strong>Claim:</strong> {res['claim']}</p>
|
| 189 |
<p><strong>Evidence:</strong> {res['evidence']}</p>
|
|
|
|
| 190 |
<p><strong>Evidence Inference Time:</strong> {res['evidence_time']:.2f} seconds</p>
|
| 191 |
<p><strong>Verdict Inference Time:</strong> {res['verdict_time']:.2f} seconds</p>
|
| 192 |
-
<p class='verdict'><span class='verdict-icon'>{verdict_icons.get(res['verdict'], '')}</span>{res['verdict']}</p>
|
| 193 |
{res['details']}
|
| 194 |
</div>
|
| 195 |
""", unsafe_allow_html=True)
|
|
|
|
| 19 |
# Set up page configuration
|
| 20 |
st.set_page_config(page_title="SemViQA Demo", layout="wide")
|
| 21 |
|
| 22 |
+
# Custom CSS: fixed header and tabs, dynamic height, result box formatting
|
| 23 |
st.markdown(
|
| 24 |
"""
|
| 25 |
<style>
|
| 26 |
+
html, body {
|
| 27 |
+
height: 100%;
|
| 28 |
+
margin: 0;
|
| 29 |
+
overflow: hidden;
|
| 30 |
+
}
|
| 31 |
+
.main-container {
|
| 32 |
+
height: calc(100vh - 55px); /* Browser height - 55px */
|
| 33 |
overflow-y: auto;
|
| 34 |
+
padding: 20px;
|
| 35 |
+
}
|
| 36 |
+
.big-title {
|
| 37 |
+
font-size: 36px;
|
| 38 |
+
font-weight: bold;
|
| 39 |
+
color: #4A90E2;
|
| 40 |
+
text-align: center;
|
| 41 |
+
margin-top: 20px;
|
| 42 |
+
position: sticky; /* Pin the header */
|
| 43 |
+
top: 0;
|
| 44 |
+
background-color: white; /* Ensure the header covers content when scrolling */
|
| 45 |
+
z-index: 100; /* Ensure it's above other content */
|
| 46 |
+
}
|
| 47 |
+
.sub-title {
|
| 48 |
+
font-size: 20px;
|
| 49 |
+
color: #666;
|
| 50 |
+
text-align: center;
|
| 51 |
+
margin-bottom: 20px;
|
| 52 |
+
}
|
| 53 |
+
.stButton>button {
|
| 54 |
+
background-color: #4CAF50;
|
| 55 |
+
color: white;
|
| 56 |
+
font-size: 16px;
|
| 57 |
+
width: 100%;
|
| 58 |
+
border-radius: 8px;
|
| 59 |
+
padding: 10px;
|
| 60 |
+
}
|
| 61 |
+
.stTextArea textarea {
|
| 62 |
+
font-size: 16px;
|
| 63 |
+
min-height: 120px;
|
| 64 |
+
}
|
| 65 |
+
.result-box {
|
| 66 |
+
background-color: #f9f9f9;
|
| 67 |
+
padding: 20px;
|
| 68 |
+
border-radius: 10px;
|
| 69 |
+
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
|
| 70 |
+
margin-top: 20px;
|
| 71 |
+
}
|
| 72 |
+
.verdict {
|
| 73 |
+
font-size: 24px;
|
| 74 |
+
font-weight: bold;
|
| 75 |
+
margin: 0;
|
| 76 |
+
display: flex;
|
| 77 |
+
align-items: center;
|
| 78 |
}
|
| 79 |
+
.verdict-icon {
|
| 80 |
+
margin-right: 10px;
|
| 81 |
+
}
|
| 82 |
+
/* Fix the tabs at the top */
|
| 83 |
+
div[data-baseweb="tab-list"] {
|
| 84 |
+
position: sticky;
|
| 85 |
+
top: 55px; /* Height of the header */
|
| 86 |
+
background-color: white;
|
| 87 |
+
z-index: 99;
|
| 88 |
+
}
|
| 89 |
+
/* Fix the sidebar content */
|
| 90 |
+
.stSidebar .sidebar-content {
|
| 91 |
+
background-color: #f0f2f6;
|
| 92 |
+
padding: 20px;
|
| 93 |
+
border-radius: 10px;
|
| 94 |
+
position: sticky;
|
| 95 |
+
top: 55px; /* Height of the header */
|
| 96 |
+
height: calc(100vh - 75px); /* Adjust height to fit within the viewport */
|
| 97 |
+
overflow-y: auto; /* Enable scrolling within the sidebar if content is too long */
|
| 98 |
+
}
|
| 99 |
+
.stSidebar .st-expander {
|
| 100 |
+
background-color: #ffffff;
|
| 101 |
+
border-radius: 10px;
|
| 102 |
+
padding: 10px;
|
| 103 |
+
margin-bottom: 10px;
|
| 104 |
+
}
|
| 105 |
+
.stSidebar .stSlider {
|
| 106 |
+
margin-bottom: 20px;
|
| 107 |
+
}
|
| 108 |
+
.stSidebar .stSelectbox {
|
| 109 |
+
margin-bottom: 20px;
|
| 110 |
+
}
|
| 111 |
+
.stSidebar .stCheckbox {
|
| 112 |
+
margin-bottom: 20px;
|
| 113 |
}
|
| 114 |
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
""",
|
| 116 |
unsafe_allow_html=True,
|
| 117 |
)
|
|
|
|
| 254 |
<div class='result-box'>
|
| 255 |
<p><strong>Claim:</strong> {res['claim']}</p>
|
| 256 |
<p><strong>Evidence:</strong> {res['evidence']}</p>
|
| 257 |
+
<p class='verdict'><span class='verdict-icon'>{verdict_icons.get(res['verdict'], '')}</span>{res['verdict']}</p>
|
| 258 |
<p><strong>Evidence Inference Time:</strong> {res['evidence_time']:.2f} seconds</p>
|
| 259 |
<p><strong>Verdict Inference Time:</strong> {res['verdict_time']:.2f} seconds</p>
|
|
|
|
| 260 |
{res['details']}
|
| 261 |
</div>
|
| 262 |
""", unsafe_allow_html=True)
|