Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,7 +36,6 @@ model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
|
|
| 36 |
)
|
| 37 |
processor = AutoProcessor.from_pretrained(MODEL_DIR)
|
| 38 |
|
| 39 |
-
# --------- Chat Inference Function ---------
|
| 40 |
def chat_qwen_vl(message: str, history: list, temperature: float = 0.1, max_new_tokens: int = 1024):
|
| 41 |
# —— 原有多模态输入构造 —— #
|
| 42 |
messages = [
|
|
@@ -63,7 +62,7 @@ def chat_qwen_vl(message: str, history: list, temperature: float = 0.1, max_new_
|
|
| 63 |
# 1. 构造 streamer,用 processor.tokenizer(AutoProcessor 内部自带 tokenizer)
|
| 64 |
streamer = TextIteratorStreamer(
|
| 65 |
processor.tokenizer,
|
| 66 |
-
timeout=
|
| 67 |
skip_prompt=True,
|
| 68 |
skip_special_tokens=True
|
| 69 |
)
|
|
@@ -75,9 +74,8 @@ def chat_qwen_vl(message: str, history: list, temperature: float = 0.1, max_new_
|
|
| 75 |
top_k=1024,
|
| 76 |
max_new_tokens=max_new_tokens,
|
| 77 |
temperature=temperature,
|
| 78 |
-
top_p=0.1
|
| 79 |
-
|
| 80 |
-
)
|
| 81 |
# 如果需要零温度贪心,则关闭采样
|
| 82 |
if gen_kwargs["temperature"] == 0:
|
| 83 |
gen_kwargs["do_sample"] = False
|
|
@@ -92,6 +90,7 @@ def chat_qwen_vl(message: str, history: list, temperature: float = 0.1, max_new_
|
|
| 92 |
# 每次拿到新片段就拼接并输出
|
| 93 |
yield "".join(buffer)
|
| 94 |
|
|
|
|
| 95 |
# --------- 3D Mesh Coloring Function ---------
|
| 96 |
def apply_gradient_color(mesh_text: str) -> str:
|
| 97 |
"""
|
|
|
|
| 36 |
)
|
| 37 |
processor = AutoProcessor.from_pretrained(MODEL_DIR)
|
| 38 |
|
|
|
|
| 39 |
def chat_qwen_vl(message: str, history: list, temperature: float = 0.1, max_new_tokens: int = 1024):
|
| 40 |
# —— 原有多模态输入构造 —— #
|
| 41 |
messages = [
|
|
|
|
| 62 |
# 1. 构造 streamer,用 processor.tokenizer(AutoProcessor 内部自带 tokenizer)
|
| 63 |
streamer = TextIteratorStreamer(
|
| 64 |
processor.tokenizer,
|
| 65 |
+
timeout=100.0,
|
| 66 |
skip_prompt=True,
|
| 67 |
skip_special_tokens=True
|
| 68 |
)
|
|
|
|
| 74 |
top_k=1024,
|
| 75 |
max_new_tokens=max_new_tokens,
|
| 76 |
temperature=temperature,
|
| 77 |
+
top_p=0.1
|
| 78 |
+
)
|
|
|
|
| 79 |
# 如果需要零温度贪心,则关闭采样
|
| 80 |
if gen_kwargs["temperature"] == 0:
|
| 81 |
gen_kwargs["do_sample"] = False
|
|
|
|
| 90 |
# 每次拿到新片段就拼接并输出
|
| 91 |
yield "".join(buffer)
|
| 92 |
|
| 93 |
+
|
| 94 |
# --------- 3D Mesh Coloring Function ---------
|
| 95 |
def apply_gradient_color(mesh_text: str) -> str:
|
| 96 |
"""
|