YAMITEK commited on
Commit
7e78576
Β·
verified Β·
1 Parent(s): 011b587

Upload 5 files

Browse files
app.py ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import joblib
3
+ import pandas as pd
4
+ from sentence_transformers import SentenceTransformer
5
+ from sklearn.metrics.pairwise import cosine_similarity
6
+
7
+ # Load the necessary models
8
+ model = joblib.load("resume_classification_model.pkl")
9
+ tokenizer = joblib.load("resume_label_encoder.pkl")
10
+ sbert_model = SentenceTransformer('all-MiniLM-L6-v2')
11
+
12
+ # Set up the Streamlit page configuration
13
+ st.set_page_config(page_title="Multi Resume Analyzer", layout="centered")
14
+ st.markdown("<h1 style='text-align: center; color: #4CAF50;'>πŸ“ Multi Resume Analyzer</h1>", unsafe_allow_html=True)
15
+
16
+ # Input job description
17
+ jd = st.text_input("Enter the Job Description:")
18
+
19
+ # Initialize session state
20
+ if "text_blocks" not in st.session_state:
21
+ st.session_state.text_blocks = []
22
+ if "submitted" not in st.session_state:
23
+ st.session_state.submitted = False
24
+ if "message" not in st.session_state:
25
+ st.session_state.message = ""
26
+ if "text_input_key" not in st.session_state:
27
+ st.session_state.text_input_key = 0
28
+
29
+ # Show textarea and buttons if not submitted
30
+ if not st.session_state.submitted:
31
+ st.markdown("### ✍️ Enter or Paste Your Resume Below:")
32
+ text_input = st.text_area("Text Input", height=200, key=f"input_{st.session_state.text_input_key}")
33
+
34
+ col1, col2 = st.columns(2)
35
+ with col1:
36
+ if st.button("Next"):
37
+ if text_input.strip():
38
+ st.session_state.text_blocks.append(text_input.strip())
39
+ st.session_state.message = f"βœ… Resume block {len(st.session_state.text_blocks)} saved!"
40
+ st.session_state.text_input_key += 1
41
+ st.rerun()
42
+ else:
43
+ st.warning("Please enter some text before clicking Next.")
44
+ with col2:
45
+ if st.button("Submit"):
46
+ if text_input.strip():
47
+ st.session_state.text_blocks.append(text_input.strip())
48
+ st.session_state.submitted = True
49
+ st.rerun()
50
+
51
+ # Show feedback message after "Next"
52
+ if st.session_state.message:
53
+ st.success(st.session_state.message)
54
+
55
+ # After submission
56
+ if st.session_state.submitted and jd:
57
+ st.markdown("## βœ… Submission Complete!")
58
+
59
+ resumes = st.session_state.text_blocks
60
+
61
+ # SBERT embeddings
62
+ embeddings = sbert_model.encode(resumes) # one vector per resume
63
+ jd_embedding = sbert_model.encode([jd]) # job description embedding
64
+
65
+ # Cosine similarities
66
+ similarities = cosine_similarity(jd_embedding, embeddings)[0]
67
+
68
+ # Predict categories for all resumes
69
+ predicted_labels = model.predict(embeddings)
70
+ predicted_categories = tokenizer.inverse_transform(predicted_labels)
71
+
72
+ # Create DataFrame
73
+ df = pd.DataFrame({
74
+ "Resume": [f"Resume {i+1}" for i in range(len(resumes))],
75
+ "Index": list(range(len(resumes))),
76
+ "Score": similarities,
77
+ "Predicted Category": predicted_categories
78
+ })
79
+
80
+ # Ranking
81
+ df["Rank"] = df["Score"].rank(ascending=False, method='first').astype(int)
82
+ df = df.sort_values(by="Rank")
83
+
84
+ # Predicted category of top resume
85
+ top_resume_embedding = embeddings[df.iloc[0]["Index"]].reshape(1, -1)
86
+ top_pred = model.predict(top_resume_embedding)
87
+ top_category = tokenizer.inverse_transform(top_pred)[0]
88
+ st.success(f"🎯 Predicted Job Category for Best Match: **{top_category}**")
89
+
90
+ # Display full results table
91
+ st.markdown("### πŸ“Š Resume Analysis Results:")
92
+ st.dataframe(df[['Resume', 'Index', 'Score', 'Rank', 'Predicted Category']], width=700)
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ streamlit==1.32.2
2
+ pandas==2.2.1
3
+ numpy==1.26.4
4
+ scikit-learn==1.4.1.post1
5
+ joblib==1.4.0
6
+ sentence-transformers==2.6.1
7
+ transformers==4.39.3
8
+ torch==2.2.2
resume_classification_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d501ff491efb2c4cedb91c52b232a4702e43023fcc4857648f2e0b1918f549ad
3
+ size 77906
resume_label_encoder.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a575dafd246993e6ee551491e5b96de44c566db677a33abf48b159cbfbfbd738
3
+ size 633
tfidf_vectorizer.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aaacc258a637621638a5b72460cc2706498e231bfb55a16f03a02743f5414690
3
+ size 146607