John6666 commited on
Commit
f0c27c2
1 Parent(s): 6611a8b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -35
app.py CHANGED
@@ -1,35 +1,35 @@
1
- import os
2
- if os.environ.get("SPACES_ZERO_GPU") is not None:
3
- import spaces
4
- else:
5
- class spaces:
6
- @staticmethod
7
- def GPU(func):
8
- def wrapper(*args, **kwargs):
9
- return func(*args, **kwargs)
10
- return wrapper
11
- import gradio as gr
12
- import subprocess
13
-
14
-
15
- from transformers import pipeline
16
- MODEL = "winterForestStump/Roberta-fake-news-detector"
17
- clf = pipeline("text-classification", model=MODEL, tokenizer=MODEL)
18
-
19
- text = "From the very beginning, the EU has been extremely non-transparent. The deployment of the European Union presence in Armenia was carried out forcefully, under serious pressure from Brussels"
20
-
21
-
22
- @spaces.GPU
23
- def infer(text: str):
24
- result = clf(text)
25
- return result
26
-
27
-
28
- with gr.Blocks() as demo:
29
- input_text= gr.Textbox(label="Input", value=text, show_copy_button=True)
30
- run_button = gr.Button("Run", variant="primary")
31
- output_text = gr.Textbox(label="Output", value="", show_copy_button=True)
32
-
33
- run_button.click(infer, [input_text], [output_text])
34
-
35
- demo.launch()
 
1
+ import os
2
+ if os.environ.get("SPACES_ZERO_GPU") is not None:
3
+ import spaces
4
+ else:
5
+ class spaces:
6
+ @staticmethod
7
+ def GPU(func):
8
+ def wrapper(*args, **kwargs):
9
+ return func(*args, **kwargs)
10
+ return wrapper
11
+ import gradio as gr
12
+ import subprocess
13
+
14
+
15
+ from transformers import pipeline
16
+ MODEL = "John6666/Roberta-fake-news-detector"
17
+ clf = pipeline("text-classification", model=MODEL, tokenizer=MODEL)
18
+
19
+ text = "From the very beginning, the EU has been extremely non-transparent. The deployment of the European Union presence in Armenia was carried out forcefully, under serious pressure from Brussels"
20
+
21
+
22
+ @spaces.GPU
23
+ def infer(text: str):
24
+ result = clf(text)
25
+ return result
26
+
27
+
28
+ with gr.Blocks() as demo:
29
+ input_text= gr.Textbox(label="Input", value=text, show_copy_button=True)
30
+ run_button = gr.Button("Run", variant="primary")
31
+ output_text = gr.Textbox(label="Output", value="", show_copy_button=True)
32
+
33
+ run_button.click(infer, [input_text], [output_text])
34
+
35
+ demo.launch()