Spaces:
Sleeping
Sleeping
File size: 1,115 Bytes
7431386 b08e97a 124c819 7431386 b28d8c7 7431386 124c819 a135394 99d492c 7431386 9b30311 4c7f128 9b30311 7431386 a135394 745d234 a135394 9b30311 a135394 |
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 37 38 39 |
import gradio as gr
from transformers import pipeline
classifier = pipeline(
"text-classification",
model="WarTitan2077/Number-Classifier",
tokenizer="WarTitan2077/Number-Classifier",
top_k=None
)
labels = ["Symbolic", "Numeric", "Natural", "Integer", "Rational", "Irrational", "Real", "Prime", "Composite"]
label_map = {f"LABEL_{i}": label for i, label in enumerate(labels)}
def classify_numbers(input1, input2, input3):
inputs = {"Input1": input1, "Input2": input2, "Input3": input3}
results = {}
for name, value in inputs.items():
if value.strip():
output = classifier(value)[0]
result = {label_map[item["label"]]: round(item["score"], 3) for item in output}
results[name] = result
else:
results[name] = {}
return results
demo = gr.Interface(
fn=classify_numbers,
inputs=[
gr.Textbox(label="Input 1"),
gr.Textbox(label="Input 2"),
gr.Textbox(label="Input 3")
],
outputs=gr.JSON(label="Predictions"),
api_name="/predict"
)
if __name__ == "__main__":
demo.launch()
|