wealthcoders commited on
Commit
49630f8
·
verified ·
1 Parent(s): bbcbe7f

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +4 -5
handler.py CHANGED
@@ -3,14 +3,13 @@ from typing import Dict, List, Any
3
  import torch
4
 
5
  class EndpointHandler:
6
- def __init__(self, path: str = "Qwen/Qwen3-VL-8B-Instruct"):
7
  # Load tokenizer and model
8
  self.processor = AutoProcessor.from_pretrained(path)
9
  self.model = Qwen3VLForConditionalGeneration.from_pretrained(path, device_map="auto")
10
  self.model.eval()
11
-
12
- def __call__(self, data: Dict[str, Any]):
13
-
14
  # Prepare your messages with image and text
15
  messages = data.get("messages")
16
 
@@ -24,6 +23,6 @@ class EndpointHandler:
24
  )
25
  inputs = inputs.to(self.model.device)
26
 
27
- generated_ids = self.model.generate(**inputs, max_new_tokens=2048)
28
  output_text = self.processor.batch_decode(generated_ids, skip_special_tokens=True)
29
  return output_text[0]
 
3
  import torch
4
 
5
  class EndpointHandler:
6
+ def __init__(self, path: str = "Qwen/Qwen3-VL-8B-Instruct"):
7
  # Load tokenizer and model
8
  self.processor = AutoProcessor.from_pretrained(path)
9
  self.model = Qwen3VLForConditionalGeneration.from_pretrained(path, device_map="auto")
10
  self.model.eval()
11
+
12
+ def __call__(self, data: Dict[str, Any]) -> str:
 
13
  # Prepare your messages with image and text
14
  messages = data.get("messages")
15
 
 
23
  )
24
  inputs = inputs.to(self.model.device)
25
 
26
+ generated_ids = self.model.generate(**inputs, max_new_tokens=128)
27
  output_text = self.processor.batch_decode(generated_ids, skip_special_tokens=True)
28
  return output_text[0]