Spaces:
Runtime error
Runtime error
Basanth
commited on
Commit
·
b544d86
1
Parent(s):
e5d2c3b
file check added,spinner added
Browse files- apps/demo.py +28 -17
- src/file_uploader.py +5 -4
apps/demo.py
CHANGED
@@ -13,8 +13,12 @@ model = load_model()
|
|
13 |
skill_extractor = load_skill_extractor()
|
14 |
|
15 |
def app():
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
18 |
|
19 |
st.markdown(f"""<h1
|
20 |
style= "text-align:-webkit-center;
|
@@ -32,15 +36,18 @@ def app():
|
|
32 |
identify skill gaps, and prioritize development
|
33 |
</h1>""",unsafe_allow_html=True)
|
34 |
|
|
|
35 |
|
36 |
|
|
|
|
|
37 |
|
38 |
-
|
39 |
-
uploaded_file = st.file_uploader("Choose a file",type =['pdf','docx'],label_visibility = "collapsed")
|
40 |
if uploaded_file is not None:
|
41 |
-
st.session_state
|
|
|
42 |
else:
|
43 |
-
|
|
|
44 |
|
45 |
|
46 |
# st.title("Uploaded resume ")
|
@@ -50,20 +57,24 @@ def app():
|
|
50 |
# # input_text = st.text_area('', value=default_text, height=200)
|
51 |
# submit_button = st.form_submit_button(label="Submit")
|
52 |
|
|
|
|
|
|
|
53 |
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
|
|
|
62 |
col1, col2,= st.columns(2)
|
63 |
gaugeData,option = gauge(value=0)
|
64 |
with st.form(key='result'):
|
65 |
-
if st.session_state
|
66 |
-
gaugeData[0]['value']=match
|
67 |
with col1:
|
68 |
st.markdown(f"""<h1 style= "text-align: -webkit-center;font-family: sans-serif;">Job Category</h1>""", unsafe_allow_html=True)
|
69 |
html_str = f"""
|
@@ -73,7 +84,7 @@ def app():
|
|
73 |
color: #ff4d4f;
|
74 |
font-family: sans-serif;
|
75 |
font-weight: bold;">
|
76 |
-
{job_cat}
|
77 |
</div>
|
78 |
"""
|
79 |
|
@@ -97,7 +108,7 @@ def app():
|
|
97 |
# st.markdown('-----------')
|
98 |
df = create_dfs(annotations)
|
99 |
st.markdown(f"""<h1 style= "text-align: -webkit-center;font-family: sans-serif;">Extracted Skill</h1>""",unsafe_allow_html=True)
|
100 |
-
st.write(", \n".join(df))
|
101 |
|
102 |
|
103 |
|
|
|
13 |
skill_extractor = load_skill_extractor()
|
14 |
|
15 |
def app():
|
16 |
+
session_items = ['input_text','match','job_cat','rerun']
|
17 |
+
if any(session_items) not in st.session_state:
|
18 |
+
st.session_state.input_text = ''
|
19 |
+
st.session_state.job_cat = ''
|
20 |
+
st.session_state.match = 0
|
21 |
+
st.session_state.rerun = False
|
22 |
|
23 |
st.markdown(f"""<h1
|
24 |
style= "text-align:-webkit-center;
|
|
|
36 |
identify skill gaps, and prioritize development
|
37 |
</h1>""",unsafe_allow_html=True)
|
38 |
|
39 |
+
|
40 |
|
41 |
|
42 |
+
|
43 |
+
uploaded_file = st.file_uploader("Choose a file",label_visibility = "collapsed")
|
44 |
|
|
|
|
|
45 |
if uploaded_file is not None:
|
46 |
+
st.session_state.input_text,st.session_state.rerun = extract_text_from_file(uploaded_file)
|
47 |
+
|
48 |
else:
|
49 |
+
st.session_state.rerun = False
|
50 |
+
|
51 |
|
52 |
|
53 |
# st.title("Uploaded resume ")
|
|
|
57 |
# # input_text = st.text_area('', value=default_text, height=200)
|
58 |
# submit_button = st.form_submit_button(label="Submit")
|
59 |
|
60 |
+
if st.session_state.rerun:
|
61 |
+
with st.spinner('Processing.....'):
|
62 |
+
|
63 |
|
64 |
+
cls_text = clean_text(st.session_state.input_text)
|
65 |
+
prob,st.session_state.job_cat = predict_cat(model, cls_text)
|
66 |
+
annotations = skill_extractor.annotate(cls_text,tresh=1)
|
67 |
+
text = annotations['text']
|
68 |
+
annotations = annotations['results']
|
69 |
+
df = create_dfs(annotations)
|
70 |
+
st.session_state.match = get_match(st.session_state.job_cat ,df)
|
71 |
|
72 |
+
|
73 |
col1, col2,= st.columns(2)
|
74 |
gaugeData,option = gauge(value=0)
|
75 |
with st.form(key='result'):
|
76 |
+
if st.session_state.rerun:
|
77 |
+
gaugeData[0]['value']=st.session_state.match
|
78 |
with col1:
|
79 |
st.markdown(f"""<h1 style= "text-align: -webkit-center;font-family: sans-serif;">Job Category</h1>""", unsafe_allow_html=True)
|
80 |
html_str = f"""
|
|
|
84 |
color: #ff4d4f;
|
85 |
font-family: sans-serif;
|
86 |
font-weight: bold;">
|
87 |
+
{st.session_state.job_cat }
|
88 |
</div>
|
89 |
"""
|
90 |
|
|
|
108 |
# st.markdown('-----------')
|
109 |
df = create_dfs(annotations)
|
110 |
st.markdown(f"""<h1 style= "text-align: -webkit-center;font-family: sans-serif;">Extracted Skill</h1>""",unsafe_allow_html=True)
|
111 |
+
st.write(", \n".join(df))
|
112 |
|
113 |
|
114 |
|
src/file_uploader.py
CHANGED
@@ -25,17 +25,18 @@ def get_file_type(uploaded_file):
|
|
25 |
return file_type
|
26 |
|
27 |
def extract_text_from_file(uploaded_file):
|
|
|
28 |
file_type = get_file_type(uploaded_file)
|
29 |
# st.write("File type: ", file_type)
|
30 |
|
31 |
if file_type == 'pdf':
|
32 |
-
return pdf2text(io.BytesIO(uploaded_file.read()))
|
33 |
|
34 |
elif file_type == 'vnd.openxmlformats-officedocument.wordprocessingml.document':
|
35 |
-
return doc2text(io.BytesIO(uploaded_file.read()))
|
36 |
else:
|
37 |
-
st.
|
38 |
-
return ""
|
39 |
|
40 |
def main():
|
41 |
uploaded_file = st.file_uploader("Choose a file", type=['pdf', 'docx', 'doc'])
|
|
|
25 |
return file_type
|
26 |
|
27 |
def extract_text_from_file(uploaded_file):
|
28 |
+
rerun_state = False
|
29 |
file_type = get_file_type(uploaded_file)
|
30 |
# st.write("File type: ", file_type)
|
31 |
|
32 |
if file_type == 'pdf':
|
33 |
+
return pdf2text(io.BytesIO(uploaded_file.read())), True
|
34 |
|
35 |
elif file_type == 'vnd.openxmlformats-officedocument.wordprocessingml.document':
|
36 |
+
return doc2text(io.BytesIO(uploaded_file.read())),True
|
37 |
else:
|
38 |
+
st.info("Only PDF and DOCX files are supported.", icon="ℹ️")
|
39 |
+
return "",False
|
40 |
|
41 |
def main():
|
42 |
uploaded_file = st.file_uploader("Choose a file", type=['pdf', 'docx', 'doc'])
|