Arpan Chatterjee commited on
Commit
58e2c18
1 Parent(s): b3a95a4

updated requirements and app

Browse files
Files changed (2) hide show
  1. app.py +12 -15
  2. requirements.txt +0 -154
app.py CHANGED
@@ -5,31 +5,27 @@ import torch
5
  import torch.nn.functional as F
6
 
7
  @st.cache
8
- def predictScore():
9
  model_dir = 'model-patent-score'
10
  tokenizer = AutoTokenizer.from_pretrained(model_dir)
11
  model = AutoModelForSequenceClassification.from_pretrained(model_dir)
12
 
13
- 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."
14
- #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."
15
  inputs = tokenizer.encode_plus(abstract, max_length=512, padding='max_length', truncation=True, return_tensors='pt')
16
 
17
- # Get the model prediction
18
  outputs = model(inputs['input_ids'], attention_mask=inputs['attention_mask'])
19
  scores = torch.softmax(outputs.logits, dim=1)[0]
20
 
21
-
22
  probs = F.softmax(scores, dim=0)
23
- # Print the scores
24
- accept_prob = probs[1].item()
25
  print(accept_prob)
26
 
 
 
27
 
28
 
29
  def main():
30
  df = pd.read_pickle("my_dataframe.pkl")
31
- abstract_list = df['abstract'].tolist()
32
- claims_list = df['claims'].tolist()
33
  title_list = df['title'].tolist()
34
  pnumber_list = df['patent_number'].tolist()
35
 
@@ -45,15 +41,16 @@ def main():
45
  print(pnumber)
46
  pclaims = df.loc[df['patent_number'] == str(pnumber), 'claims'].iloc[0]
47
  pabstract = df.loc[df['patent_number'] == str(pnumber), 'abstract'].iloc[0]
48
- print(pclaims)
49
- print(pabstract)
50
  st.write(pclaims)
51
  st.write(pabstract)
52
- '''
53
- x = st.slider('Select a value')
54
- st.write(x, 'squared is', x * x)
55
 
56
- '''
 
 
 
 
 
57
 
58
  if __name__ == '__main__':
59
  main()
 
5
  import torch.nn.functional as F
6
 
7
  @st.cache
8
+ def predictScore(abstract):
9
  model_dir = 'model-patent-score'
10
  tokenizer = AutoTokenizer.from_pretrained(model_dir)
11
  model = AutoModelForSequenceClassification.from_pretrained(model_dir)
12
 
13
+ #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."
 
14
  inputs = tokenizer.encode_plus(abstract, max_length=512, padding='max_length', truncation=True, return_tensors='pt')
15
 
 
16
  outputs = model(inputs['input_ids'], attention_mask=inputs['attention_mask'])
17
  scores = torch.softmax(outputs.logits, dim=1)[0]
18
 
 
19
  probs = F.softmax(scores, dim=0)
20
+ accept_prob = probs[0].item()
 
21
  print(accept_prob)
22
 
23
+ return accept_prob
24
+
25
 
26
 
27
  def main():
28
  df = pd.read_pickle("my_dataframe.pkl")
 
 
29
  title_list = df['title'].tolist()
30
  pnumber_list = df['patent_number'].tolist()
31
 
 
41
  print(pnumber)
42
  pclaims = df.loc[df['patent_number'] == str(pnumber), 'claims'].iloc[0]
43
  pabstract = df.loc[df['patent_number'] == str(pnumber), 'abstract'].iloc[0]
44
+ score = predictScore(pabstract)
 
45
  st.write(pclaims)
46
  st.write(pabstract)
 
 
 
47
 
48
+ with st.form("my_form"):
49
+ submit_button = st.form_submit_button(label='Submit')
50
+
51
+ if submit_button:
52
+ st.write("The patentability score of this patent: ", score)
53
+
54
 
55
  if __name__ == '__main__':
56
  main()
requirements.txt CHANGED
@@ -1,158 +1,21 @@
1
- absl-py==1.4.0
2
- aiohttp==3.8.4
3
- aiosignal==1.3.1
4
- altair==4.2.0
5
- anyio==3.6.2
6
- argon2-cffi==21.3.0
7
- argon2-cffi-bindings==21.2.0
8
- arrow==1.2.3
9
- asgiref==3.6.0
10
- asttokens==2.2.1
11
- astunparse==1.6.3
12
- async-timeout==4.0.2
13
- attrs==22.1.0
14
- backcall==0.2.0
15
- beautifulsoup4==4.11.2
16
- bleach==6.0.0
17
- blinker==1.5
18
- cachetools==5.2.0
19
- certifi==2022.12.7
20
- cffi==1.15.1
21
- charset-normalizer==2.1.1
22
- click==8.1.3
23
- colorama==0.4.6
24
- comm==0.1.2
25
- commonmark==0.9.1
26
- contourpy==1.0.6
27
- cycler==0.11.0
28
  datasets==2.11.0
29
- debugpy==1.6.6
30
- decorator==5.1.1
31
- defusedxml==0.7.1
32
- dill==0.3.6
33
- distlib==0.3.6
34
- Django==4.1.7
35
- entrypoints==0.4
36
- executing==1.2.0
37
- fastjsonschema==2.16.2
38
- filelock==3.10.0
39
- findspark==2.0.1
40
- flatbuffers==23.3.3
41
- fonttools==4.38.0
42
- fqdn==1.5.1
43
- frozenlist==1.3.3
44
- fsspec==2023.4.0
45
- gast==0.4.0
46
- gitdb==4.0.10
47
- GitPython==3.1.29
48
  google-auth==2.17.2
49
  google-auth-oauthlib==1.0.0
50
  google-pasta==0.2.0
51
- grpcio==1.53.0
52
- gunicorn==20.1.0
53
- h5py==3.8.0
54
- huggingface-hub==0.13.4
55
- idna==3.4
56
- importlib-metadata==5.1.0
57
- ipykernel==6.21.1
58
- ipython==8.9.0
59
- ipython-genutils==0.2.0
60
- isoduration==20.11.0
61
  jax==0.4.8
62
  jedi==0.18.2
63
  Jinja2==3.1.2
64
- joblib==1.2.0
65
- jsonpointer==2.3
66
- jsonschema==4.17.3
67
- jupyter-events==0.6.3
68
- jupyter_client==8.0.2
69
- jupyter_core==5.2.0
70
- jupyter_server==2.2.1
71
- jupyter_server_terminals==0.4.4
72
- jupyterlab-pygments==0.2.2
73
- keras==2.12.0
74
- kiwisolver==1.4.4
75
- libclang==16.0.0
76
- Markdown==3.4.3
77
- MarkupSafe==2.1.1
78
- matplotlib==3.6.2
79
- matplotlib-inline==0.1.6
80
- mistune==2.0.4
81
  ml-dtypes==0.0.4
82
- mpmath==1.3.0
83
- multidict==6.0.4
84
- multiprocess==0.70.14
85
- nbclassic==0.5.1
86
- nbclient==0.7.2
87
- nbconvert==7.2.9
88
- nbformat==5.7.3
89
- nest-asyncio==1.5.6
90
- networkx==3.1
91
- notebook==6.5.2
92
- notebook_shim==0.2.2
93
- numpy==1.23.5
94
- oauthlib==3.2.2
95
- opencv-python==4.7.0.68
96
- opt-einsum==3.3.0
97
- packaging==21.3
98
  pandas==1.5.2
99
  pandocfilters==1.5.0
100
  parso==0.8.3
101
  pickleshare==0.7.5
102
  Pillow==9.3.0
103
- platformdirs==2.6.2
104
- prometheus-client==0.16.0
105
- prompt-toolkit==3.0.36
106
- protobuf==3.20.3
107
- psutil==5.9.4
108
- pure-eval==0.2.2
109
- py4j==0.10.9.5
110
- pyarrow==10.0.1
111
- pyasn1==0.4.8
112
- pyasn1-modules==0.2.8
113
- pycparser==2.21
114
- pydeck==0.8.0
115
- Pygments==2.13.0
116
- Pympler==1.0.1
117
- pyparsing==3.0.9
118
- pyrsistent==0.19.2
119
- pyspark==3.3.2
120
- python-dateutil==2.8.2
121
- python-json-logger==2.0.4
122
  python-version==0.0.2
123
- pytz==2022.6
124
- pytz-deprecation-shim==0.1.0.post0
125
- PyYAML==6.0
126
- pyzmq==25.0.0
127
- redis==4.4.0
128
- regex==2023.3.23
129
- requests==2.28.1
130
- requests-oauthlib==1.3.1
131
- responses==0.18.0
132
- rfc3339-validator==0.1.4
133
- rfc3986-validator==0.1.1
134
- rich==12.6.0
135
- rsa==4.9
136
  scikit-learn==1.2.2
137
  scipy==1.10.1
138
- semver==2.13.0
139
- Send2Trash==1.8.0
140
- six==1.16.0
141
- smmap==5.0.0
142
- sniffio==1.3.0
143
- soupsieve==2.3.2.post1
144
- spotipy==2.22.0
145
- sqlparse==0.4.3
146
- stack-data==0.6.2
147
  streamlit==1.16.0
148
  sympy==1.11.1
149
- termcolor==2.2.0
150
- terminado==0.17.1
151
- threadpoolctl==3.1.0
152
- tinycss2==1.2.1
153
- tokenizers==0.13.3
154
- toml==0.10.2
155
- toolz==0.12.0
156
  torch==2.0.0
157
  torchaudio==2.0.1
158
  torchvision==0.15.1
@@ -160,21 +23,4 @@ tornado==6.2
160
  tqdm==4.65.0
161
  traitlets==5.9.0
162
  transformers==4.27.4
163
- typing_extensions==4.4.0
164
- tzdata==2022.7
165
- tzlocal==4.2
166
- uri-template==1.2.0
167
- urllib3==1.26.13
168
- validators==0.20.0
169
- virtualenv==20.21.0
170
- watchdog==2.2.0
171
- wcwidth==0.2.6
172
- webcolors==1.12
173
- webencodings==0.5.1
174
- websocket-client==1.5.0
175
- Werkzeug==2.2.3
176
- wget==3.2
177
- wrapt==1.14.1
178
- xxhash==3.2.0
179
- yarl==1.9.1
180
  zipp==3.11.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  datasets==2.11.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  google-auth==2.17.2
3
  google-auth-oauthlib==1.0.0
4
  google-pasta==0.2.0
 
 
 
 
 
 
 
 
 
 
5
  jax==0.4.8
6
  jedi==0.18.2
7
  Jinja2==3.1.2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  ml-dtypes==0.0.4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  pandas==1.5.2
10
  pandocfilters==1.5.0
11
  parso==0.8.3
12
  pickleshare==0.7.5
13
  Pillow==9.3.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  python-version==0.0.2
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  scikit-learn==1.2.2
16
  scipy==1.10.1
 
 
 
 
 
 
 
 
 
17
  streamlit==1.16.0
18
  sympy==1.11.1
 
 
 
 
 
 
 
19
  torch==2.0.0
20
  torchaudio==2.0.1
21
  torchvision==0.15.1
 
23
  tqdm==4.65.0
24
  traitlets==5.9.0
25
  transformers==4.27.4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  zipp==3.11.0