Spaces:
Runtime error
Runtime error
Commit ·
ed7b53e
1
Parent(s): 028e671
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,14 +2,11 @@ import torch
|
|
| 2 |
from transformers import BartForConditionalGeneration, BartTokenizer
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
# Load the fine-tuned model and tokenizer
|
| 8 |
model_path = "difinative/AIBuddy" # Path to the pretrained fine-tuned model
|
| 9 |
model = BartForConditionalGeneration.from_pretrained(model_path)
|
| 10 |
tokenizer = BartTokenizer.from_pretrained(model_path)
|
| 11 |
|
| 12 |
-
|
| 13 |
# Translate function using the fine-tuned model
|
| 14 |
def translate_instruction(context, input_text):
|
| 15 |
full_input = context + " " + input_text
|
|
@@ -19,7 +16,6 @@ def translate_instruction(context, input_text):
|
|
| 19 |
translated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 20 |
return translated_text
|
| 21 |
|
| 22 |
-
|
| 23 |
# Gradio Interface
|
| 24 |
iface = gr.Interface(
|
| 25 |
fn=translate_instruction,
|
|
@@ -40,12 +36,8 @@ iface = gr.Interface(
|
|
| 40 |
<li>Kubernetes -> Show the pods running in the 'testing' namespace?</li>
|
| 41 |
<li>Docker -> What command should I use to get the list of containers?</li>
|
| 42 |
</ul>
|
| 43 |
-
</div>"
|
| 44 |
-
#examples_style = {"textAlign": "left"}
|
| 45 |
-
#examples_align = "left"
|
| 46 |
)
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
# Launch the Gradio app using Ngrok
|
| 51 |
-
iface.launch()
|
|
|
|
| 2 |
from transformers import BartForConditionalGeneration, BartTokenizer
|
| 3 |
import gradio as gr
|
| 4 |
|
|
|
|
|
|
|
| 5 |
# Load the fine-tuned model and tokenizer
|
| 6 |
model_path = "difinative/AIBuddy" # Path to the pretrained fine-tuned model
|
| 7 |
model = BartForConditionalGeneration.from_pretrained(model_path)
|
| 8 |
tokenizer = BartTokenizer.from_pretrained(model_path)
|
| 9 |
|
|
|
|
| 10 |
# Translate function using the fine-tuned model
|
| 11 |
def translate_instruction(context, input_text):
|
| 12 |
full_input = context + " " + input_text
|
|
|
|
| 16 |
translated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 17 |
return translated_text
|
| 18 |
|
|
|
|
| 19 |
# Gradio Interface
|
| 20 |
iface = gr.Interface(
|
| 21 |
fn=translate_instruction,
|
|
|
|
| 36 |
<li>Kubernetes -> Show the pods running in the 'testing' namespace?</li>
|
| 37 |
<li>Docker -> What command should I use to get the list of containers?</li>
|
| 38 |
</ul>
|
| 39 |
+
</div>"""
|
|
|
|
|
|
|
| 40 |
)
|
| 41 |
|
|
|
|
|
|
|
| 42 |
# Launch the Gradio app using Ngrok
|
| 43 |
+
iface.launch()
|