Arpan Chatterjee
Modified trained model path
5f20c72
raw
history blame
2.12 kB
import streamlit as st
import pandas as pd
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import torch.nn.functional as F
df = pd.read_pickle("my_dataframe.pkl")
print(df.head(5))
print(df["abstract"][4])
model_dir = 'model-patent-score'
tokenizer = AutoTokenizer.from_pretrained(model_dir)
model = AutoModelForSequenceClassification.from_pretrained(model_dir)
abstract = "The present invention relates to passive optical network (PON), and in particular, to an optical network terminal (ONT) in the PON system. In one embodiment, the optical network terminal includes a first interface coupled to a communications network, a second interface coupled to a network client and a processor including a memory coupled to the first interface and to the second interface, wherein the processor is capable of converting optical signals to electric signals, such that the network client can access the communications network."
#abstract = "A shoe midsole is composed of a base plate (1), a cover (2), a plurality of blades (3), and liquid (4). The blades (3) are formed in such a manner as to rise within a first region (11) of the base plate (1). The blades (3) are each composed of a plurality of flat-shaped blade elements (32, 33) separated each other by slits (31), and are tilted toward the toe side or the heel side. The flat-shaped blade elements (32, 33) are disposed in such a manner as to be divergent toward the toe side or the heel side. The base plate (1) and the cover (2) are joined together, thereby forming a closed space (5), and the liquid (4) is sealed in the closed space."
inputs = tokenizer.encode_plus(abstract, max_length=512, padding='max_length', truncation=True, return_tensors='pt')
# Get the model prediction
outputs = model(inputs['input_ids'], attention_mask=inputs['attention_mask'])
scores = torch.softmax(outputs.logits, dim=1)[0]
probs = F.softmax(scores, dim=0)
# Print the scores
accept_prob = probs[1].item()
print(accept_prob)
print(outputs)
print(scores)
print(probs)
'''
x = st.slider('Select a value')
st.write(x, 'squared is', x * x)
'''