File size: 1,273 Bytes
b23dced
1b6a720
 
9615c66
1b6a720
cefbbca
9a8b099
 
 
b23dced
3a15f10
b23dced
 
9de6f34
 
7b8d7d3
9de6f34
 
 
b23dced
 
 
 
2973318
0dc667c
 
 
 
b23dced
0dc667c
 
 
 
1047b7a
de5a93f
0dc667c
876676b
2125690
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import streamlit as st
import torch
import torch.nn.functional as F
import transformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
from datasets import load_dataset
import numpy as np
import pandas as pd


st.title('Can I Patent This?')

# steamlit form
option = st.selectbox(
    'How would you like to be contacted?',
    ('p1', 'p2', 'p3'))

st.write(option)

form = st.form(key='sentiment-form')
user_input = form.text_area(label = 'Enter your text', value = "I love steamlit and hugging face!")
submit = form.form_submit_button('Submit')

model_name = "ayethuzar/tuned-for-patentability"
model = AutoModelForSequenceClassification.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)

test = [user_input]

if submit:
    batch = tokenizer(test, padding = True, truncation = True, max_length = 512, return_tensors = "pt")
    
    with torch.no_grad():
      outputs = model(**batch)
      #st.write(outputs)
      predictions = F.softmax(outputs.logits, dim = 1)
      result = "Patentability Score: " + str(predictions.numpy()[0][1])
      html_str = f"""<style>p.a {{font: bold {28}px Courier;color:#1D5D9B;}}</style><p class="a">{result}</p>"""
      st.markdown(html_str, unsafe_allow_html=True)