Poe Dator commited on
Commit
1f7ef74
1 Parent(s): 35bd6d3

charting added

Browse files
Files changed (1) hide show
  1. app.py +12 -0
app.py CHANGED
@@ -3,6 +3,7 @@ import torch
3
  from torch import nn
4
  from transformers import BertModel, AutoTokenizer, AutoModel, pipeline
5
  from time import time
 
6
  # device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
7
  device = 'cpu'
8
 
@@ -72,4 +73,15 @@ for lbl, score in res:
72
  if score >=1:
73
  st.markdown(f"[ {lbl:<7}] {labels_decoder[lbl]:<35} {score:.1f}%")
74
 
 
 
 
 
 
 
 
 
 
 
 
75
  st.markdown(f"cycle time = {time() - start_time:.2f} s.")
 
3
  from torch import nn
4
  from transformers import BertModel, AutoTokenizer, AutoModel, pipeline
5
  from time import time
6
+ import matplotlib.pyplot as plt
7
  # device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
8
  device = 'cpu'
9
 
 
73
  if score >=1:
74
  st.markdown(f"[ {lbl:<7}] {labels_decoder[lbl]:<35} {score:.1f}%")
75
 
76
+
77
+ fig, ax = plt.subplots()
78
+ total=0
79
+ for r in res:
80
+ if total < 95:
81
+ ax.barh(r[0], r[1])
82
+ total += r[1]
83
+ else:
84
+ break
85
+ st.pyplot()
86
+
87
  st.markdown(f"cycle time = {time() - start_time:.2f} s.")