Update app.py
Browse files
app.py
CHANGED
|
@@ -16,12 +16,12 @@ ACTIONS = [
|
|
| 16 |
"chat_only"
|
| 17 |
]
|
| 18 |
|
| 19 |
-
# Load model and tokenizer
|
| 20 |
-
model_name = "
|
| 21 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 22 |
model = AutoModelForSequenceClassification.from_pretrained(model_name, num_labels=len(ACTIONS))
|
| 23 |
|
| 24 |
-
# This function will need to be trained
|
| 25 |
def predict_action(text):
|
| 26 |
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
|
| 27 |
outputs = model(**inputs)
|
|
@@ -41,23 +41,12 @@ def process_text(text):
|
|
| 41 |
return result["action"], result["confidence"], result["all_actions"]
|
| 42 |
|
| 43 |
# Define the Gradio interface
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
all_actions_output = gr.JSON(label="All action probabilities")
|
| 52 |
-
|
| 53 |
-
text_input.change(process_text, inputs=text_input, outputs=[action_output, confidence_output, all_actions_output])
|
| 54 |
-
|
| 55 |
-
gr.Interface(
|
| 56 |
-
fn=predict_action,
|
| 57 |
-
inputs=gr.Textbox(label="Character text"),
|
| 58 |
-
outputs=gr.JSON(label="Result"),
|
| 59 |
-
title="Minecraft Action Predictor API",
|
| 60 |
-
description="Predicts the best action based on character text"
|
| 61 |
-
)
|
| 62 |
|
| 63 |
demo.launch()
|
|
|
|
| 16 |
"chat_only"
|
| 17 |
]
|
| 18 |
|
| 19 |
+
# Load model and tokenizer - CORRECTED MODEL NAME
|
| 20 |
+
model_name = "microsoft/deberta-v3-small" # Correct format for model name
|
| 21 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 22 |
model = AutoModelForSequenceClassification.from_pretrained(model_name, num_labels=len(ACTIONS))
|
| 23 |
|
| 24 |
+
# This function will need to be trained with your data
|
| 25 |
def predict_action(text):
|
| 26 |
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
|
| 27 |
outputs = model(**inputs)
|
|
|
|
| 41 |
return result["action"], result["confidence"], result["all_actions"]
|
| 42 |
|
| 43 |
# Define the Gradio interface
|
| 44 |
+
demo = gr.Interface(
|
| 45 |
+
fn=predict_action,
|
| 46 |
+
inputs=gr.Textbox(label="Character text"),
|
| 47 |
+
outputs=gr.JSON(label="Result"),
|
| 48 |
+
title="Minecraft Action Predictor",
|
| 49 |
+
description="Predicts the best action based on character text"
|
| 50 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
demo.launch()
|