Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,18 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
import pdfplumber
|
3 |
import re
|
4 |
import openpyxl
|
5 |
-
|
|
|
6 |
|
7 |
-
#
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
11 |
|
12 |
# Function to extract text from PDF
|
13 |
def extract_text_from_pdf(pdf_path):
|
@@ -82,16 +87,27 @@ def process_pdfs(pdfs):
|
|
82 |
|
83 |
return output_file
|
84 |
|
85 |
-
# Gradio interface setup with
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
-
# Launch the
|
97 |
-
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
3 |
import pdfplumber
|
4 |
import re
|
5 |
import openpyxl
|
6 |
+
import os
|
7 |
+
from huggingface_hub import login
|
8 |
|
9 |
+
# Function to authenticate Hugging Face using token
|
10 |
+
def authenticate_hf(token):
|
11 |
+
try:
|
12 |
+
login(token)
|
13 |
+
return "Authentication Successful"
|
14 |
+
except Exception as e:
|
15 |
+
return f"Error: {e}"
|
16 |
|
17 |
# Function to extract text from PDF
|
18 |
def extract_text_from_pdf(pdf_path):
|
|
|
87 |
|
88 |
return output_file
|
89 |
|
90 |
+
# Gradio interface setup with Hugging Face API token input
|
91 |
+
with gr.Blocks() as app:
|
92 |
+
gr.Markdown("### Hugging Face Authentication")
|
93 |
+
|
94 |
+
# Input field for Hugging Face API token
|
95 |
+
hf_token = gr.Textbox(label="Hugging Face API Token", placeholder="Enter your Hugging Face token here", type="password")
|
96 |
+
login_button = gr.Button("Authenticate")
|
97 |
+
auth_status = gr.Textbox(label="Authentication Status", interactive=False)
|
98 |
+
|
99 |
+
# Authenticate Hugging Face model when button is clicked
|
100 |
+
login_button.click(authenticate_hf, inputs=hf_token, outputs=auth_status)
|
101 |
+
|
102 |
+
gr.Markdown("### Upload PDF Resumes")
|
103 |
+
|
104 |
+
# File input to upload resumes
|
105 |
+
pdfs_input = gr.File(file_count="multiple", type="file")
|
106 |
+
output_file = gr.File()
|
107 |
+
|
108 |
+
# Process the PDFs and parse them
|
109 |
+
process_button = gr.Button("Process Resumes")
|
110 |
+
process_button.click(process_pdfs, inputs=pdfs_input, outputs=output_file)
|
111 |
|
112 |
+
# Launch the app
|
113 |
+
app.launch()
|