Update app.py
Browse files
app.py
CHANGED
@@ -11,7 +11,7 @@ def Model():
|
|
11 |
return model, tokenizer
|
12 |
|
13 |
def Predict(model, tokenizer, text):
|
14 |
-
res = tokenizer(
|
15 |
res = model(**res)
|
16 |
logits = res.logits.softmax(dim=1)
|
17 |
logits = logits.numpy()[0]#.cpu().detach().numpy()[0]
|
@@ -20,10 +20,10 @@ def Predict(model, tokenizer, text):
|
|
20 |
def Print(logits, dictionary):
|
21 |
z = zip(logits, np.arange(0, 8))
|
22 |
z = sorted(z, key=lambda x: x[0], reverse=True)
|
23 |
-
|
24 |
-
while
|
25 |
st.markdown(f"{idx + 1}. ", dictionary[z[idx][1]])
|
26 |
-
|
27 |
idx += 1
|
28 |
|
29 |
def filter(title, abstract):
|
|
|
11 |
return model, tokenizer
|
12 |
|
13 |
def Predict(model, tokenizer, text):
|
14 |
+
res = tokenizer(text, padding=True, truncation=True, return_tensors="pt", max_length=512)
|
15 |
res = model(**res)
|
16 |
logits = res.logits.softmax(dim=1)
|
17 |
logits = logits.numpy()[0]#.cpu().detach().numpy()[0]
|
|
|
20 |
def Print(logits, dictionary):
|
21 |
z = zip(logits, np.arange(0, 8))
|
22 |
z = sorted(z, key=lambda x: x[0], reverse=True)
|
23 |
+
summ, idx = 0, 0
|
24 |
+
while summ < 0.95:
|
25 |
st.markdown(f"{idx + 1}. ", dictionary[z[idx][1]])
|
26 |
+
summ += z[idx][0]
|
27 |
idx += 1
|
28 |
|
29 |
def filter(title, abstract):
|