Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -44,7 +44,7 @@ def filter_relevant_resumes(files):
|
|
44 |
os.makedirs("filtered_resumes", exist_ok=True)
|
45 |
|
46 |
for file in files:
|
47 |
-
file_name = file.name
|
48 |
resume_text, error = extract_resume_text(file)
|
49 |
if error:
|
50 |
predictions[file_name] = {"error": error}
|
@@ -54,8 +54,8 @@ def filter_relevant_resumes(files):
|
|
54 |
result = text_classifier(cleaned_text[:512])
|
55 |
label = result[0]['label']
|
56 |
score = round(result[0]['score'], 4)
|
57 |
-
|
58 |
status = LABEL_MAP.get(label, "Unknown")
|
|
|
59 |
predictions[file_name] = {
|
60 |
"Relevance": status,
|
61 |
"Confidence Score": score
|
@@ -63,13 +63,14 @@ def filter_relevant_resumes(files):
|
|
63 |
|
64 |
if status == "Relevant":
|
65 |
dest_path = f"filtered_resumes/{file_name}"
|
66 |
-
with open(dest_path, "wb") as f_out:
|
67 |
-
|
68 |
relevant_files.append(dest_path)
|
69 |
|
70 |
return predictions, relevant_files
|
71 |
|
72 |
|
|
|
73 |
# Gradio UI
|
74 |
with gr.Blocks(title="Resume Relevance Classifier & Filter") as demo:
|
75 |
gr.Markdown("## π Resume Relevance Filter using Hugging Face Model\nUpload PDF resumes and filter out only the relevant ones.")
|
|
|
44 |
os.makedirs("filtered_resumes", exist_ok=True)
|
45 |
|
46 |
for file in files:
|
47 |
+
file_name = os.path.basename(file.name)
|
48 |
resume_text, error = extract_resume_text(file)
|
49 |
if error:
|
50 |
predictions[file_name] = {"error": error}
|
|
|
54 |
result = text_classifier(cleaned_text[:512])
|
55 |
label = result[0]['label']
|
56 |
score = round(result[0]['score'], 4)
|
|
|
57 |
status = LABEL_MAP.get(label, "Unknown")
|
58 |
+
|
59 |
predictions[file_name] = {
|
60 |
"Relevance": status,
|
61 |
"Confidence Score": score
|
|
|
63 |
|
64 |
if status == "Relevant":
|
65 |
dest_path = f"filtered_resumes/{file_name}"
|
66 |
+
with open(file.name, "rb") as f_in, open(dest_path, "wb") as f_out:
|
67 |
+
shutil.copyfileobj(f_in, f_out)
|
68 |
relevant_files.append(dest_path)
|
69 |
|
70 |
return predictions, relevant_files
|
71 |
|
72 |
|
73 |
+
|
74 |
# Gradio UI
|
75 |
with gr.Blocks(title="Resume Relevance Classifier & Filter") as demo:
|
76 |
gr.Markdown("## π Resume Relevance Filter using Hugging Face Model\nUpload PDF resumes and filter out only the relevant ones.")
|