Update app.py
Browse files
app.py
CHANGED
@@ -5,9 +5,14 @@ from transformers import pipeline
|
|
5 |
import pandas as pd
|
6 |
from huggingface_hub import login
|
7 |
|
8 |
-
#
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
# Load the model for Named Entity Recognition (NER)
|
13 |
# You can replace 'dbmdz/bert-large-cased-finetuned-conll03-english' with any other model if needed
|
@@ -68,10 +73,33 @@ def batch_process_resumes(pdf_files):
|
|
68 |
# Gradio interface
|
69 |
with gr.Blocks() as demo:
|
70 |
gr.Markdown("### AI Resume Parser")
|
|
|
|
|
|
|
|
|
|
|
71 |
file_input = gr.File(file_count="multiple", label="Upload Resumes (PDFs)")
|
|
|
|
|
72 |
output = gr.Textbox(label="Result")
|
|
|
|
|
73 |
process_button = gr.Button("Process Resumes")
|
74 |
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
|
|
|
77 |
demo.launch()
|
|
|
5 |
import pandas as pd
|
6 |
from huggingface_hub import login
|
7 |
|
8 |
+
# Function to login using Hugging Face API token
|
9 |
+
def login_with_token(hf_token):
|
10 |
+
"""Login to Hugging Face using provided token"""
|
11 |
+
try:
|
12 |
+
login(token=hf_token)
|
13 |
+
return "Logged in successfully!"
|
14 |
+
except Exception as e:
|
15 |
+
return f"Error: {str(e)}"
|
16 |
|
17 |
# Load the model for Named Entity Recognition (NER)
|
18 |
# You can replace 'dbmdz/bert-large-cased-finetuned-conll03-english' with any other model if needed
|
|
|
73 |
# Gradio interface
|
74 |
with gr.Blocks() as demo:
|
75 |
gr.Markdown("### AI Resume Parser")
|
76 |
+
|
77 |
+
# User input for Hugging Face token
|
78 |
+
hf_token_input = gr.Textbox(label="Hugging Face Token", placeholder="Enter your Hugging Face API Token here")
|
79 |
+
|
80 |
+
# File input for resume files
|
81 |
file_input = gr.File(file_count="multiple", label="Upload Resumes (PDFs)")
|
82 |
+
|
83 |
+
# Output for results
|
84 |
output = gr.Textbox(label="Result")
|
85 |
+
|
86 |
+
# Process button that triggers the login and resume parsing
|
87 |
process_button = gr.Button("Process Resumes")
|
88 |
|
89 |
+
# Function call when button is clicked
|
90 |
+
def process_resumes(hf_token, pdf_files):
|
91 |
+
# Attempt to log in with provided token
|
92 |
+
login_message = login_with_token(hf_token)
|
93 |
+
|
94 |
+
# If login is successful, process resumes
|
95 |
+
if "Error" not in login_message:
|
96 |
+
result_message = batch_process_resumes(pdf_files)
|
97 |
+
return login_message + "\n" + result_message
|
98 |
+
else:
|
99 |
+
return login_message
|
100 |
+
|
101 |
+
# Set up the button click event
|
102 |
+
process_button.click(process_resumes, inputs=[hf_token_input, file_input], outputs=output)
|
103 |
|
104 |
+
# Launch the Gradio interface
|
105 |
demo.launch()
|