TKM03 commited on
Commit
90f398d
Β·
verified Β·
1 Parent(s): 5bda631

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
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.split("/")[-1]
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
- f_out.write(file.data)
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.")