danseith commited on
Commit
38bdfc6
·
1 Parent(s): 13f7861

Removed TempScale class for debugging

Browse files
Files changed (1) hide show
  1. app.py +28 -28
app.py CHANGED
@@ -31,34 +31,34 @@ import gradio as gr
31
  from transformers import pipeline, Pipeline
32
 
33
 
34
- unmasker = pipeline("fill-mask", model="anferico/bert-for-patents")
35
-
36
-
37
- def add_mask(text, size=3):
38
- split_text = text.split()
39
- idx = np.random.randint(len(split_text), size=size)
40
- for i in idx:
41
- split_text[i] = '[MASK]'
42
- return ' '.join(split_text)
43
-
44
-
45
- def unmask(text):
46
- text = add_mask(text)
47
- res = unmasker(text)
48
- out = {item["token_str"]: item["score"] for item in res}
49
- return out
50
-
51
-
52
- textbox = gr.Textbox(label="Type language here", lines=5)
53
-
54
- demo = gr.Interface(
55
- fn=unmask,
56
- inputs=textbox,
57
- outputs="label",
58
- examples=[
59
-
60
- ],
61
- )
62
 
63
  demo.launch()
64
  demo = gr.Interface(
 
31
  from transformers import pipeline, Pipeline
32
 
33
 
34
+ # unmasker = pipeline("fill-mask", model="anferico/bert-for-patents")
35
+ #
36
+ #
37
+ # def add_mask(text, size=1):
38
+ # split_text = text.split()
39
+ # idx = np.random.randint(len(split_text), size=size)
40
+ # for i in idx:
41
+ # split_text[i] = '[MASK]'
42
+ # return ' '.join(split_text)
43
+ #
44
+ #
45
+ # def unmask(text):
46
+ # text = add_mask(text)
47
+ # res = unmasker(text)
48
+ # out = {item["token_str"]: item["score"] for item in res}
49
+ # return out
50
+ #
51
+ #
52
+ # textbox = gr.Textbox(label="Type language here", lines=5)
53
+ #
54
+ # demo = gr.Interface(
55
+ # fn=unmask,
56
+ # inputs=textbox,
57
+ # outputs="label",
58
+ # examples=[
59
+ #
60
+ # ],
61
+ # )
62
 
63
  demo.launch()
64
  demo = gr.Interface(