nolazil commited on
Commit
273c236
1 Parent(s): eba3dbd

Let input text in pipeline

Browse files
Files changed (1) hide show
  1. pipeline.py +2 -2
pipeline.py CHANGED
@@ -43,12 +43,12 @@ class PreTrainedPipeline():
43
  - "feature_vector": A list of floats corresponding to the image embedding.
44
  """
45
  inputs = data.pop("inputs", data)
46
- parameters = data.pop("parameters", {"mode": "image"})
47
 
48
  # decode base64 image to PIL
49
  image = Image.open(BytesIO(base64.b64decode(inputs['image'])))
50
  image = self.transform(image).unsqueeze(0).to(device)
51
- text=""
52
  with torch.no_grad():
53
  feature_vector = self.model(image, text, mode=parameters["mode"])[0,0].tolist()
54
  # postprocess the prediction
 
43
  - "feature_vector": A list of floats corresponding to the image embedding.
44
  """
45
  inputs = data.pop("inputs", data)
46
+ parameters = data.pop("parameters", {"mode": "multimodal"})
47
 
48
  # decode base64 image to PIL
49
  image = Image.open(BytesIO(base64.b64decode(inputs['image'])))
50
  image = self.transform(image).unsqueeze(0).to(device)
51
+ text = inputs['text'] if 'text' in inputs else ''# already gets tokenised in the model
52
  with torch.no_grad():
53
  feature_vector = self.model(image, text, mode=parameters["mode"])[0,0].tolist()
54
  # postprocess the prediction