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()