Udhaya28 commited on
Commit
4e252f2
·
verified ·
1 Parent(s): c393813

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -54,12 +54,12 @@ def analyze_personality_file(file) -> dict:
54
  # Get full list of scores for each label
55
  all_preds = personality_pipe(cv_text)[0] # pipeline returns list per input
56
 
57
- # Map to human-friendly trait names and percentages
58
  trait_scores = {}
59
  for item in all_preds:
60
  trait = LABEL_TO_TRAIT.get(item['label'], item['label'])
61
- # convert to percentage
62
- trait_scores[trait] = round(item['score'] * 100, 1)
63
  return trait_scores
64
 
65
  with gr.Blocks() as demo:
@@ -74,6 +74,7 @@ if __name__ == "__main__":
74
  demo.launch()
75
 
76
  # requirements.txt
 
77
  gradio
78
  transformers
79
  torch
 
54
  # Get full list of scores for each label
55
  all_preds = personality_pipe(cv_text)[0] # pipeline returns list per input
56
 
57
+ # Map to human-friendly trait names (values between 0 and 1)
58
  trait_scores = {}
59
  for item in all_preds:
60
  trait = LABEL_TO_TRAIT.get(item['label'], item['label'])
61
+ # keep probability in [0,1] for correct Gradio percentage display
62
+ trait_scores[trait] = round(item['score'], 3)
63
  return trait_scores
64
 
65
  with gr.Blocks() as demo:
 
74
  demo.launch()
75
 
76
  # requirements.txt
77
+
78
  gradio
79
  transformers
80
  torch