Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -38,6 +38,7 @@ import appStore.target as target_analysis
|
|
38 |
import appStore.doc_processing as processing
|
39 |
from utils.uploadAndExample import add_upload
|
40 |
from utils.vulnerability_classifier import label_dict
|
|
|
41 |
import pandas as pd
|
42 |
import plotly.express as px
|
43 |
|
@@ -51,7 +52,16 @@ with st.sidebar:
|
|
51 |
or else you can try a example document',
|
52 |
options = ('Upload Document', 'Try Example'),
|
53 |
horizontal = True)
|
54 |
-
add_upload(choice)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
with st.container():
|
57 |
st.markdown("<h2 style='text-align: center;'> Vulnerability Analysis 3.0 </h2>", unsafe_allow_html=True)
|
@@ -97,85 +107,6 @@ if st.button("Analyze Document"):
|
|
97 |
if 'key0' in st.session_state:
|
98 |
|
99 |
vulnerability_analysis.vulnerability_display()
|
100 |
-
target_analysis.target_display()
|
101 |
-
|
102 |
-
# ###################################################################
|
103 |
-
|
104 |
-
# #with st.sidebar:
|
105 |
-
# # topic = st.radio(
|
106 |
-
# # "Which category you want to explore?",
|
107 |
-
# # (['Vulnerability', 'Concrete targets/actions/measures']))
|
108 |
-
|
109 |
-
# #if topic == 'Vulnerability':
|
110 |
|
111 |
-
|
112 |
-
# df_vul = st.session_state['key0']
|
113 |
-
# st.write(df_vul)
|
114 |
-
|
115 |
-
# col1, col2 = st.columns([1,1])
|
116 |
-
|
117 |
-
# with col1:
|
118 |
-
|
119 |
-
# # Header
|
120 |
-
# st.subheader("Explore references to vulnerable groups:")
|
121 |
-
|
122 |
-
# # Text
|
123 |
-
# num_paragraphs = len(df_vul['Vulnerability Label'])
|
124 |
-
# num_references = df_vul['Vulnerability Label'].apply(lambda x: 'Other' not in x).sum()
|
125 |
-
|
126 |
-
# st.markdown(f"""<div style="text-align: justify;"> The document contains a
|
127 |
-
# total of <span style="color: red;">{num_paragraphs}</span> paragraphs.
|
128 |
-
# We identified <span style="color: red;">{num_references}</span>
|
129 |
-
# references to vulnerable groups.</div>
|
130 |
-
# <br>
|
131 |
-
# In the pie chart on the right you can see the distribution of the different
|
132 |
-
# groups defined. For a more detailed view in the text, see the paragraphs and
|
133 |
-
# their respective labels in the table below.</div>""", unsafe_allow_html=True)
|
134 |
-
|
135 |
-
# with col2:
|
136 |
-
|
137 |
-
# ### Bar chart
|
138 |
-
|
139 |
-
# # # Create a df that stores all the labels
|
140 |
-
# df_labels = pd.DataFrame(list(label_dict.items()), columns=['Label ID', 'Label'])
|
141 |
-
|
142 |
-
# # Count how often each label appears in the "Vulnerability Labels" column
|
143 |
-
# group_counts = {}
|
144 |
-
|
145 |
-
# # Iterate through each sublist
|
146 |
-
# for index, row in df_vul.iterrows():
|
147 |
-
|
148 |
-
# # Iterate through each group in the sublist
|
149 |
-
# for sublist in row['Vulnerability Label']:
|
150 |
-
|
151 |
-
# # Update the count in the dictionary
|
152 |
-
# group_counts[sublist] = group_counts.get(sublist, 0) + 1
|
153 |
-
|
154 |
-
# # Create a new dataframe from group_counts
|
155 |
-
# df_label_count = pd.DataFrame(list(group_counts.items()), columns=['Label', 'Count'])
|
156 |
-
|
157 |
-
# # Merge the label counts with the df_label DataFrame
|
158 |
-
# df_label_count = df_labels.merge(df_label_count, on='Label', how='left')
|
159 |
-
# st.write("df_label_count")
|
160 |
-
|
161 |
-
# # # Configure graph
|
162 |
-
# # fig = px.pie(df_labels,
|
163 |
-
# # names="Label",
|
164 |
-
# # values="Count",
|
165 |
-
# # title='Label Counts',
|
166 |
-
# # hover_name="Count",
|
167 |
-
# # color_discrete_sequence=px.colors.qualitative.Plotly
|
168 |
-
# # )
|
169 |
-
|
170 |
-
# # #Show plot
|
171 |
-
# # st.plotly_chart(fig, use_container_width=True)
|
172 |
-
|
173 |
-
# # ### Table
|
174 |
-
# st.table(df_vul[df_vul['Vulnerability Label'] != 'Other'])
|
175 |
-
|
176 |
-
# vulnerability_analysis.vulnerability_display()
|
177 |
-
# elif topic == 'Action':
|
178 |
-
# policyaction.action_display()
|
179 |
-
# else:
|
180 |
-
# policyaction.policy_display()
|
181 |
-
#st.write(st.session_state.key0)
|
|
|
38 |
import appStore.doc_processing as processing
|
39 |
from utils.uploadAndExample import add_upload
|
40 |
from utils.vulnerability_classifier import label_dict
|
41 |
+
from utils.config import model_dict
|
42 |
import pandas as pd
|
43 |
import plotly.express as px
|
44 |
|
|
|
52 |
or else you can try a example document',
|
53 |
options = ('Upload Document', 'Try Example'),
|
54 |
horizontal = True)
|
55 |
+
add_upload(choice)
|
56 |
+
|
57 |
+
# Create a list of options for the dropdown
|
58 |
+
model_options = ['Llama3.1-8B','Llama3.1-70B','Llama3.1-405B',]
|
59 |
+
|
60 |
+
# Dropdown selectbox: model
|
61 |
+
model_sel = st.selectbox('Select a model:', model_options)
|
62 |
+
model_sel_name = model_dict[model_sel]
|
63 |
+
|
64 |
+
st.session_state['model_sel_name'] = model_sel_name
|
65 |
|
66 |
with st.container():
|
67 |
st.markdown("<h2 style='text-align: center;'> Vulnerability Analysis 3.0 </h2>", unsafe_allow_html=True)
|
|
|
107 |
if 'key0' in st.session_state:
|
108 |
|
109 |
vulnerability_analysis.vulnerability_display()
|
110 |
+
target_analysis.target_display(model_sel_name=model_sel_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
|
112 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|