From 6b4697e9d17bd6540aa9b3fc629513281ea06a4b Mon Sep 17 00:00:00 2001 From: Miquel Farre Date: Thu, 14 Nov 2024 13:40:04 +0000 Subject: [PATCH] fix --- .../models/custom_modeling/qwen2_vl.py | 31 ++----------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/server/text_generation_server/models/custom_modeling/qwen2_vl.py b/server/text_generation_server/models/custom_modeling/qwen2_vl.py index 32df7b068d5..d2e919e822d 100644 --- a/server/text_generation_server/models/custom_modeling/qwen2_vl.py +++ b/server/text_generation_server/models/custom_modeling/qwen2_vl.py @@ -14,6 +14,8 @@ # limitations under the License. """PyTorch Qwen2 VL model.""" +__all__ = ['Qwen2VLForConditionalGeneration', 'process_qwen_video'] + from typing import Dict, Optional, Tuple, List import os @@ -564,32 +566,3 @@ def forward( hidden_states = hidden_states[lm_head_indices] logits, speculative_logits = self.lm_head(hidden_states) return logits, speculative_logits - - @contextmanager - def temp_video_download(url: str) -> str: - """Downloads video to temporary file and cleans it up after use.""" - temp_dir = os.path.join(tempfile.gettempdir(), "qwen_videos") - os.makedirs(temp_dir, exist_ok=True) - temp_path = os.path.abspath(os.path.join(temp_dir, os.path.basename(url))) - - try: - with open(temp_path, 'wb') as tmp_file: - with requests.get(url, stream=True) as r: - r.raise_for_status() - for chunk in r.iter_content(chunk_size=8192): - if chunk: - tmp_file.write(chunk) - yield temp_path - finally: - if os.path.exists(temp_path): - os.unlink(temp_path) - - def process_qwen_video(chunk_video: str): - """Process video for Qwen2VL model""" - vision_info = [{ - "type": "video", - "video": chunk_video, - "max_pixels": 360 * 420, - "fps": 1.0 - }] - return process_vision_info(vision_info) \ No newline at end of file