Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
3 |
+
|
4 |
+
tokenizer = AutoTokenizer.from_pretrained("ByteDance-Seed/UI-TARS-1.5-7B")
|
5 |
+
model = AutoModelForCausalLM.from_pretrained("ByteDance-Seed/UI-TARS-1.5-7B")
|
6 |
+
|
7 |
+
def predict(ui_context, goal):
|
8 |
+
prompt = f"<context>{ui_context}</context>\n<task>{goal}</task>"
|
9 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
10 |
+
outputs = model.generate(**inputs, max_new_tokens=128)
|
11 |
+
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
12 |
+
|
13 |
+
gr.Interface(fn=predict,
|
14 |
+
inputs=["textbox", "textbox"],
|
15 |
+
outputs="textbox",
|
16 |
+
title="UITARS 1.5 Action Predictor"
|
17 |
+
).launch()
|