Spaces:
Running
on
Zero
Running
on
Zero
File size: 927 Bytes
9974890 536eb9a 9974890 971eb0b 9974890 971eb0b 9974890 971eb0b 9974890 971eb0b 9974890 971eb0b 9974890 971eb0b |
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 |
import gradio as gr
from transformers import pipeline
import spaces
# Load the pipeline (token classification)
#token_classifier = pipeline("token-classification", model="WesScivetti/SNACS_English", aggregation_strategy="simple")
@spaces.GPU # <-- required for ZeroGPU
def classify_tokens(text):
token_classifier = pipeline("token-classification", model="WesScivetti/SNACS_English",
aggregation_strategy="simple")
results = token_classifier(text)
output = ""
for entity in results:
output += f"{entity['word']} ({entity['entity_group']}, score={entity['score']:.2f})\n"
return output.strip()
iface = gr.Interface(
fn=classify_tokens,
inputs=gr.Textbox(lines=4, placeholder="Enter text to be classified..."),
outputs="text",
title="SNACS Tagging in English",
description="SNACS Tagging in English"
)
iface.launch() |