Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
# Load model
|
| 5 |
classifier = pipeline(
|
| 6 |
"text-classification",
|
| 7 |
model="WarTitan2077/Number-Classifier",
|
|
@@ -12,9 +11,7 @@ classifier = pipeline(
|
|
| 12 |
labels = ["Symbolic", "Numeric", "Natural", "Integer", "Rational", "Irrational", "Real", "Prime", "Composite"]
|
| 13 |
label_map = {f"LABEL_{i}": label for i, label in enumerate(labels)}
|
| 14 |
|
| 15 |
-
|
| 16 |
-
@gr.predict()
|
| 17 |
-
def classify_numbers(input1: str, input2: str, input3: str) -> dict:
|
| 18 |
inputs = {"Input1": input1, "Input2": input2, "Input3": input3}
|
| 19 |
results = {}
|
| 20 |
for name, value in inputs.items():
|
|
@@ -26,14 +23,22 @@ def classify_numbers(input1: str, input2: str, input3: str) -> dict:
|
|
| 26 |
results[name] = {}
|
| 27 |
return results
|
| 28 |
|
| 29 |
-
#
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
-
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
|
|
|
| 4 |
classifier = pipeline(
|
| 5 |
"text-classification",
|
| 6 |
model="WarTitan2077/Number-Classifier",
|
|
|
|
| 11 |
labels = ["Symbolic", "Numeric", "Natural", "Integer", "Rational", "Irrational", "Real", "Prime", "Composite"]
|
| 12 |
label_map = {f"LABEL_{i}": label for i, label in enumerate(labels)}
|
| 13 |
|
| 14 |
+
def classify_numbers(input1, input2, input3):
|
|
|
|
|
|
|
| 15 |
inputs = {"Input1": input1, "Input2": input2, "Input3": input3}
|
| 16 |
results = {}
|
| 17 |
for name, value in inputs.items():
|
|
|
|
| 23 |
results[name] = {}
|
| 24 |
return results
|
| 25 |
|
| 26 |
+
# ✅ This creates /predict endpoint usable by Unity
|
| 27 |
+
demo = gr.Interface(
|
| 28 |
+
fn=classify_numbers,
|
| 29 |
+
inputs=[
|
| 30 |
+
gr.Textbox(label="Input 1"),
|
| 31 |
+
gr.Textbox(label="Input 2"),
|
| 32 |
+
gr.Textbox(label="Input 3")
|
| 33 |
+
],
|
| 34 |
+
outputs=gr.JSON(label="Predictions"),
|
| 35 |
+
title="Number Classifier",
|
| 36 |
+
description="Enter up to three inputs to classify them as Symbolic, Numeric, Prime, etc.",
|
| 37 |
+
allow_flagging="never",
|
| 38 |
+
examples=None,
|
| 39 |
+
cache_examples=False,
|
| 40 |
+
api_name="/predict" # ✅ This exposes /predict endpoint
|
| 41 |
+
)
|
| 42 |
|
| 43 |
+
if __name__ == "__main__":
|
| 44 |
+
demo.launch()
|