File size: 1,035 Bytes
f0c27c2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
if os.environ.get("SPACES_ZERO_GPU") is not None:
    import spaces
else:
    class spaces:
        @staticmethod
        def GPU(func):
            def wrapper(*args, **kwargs):
                return func(*args, **kwargs)
            return wrapper
import gradio as gr
import subprocess


from transformers import pipeline
MODEL = "John6666/Roberta-fake-news-detector"
clf = pipeline("text-classification", model=MODEL, tokenizer=MODEL)

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"


@spaces.GPU
def infer(text: str):
    result = clf(text)
    return result


with gr.Blocks() as demo:
    input_text= gr.Textbox(label="Input", value=text, show_copy_button=True)
    run_button = gr.Button("Run", variant="primary")
    output_text = gr.Textbox(label="Output", value="", show_copy_button=True)

    run_button.click(infer, [input_text], [output_text])

demo.launch()