|
import gradio as gr |
|
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM |
|
|
|
|
|
model_checkpoint = "AnasHXH/Ros_model" |
|
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint) |
|
model = AutoModelForSeq2SeqLM.from_pretrained(model_checkpoint) |
|
|
|
def generate_command(input_text): |
|
|
|
inputs = tokenizer(input_text, return_tensors="pt", padding=True, truncation=True) |
|
|
|
outputs = model.generate(inputs["input_ids"]) |
|
|
|
command = tokenizer.decode(outputs[0], skip_special_tokens=True) |
|
return command |
|
|
|
|
|
iface = gr.Interface( |
|
fn=generate_command, |
|
inputs="text", |
|
outputs="text", |
|
title="Robot Command Generator", |
|
description="Type in English to get the robot command" |
|
) |
|
|
|
|
|
iface.launch() |