NotSoundRated commited on
Commit
85f2aad
·
verified ·
1 Parent(s): 41215c7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -21
app.py CHANGED
@@ -16,12 +16,12 @@ ACTIONS = [
16
  "chat_only"
17
  ]
18
 
19
- # Load model and tokenizer (you'll fine-tune this on your specific task)
20
- model_name = "models/microsoft/deberta-v3-small" # Starting point, you'll need to fine-tune
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/fine-tuned with your data
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
- with gr.Blocks() as demo:
45
- gr.Markdown("# Minecraft Action Predictor")
46
- with gr.Row():
47
- text_input = gr.Textbox(label="Character text")
48
- action_output = gr.Textbox(label="Predicted action")
49
- with gr.Row():
50
- confidence_output = gr.Number(label="Confidence")
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()