rroset commited on
Commit
4621849
1 Parent(s): f3e44e7

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +4 -4
handler.py CHANGED
@@ -6,13 +6,13 @@ import base64
6
  from typing import Dict, List, Any
7
 
8
  class EndpointHandler():
9
- def __init__(self, path="."):
10
- # Carrega el model i el processor específics de CLIP
11
  self.model = CLIPModel.from_pretrained(path)
12
  self.processor = CLIPProcessor.from_pretrained(path)
13
 
14
  # Crea la pipeline de classificació d'imatges zero-shot
15
- self.classifier = pipeline("zero-shot-image-classification", model=self.model, tokenizer=self.processor)
16
 
17
  def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
18
  image_input = data.get("inputs", None)
@@ -26,7 +26,7 @@ class EndpointHandler():
26
  response = requests.get(image_input)
27
  image = Image.open(BytesIO(response.content))
28
  else:
29
- # Suposa que l'input és base64 i decodifica-la
30
  image_data = base64.b64decode(image_input)
31
  image = Image.open(BytesIO(image_data))
32
 
 
6
  from typing import Dict, List, Any
7
 
8
  class EndpointHandler():
9
+ def __init__(self, path=""):
10
+ # Carrega el model i el processador específics de CLIP
11
  self.model = CLIPModel.from_pretrained(path)
12
  self.processor = CLIPProcessor.from_pretrained(path)
13
 
14
  # Crea la pipeline de classificació d'imatges zero-shot
15
+ self.classifier = pipeline("zero-shot-image-classification", model=self.model, processor=self.processor)
16
 
17
  def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
18
  image_input = data.get("inputs", None)
 
26
  response = requests.get(image_input)
27
  image = Image.open(BytesIO(response.content))
28
  else:
29
+ # Suposem que l'input és base64 i decodifica-la
30
  image_data = base64.b64decode(image_input)
31
  image = Image.open(BytesIO(image_data))
32