sanjaybhargavneela1929 commited on
Commit
e79685f
·
verified ·
1 Parent(s): 8f56da4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -13
app.py CHANGED
@@ -1,22 +1,19 @@
1
  from transformers import pipeline
2
  import gradio as gr
3
 
4
- # Load a pre-trained sentiment analysis model for demo purposes
5
- # You can replace this with your fine-tuned model later
6
  classifier = pipeline("text-classification", model="nlptown/bert-base-multilingual-uncased-sentiment")
7
 
8
  def match_profile(resume_text, linkedin_text):
9
- """
10
- Combines resume and LinkedIn text, sends to classifier,
11
- and returns a Suitability Score (0-100).
12
- """
13
- input_text = resume_text + " " + linkedin_text
14
- result = classifier(input_text)
15
- label = result[0]['label']
16
- score = result[0]['score'] * 100
17
- return f"Predicted Label: {label}\nSuitability Score: {score:.2f}"
18
 
19
- # Gradio Interface
20
  interface = gr.Interface(
21
  fn=match_profile,
22
  inputs=[
@@ -28,5 +25,4 @@ interface = gr.Interface(
28
  description="This tool matches an agent’s resume and LinkedIn profile using a BERT model and returns a suitability score."
29
  )
30
 
31
- # Launch the app
32
  interface.launch()
 
1
  from transformers import pipeline
2
  import gradio as gr
3
 
 
 
4
  classifier = pipeline("text-classification", model="nlptown/bert-base-multilingual-uncased-sentiment")
5
 
6
  def match_profile(resume_text, linkedin_text):
7
+ try:
8
+ # Combine input safely and truncate
9
+ input_text = (resume_text + " " + linkedin_text)[:1000] # Trim to 1000 chars
10
+ result = classifier(input_text)
11
+ label = result[0]['label']
12
+ score = result[0]['score'] * 100
13
+ return f"Predicted Label: {label}\nSuitability Score: {score:.2f}"
14
+ except Exception as e:
15
+ return f" Error: {str(e)}"
16
 
 
17
  interface = gr.Interface(
18
  fn=match_profile,
19
  inputs=[
 
25
  description="This tool matches an agent’s resume and LinkedIn profile using a BERT model and returns a suitability score."
26
  )
27
 
 
28
  interface.launch()