jauntybrain commited on
Commit
7555d4c
1 Parent(s): 8ebc1d4

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +3 -3
handler.py CHANGED
@@ -8,7 +8,7 @@ class EndpointHandler:
8
  self.processor = AutoProcessor.from_pretrained(path)
9
  self.model = MusicgenForConditionalGeneration.from_pretrained(path, torch_dtype=torch.float16).to("cuda")
10
 
11
- def __call__(self, data: Dict[str, Any]) -> bytes:
12
  """
13
  Args:
14
  data (:dict:):
@@ -29,6 +29,6 @@ class EndpointHandler:
29
  outputs = self.model.generate(**inputs, do_sample=False, max_new_tokens=400)
30
 
31
  # postprocess the prediction
32
- prediction = outputs[0].cpu().numpy().tobytes()
33
 
34
- return prediction
 
8
  self.processor = AutoProcessor.from_pretrained(path)
9
  self.model = MusicgenForConditionalGeneration.from_pretrained(path, torch_dtype=torch.float16).to("cuda")
10
 
11
+ def __call__(self, data: Dict[str, Any]) -> Dict[str, str]:
12
  """
13
  Args:
14
  data (:dict:):
 
29
  outputs = self.model.generate(**inputs, do_sample=False, max_new_tokens=400)
30
 
31
  # postprocess the prediction
32
+ prediction = outputs[0].cpu().numpy().tolist()
33
 
34
+ return [{"generated_audio": prediction}]