arittrabag commited on
Commit
5fbf6db
·
verified ·
1 Parent(s): d2dca70

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer
4
+
5
+ # Load fine-tuned model & tokenizer
6
+ model_path = "bert_resume_classifier" # Change if saved elsewhere
7
+ tokenizer = AutoTokenizer.from_pretrained(model_path)
8
+ model = AutoModelForSequenceClassification.from_pretrained(model_path)
9
+
10
+ # Label mapping
11
+ label_map = {
12
+ 0: "Advocate", 1: "Arts", 2: "Automation Testing", 3: "Blockchain",
13
+ 4: "Business Analyst", 5: "Civil Engineer", 6: "Data Science", 7: "Database",
14
+ 8: "DevOps Engineer", 9: "DotNet Developer", 10: "ETL Developer",
15
+ 11: "Electrical Engineering", 12: "HR", 13: "Hadoop", 14: "Health and fitness",
16
+ 15: "Java Developer", 16: "Mechanical Engineer", 17: "Network Security Engineer",
17
+ 18: "Operations Manager", 19: "PMO", 20: "Python Developer",
18
+ 21: "SAP Developer", 22: "Sales", 23: "Testing", 24: "Web Designing"
19
+ }
20
+
21
+ # Prediction Function
22
+ def predict_resume_category(resume_text):
23
+ inputs = tokenizer(resume_text, truncation=True, padding=True, max_length=512, return_tensors="pt")
24
+ with torch.no_grad():
25
+ outputs = model(**inputs)
26
+ logits = outputs.logits
27
+ predicted_class = torch.argmax(logits, dim=1).item()
28
+ return f"Predicted Job Category: {label_map[predicted_class]}"
29
+
30
+ # Gradio Interface
31
+ iface = gr.Interface(
32
+ fn=predict_resume_category,
33
+ inputs=gr.Textbox(lines=10, placeholder="Paste resume text here..."),
34
+ outputs="text",
35
+ title="Resume Job Category Predictor",
36
+ description="Enter resume text to classify the job category using BERT.",
37
+ )
38
+
39
+ # Launch
40
+ iface.launch(share=True) # Use share=True to get a public Gradio link