LR36 commited on
Commit
4a80b55
·
verified ·
1 Parent(s): e8183e4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
3
+
4
+ # Load your LOCAL model (update this path)
5
+ MODEL_PATH = "./aba-retrained-final"
6
+
7
+ # Initialize components
8
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
9
+ model = AutoModelForSeq2SeqLM.from_pretrained(MODEL_PATH)
10
+
11
+ def ask_aba(question):
12
+ inputs = tokenizer(f"question: {question}", return_tensors="pt")
13
+ outputs = model.generate(**inputs, max_length=150)
14
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
15
+
16
+ # Gradio interface
17
+ with gr.Blocks() as demo:
18
+ gr.Markdown("# ABA Therapy Assistant")
19
+ with gr.Row():
20
+ question = gr.Textbox(label="Ask about ABA")
21
+ output = gr.Textbox(label="Answer")
22
+ gr.Examples(
23
+ examples=["What is positive reinforcement?", "How to reduce tantrums?"],
24
+ inputs=question
25
+ )
26
+ question.submit(ask_aba, inputs=question, outputs=output)
27
+
28
+ demo.launch()