AyushChothe commited on
Commit
6c16da1
·
1 Parent(s): 8326c43

unsupported operand type(s) for |: 'type' and '_GenericAlias' Fix

Browse files
Files changed (1) hide show
  1. pipeline.py +10 -3
pipeline.py CHANGED
@@ -1,6 +1,6 @@
1
  import asyncio
2
  from io import BytesIO
3
- from typing import Any, Dict, List
4
 
5
  import aiohttp
6
  import numpy as np
@@ -17,7 +17,7 @@ class PreTrainedPipeline:
17
  image = Image.open(BytesIO(await response.read()))
18
  return image
19
 
20
- async def process(self, inputs: str | List[str]) -> List[float]:
21
  if isinstance(inputs, str):
22
  inputs = [inputs]
23
 
@@ -32,7 +32,7 @@ class PreTrainedPipeline:
32
  embedding = np.divide(np.sum(embeddings, axis=0), len(embeddings)).tolist()
33
  return embedding
34
 
35
- def __call__(self, inputs: str | List[str]) -> List[float]:
36
  """
37
  Args:
38
  inputs (:obj:`str`):
@@ -44,3 +44,10 @@ class PreTrainedPipeline:
44
  embedding = loop.run_until_complete(self.process(inputs=inputs))
45
  loop.close()
46
  return embedding
 
 
 
 
 
 
 
 
1
  import asyncio
2
  from io import BytesIO
3
+ from typing import List
4
 
5
  import aiohttp
6
  import numpy as np
 
17
  image = Image.open(BytesIO(await response.read()))
18
  return image
19
 
20
+ async def process(self, inputs: str | list[str]) -> List[float]:
21
  if isinstance(inputs, str):
22
  inputs = [inputs]
23
 
 
32
  embedding = np.divide(np.sum(embeddings, axis=0), len(embeddings)).tolist()
33
  return embedding
34
 
35
+ def __call__(self, inputs: str | list[str]) -> List[float]:
36
  """
37
  Args:
38
  inputs (:obj:`str`):
 
44
  embedding = loop.run_until_complete(self.process(inputs=inputs))
45
  loop.close()
46
  return embedding
47
+
48
+
49
+ print(
50
+ PreTrainedPipeline().__call__(
51
+ inputs="https://images.unsplash.com/photo-1575936123452-b67c3203c357?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8Mnx8aW1hZ2V8ZW58MHx8MHx8fDA%3D&w=1000&q=80"
52
+ )
53
+ )