Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import traceback
|
| 4 |
+
from model import screen_resumes_backend
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def process(job_description, files, model_option, threshold):
|
| 8 |
+
try:
|
| 9 |
+
if not files:
|
| 10 |
+
return "❌ Upload CV files first", None, None
|
| 11 |
+
|
| 12 |
+
if not job_description or len(job_description.strip()) < 20:
|
| 13 |
+
return "❌ Job description too short", None, None
|
| 14 |
+
|
| 15 |
+
results, summary, _, zip_path = screen_resumes_backend(
|
| 16 |
+
job_description,
|
| 17 |
+
files,
|
| 18 |
+
model_option,
|
| 19 |
+
threshold
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
df = pd.DataFrame(results) if results else None
|
| 23 |
+
|
| 24 |
+
return summary, df, zip_path
|
| 25 |
+
|
| 26 |
+
except Exception as e:
|
| 27 |
+
return f"❌ Error: {str(e)}\n{traceback.format_exc()}", None, None
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
# ================= UI =================
|
| 31 |
+
with gr.Blocks(title="AI Resume Screener") as demo:
|
| 32 |
+
|
| 33 |
+
gr.HTML("""
|
| 34 |
+
<h1 style="text-align:center; color:#2563eb;">
|
| 35 |
+
🧠 AI Resume Screening System
|
| 36 |
+
</h1>
|
| 37 |
+
""")
|
| 38 |
+
|
| 39 |
+
job_desc = gr.Textbox(
|
| 40 |
+
label="Job Description",
|
| 41 |
+
lines=8,
|
| 42 |
+
placeholder="Enter job requirements..."
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
model_choice = gr.Dropdown(
|
| 46 |
+
["Fast (MiniLM)", "Balanced (Recommended)", "High Accuracy"],
|
| 47 |
+
value="Balanced (Recommended)",
|
| 48 |
+
label="Model"
|
| 49 |
+
)
|
| 50 |
+
|
| 51 |
+
threshold = gr.Slider(0.4, 0.9, value=0.6, step=0.05, label="Threshold")
|
| 52 |
+
|
| 53 |
+
file_input = gr.File(
|
| 54 |
+
label="Upload CVs (PDF/DOCX)",
|
| 55 |
+
file_count="multiple"
|
| 56 |
+
)
|
| 57 |
+
|
| 58 |
+
btn = gr.Button("Process")
|
| 59 |
+
|
| 60 |
+
output_text = gr.Markdown()
|
| 61 |
+
output_table = gr.DataFrame()
|
| 62 |
+
download_file = gr.File()
|
| 63 |
+
|
| 64 |
+
btn.click(
|
| 65 |
+
process,
|
| 66 |
+
inputs=[job_desc, file_input, model_choice, threshold],
|
| 67 |
+
outputs=[output_text, output_table, download_file]
|
| 68 |
+
)
|
| 69 |
+
|
| 70 |
+
if __name__ == "__main__":
|
| 71 |
+
demo.launch()
|