video datasets

Former-commit-id: 8cafc7b055
This commit is contained in:
hiyouga
2024-09-05 02:04:17 +08:00
parent 60d770e4b1
commit 9df7a26e6b
27 changed files with 420 additions and 148 deletions

View File

@@ -133,6 +133,7 @@ class WebChatModel(ChatModel):
system: str,
tools: str,
image: Optional[Any],
video: Optional[Any],
max_new_tokens: int,
top_p: float,
temperature: float,
@@ -140,7 +141,7 @@ class WebChatModel(ChatModel):
chatbot[-1][1] = ""
response = ""
for new_text in self.stream_chat(
messages, system, tools, image, max_new_tokens=max_new_tokens, top_p=top_p, temperature=temperature
messages, system, tools, image, video, max_new_tokens=max_new_tokens, top_p=top_p, temperature=temperature
):
response += new_text
if tools:

View File

@@ -43,8 +43,12 @@ def create_chat_box(
system = gr.Textbox(show_label=False)
tools = gr.Textbox(show_label=False, lines=3)
with gr.Column() as image_box:
image = gr.Image(sources=["upload"], type="pil")
with gr.Column() as mm_box:
with gr.Tab("Image"):
image = gr.Image(sources=["upload"], type="pil")
with gr.Tab("Video"):
video = gr.Video(sources=["upload"])
query = gr.Textbox(show_label=False, lines=8)
submit_btn = gr.Button(variant="primary")
@@ -63,7 +67,7 @@ def create_chat_box(
[chatbot, messages, query],
).then(
engine.chatter.stream,
[chatbot, messages, system, tools, image, max_new_tokens, top_p, temperature],
[chatbot, messages, system, tools, image, video, max_new_tokens, top_p, temperature],
[chatbot, messages],
)
clear_btn.click(lambda: ([], []), outputs=[chatbot, messages])
@@ -76,8 +80,9 @@ def create_chat_box(
role=role,
system=system,
tools=tools,
image_box=image_box,
mm_box=mm_box,
image=image,
video=video,
query=query,
submit_btn=submit_btn,
max_new_tokens=max_new_tokens,

View File

@@ -68,7 +68,7 @@ def create_infer_tab(engine: "Engine") -> Dict[str, "Component"]:
engine.manager.get_elem_by_id("top.model_name").change(
lambda model_name: gr.Column(visible=get_visual(model_name)),
[engine.manager.get_elem_by_id("top.model_name")],
[chat_elems["image_box"]],
[chat_elems["mm_box"]],
)
return elem_dict

View File

@@ -59,7 +59,7 @@ class Engine:
init_dict["train.output_dir"] = {"value": "train_{}".format(current_time)}
init_dict["train.config_path"] = {"value": "{}.yaml".format(current_time)}
init_dict["eval.output_dir"] = {"value": "eval_{}".format(current_time)}
init_dict["infer.image_box"] = {"visible": False}
init_dict["infer.mm_box"] = {"visible": False}
if user_config.get("last_model", None):
init_dict["top.model_name"] = {"value": user_config["last_model"]}

View File

@@ -1691,6 +1691,20 @@ LOCALES = {
"label": "이미지 (선택 사항)",
},
},
"video": {
"en": {
"label": "Video (optional)",
},
"ru": {
"label": "Видео (по желанию)",
},
"zh": {
"label": "视频(非必填)",
},
"ko": {
"label": "비디오 (선택 사항)",
},
},
"query": {
"en": {
"placeholder": "Input...",