thushalya commited on
Commit
39953cb
1 Parent(s): 73dcfcf

Add personality bar graph

Browse files
Files changed (1) hide show
  1. app.py +21 -3
app.py CHANGED
@@ -176,6 +176,7 @@ def personality_detection(text, threshold=0.05, endpoint= 1.0):
176
  # # result = {label_names[i]: f"{predictions[i]*100:.0f}%" for i in range(len(label_names))}
177
  # result = {label_names[i]: f"{probabilities}%" for i in range(len(label_names))}
178
  # probabilities
 
179
  return [probabilities[0][0].detach().numpy()
180
  ,probabilities[0][1].detach().numpy()
181
  ,probabilities[0][2].detach().numpy()
@@ -377,7 +378,14 @@ def greet(tweet):
377
  "Emotions": ["Anger", "Anticipation", "Disgust", "Fear", "Joy", "Love", "Optimism", "Pessimism", "Sadness","Surprise","Trust"],
378
  "Values": preemotion_list,
379
  }
380
- )
 
 
 
 
 
 
 
381
  # with gr.Blocks() as bar_plot:
382
  # bar_plot.load(outputs= gr.BarPlot(
383
  # simple,
@@ -405,7 +413,7 @@ def greet(tweet):
405
  label = "Hate"
406
 
407
 
408
- return label,str(prediction_value)+"%",str(1-prediction_value)+"%",simple
409
 
410
  # demo = gr.Interface(fn=greet, inputs="text", outputs="text")
411
  demo = gr.Interface(
@@ -422,7 +430,17 @@ demo = gr.Interface(
422
  y="Values",
423
  title="Emotion Analysis",
424
  tooltip=["Emotions", "Values"],
425
- y_lim=[0, 40],
 
 
 
 
 
 
 
 
 
 
426
  )
427
  ],
428
  examples=[
 
176
  # # result = {label_names[i]: f"{predictions[i]*100:.0f}%" for i in range(len(label_names))}
177
  # result = {label_names[i]: f"{probabilities}%" for i in range(len(label_names))}
178
  # probabilities
179
+ print(probabilities)
180
  return [probabilities[0][0].detach().numpy()
181
  ,probabilities[0][1].detach().numpy()
182
  ,probabilities[0][2].detach().numpy()
 
378
  "Emotions": ["Anger", "Anticipation", "Disgust", "Fear", "Joy", "Love", "Optimism", "Pessimism", "Sadness","Surprise","Trust"],
379
  "Values": preemotion_list,
380
  }
381
+ )
382
+ personality_values = pd.DataFrame(
383
+ {
384
+ "Personality": ['Agreeableness', 'Conscientiousness', 'Extraversion', 'Neuroticism', 'Openness'],
385
+ "Values": personality_list,
386
+ }
387
+ )
388
+
389
  # with gr.Blocks() as bar_plot:
390
  # bar_plot.load(outputs= gr.BarPlot(
391
  # simple,
 
413
  label = "Hate"
414
 
415
 
416
+ return label,str(prediction_value)+"%",str(1-prediction_value)+"%",simple,personality_values
417
 
418
  # demo = gr.Interface(fn=greet, inputs="text", outputs="text")
419
  demo = gr.Interface(
 
430
  y="Values",
431
  title="Emotion Analysis",
432
  tooltip=["Emotions", "Values"],
433
+ y_lim=[0, 1],
434
+ label="Emotion bar graph"
435
+ ),
436
+ gr.BarPlot(
437
+ personality_values,
438
+ x="Personality",
439
+ y="Values",
440
+ title="Personality Analysis",
441
+ tooltip=["Personality", "Values"],
442
+ y_lim=[0, 1],
443
+ label="Personality bar graph"
444
  )
445
  ],
446
  examples=[