Spaces:
Runtime error
Runtime error
add app.py
Browse files- .gitignore +3 -0
- app.py +35 -0
- requirements.txt +3 -0
.gitignore
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
.venv
|
2 |
+
.vscode
|
3 |
+
flagged
|
app.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
unmasker = pipeline("fill-mask", model="anferico/bert-for-patents")
|
5 |
+
|
6 |
+
|
7 |
+
def unmask(text):
|
8 |
+
res = unmasker(text)
|
9 |
+
out = {item["token_str"]: item["score"] for item in res}
|
10 |
+
return out
|
11 |
+
|
12 |
+
|
13 |
+
textbox = gr.Textbox(label="Type patent abstract here", lines=5)
|
14 |
+
|
15 |
+
demo = gr.Interface(
|
16 |
+
fn=unmask,
|
17 |
+
inputs=textbox,
|
18 |
+
outputs="label",
|
19 |
+
examples=[
|
20 |
+
[
|
21 |
+
"The present [MASK] provides a torque sensor that is small and highly rigid and for which high production efficiency is possible."
|
22 |
+
],
|
23 |
+
[
|
24 |
+
"The present invention relates to [MASK] accessories and pertains particularly to a brake light unit for bicycles."
|
25 |
+
],
|
26 |
+
[
|
27 |
+
"The present invention discloses a space-bound-free [MASK] and its coordinate determining circuit for determining a coordinate of a stylus pen."
|
28 |
+
],
|
29 |
+
[
|
30 |
+
"The illuminated [MASK] includes a substantially translucent canopy supported by a plurality of ribs pivotally swingable towards and away from a shaft."
|
31 |
+
],
|
32 |
+
],
|
33 |
+
)
|
34 |
+
|
35 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
torch
|
3 |
+
transformers
|