We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
`Img2VecEncoder` calls `self.prepare` twice
## Your Environment
* Python version: Python 3.8.10
* Operating system: Ubuntu 20.04.3 LTS
* Lightwood version: 1.3.0

## Describe your issue
`Img2VecEncoder` crashes when `.encode(images)` is called.

Internally there seems to be some confusion on what the `.prepare` method actually does.
For some reason it is called to convert images to tensors, while in reality it should be used to initialize the model and (maybe) perform some initial training.

## Fixing the issue

Implement a method to convert images to torch tensors.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `lightwood/encoder/image/img_2_vec.py`
Content:
```
1 import logging
2 import torch
3 import torchvision.transforms as transforms
4 from lightwood.encoder.image.helpers.img_to_vec import Img2Vec
5 from lightwood.encoder.base import BaseEncoder
6 
7 
8 class Img2VecEncoder(BaseEncoder):
9 
10     def __init__(self, is_target: bool = False):
11         super().__init__(is_target)
12         self.model = None
13         # I think we should make this an enum, something like: speed, balance, accuracy
14         self.aim = aim
15         self._prepared = False
16 
17         self._scaler = transforms.Scale((224, 224))
18         self._normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
19         self._to_tensor = transforms.ToTensor()
20 
21         pil_logger = logging.getLogger('PIL')
22         pil_logger.setLevel(logging.ERROR)
23 
24     def prepare(self, priming_data):
25         if self._prepared:
26             raise Exception('You can only call "prepare" once for a given encoder.')
27 
28         if self.model is None:
29             self.model = Img2Vec(model='resnext-50-small')
30         self._prepared = True
31 
32     def encode(self, images):
33         """
34             Encode list of images
35 
36             :images : list of images, each image is a path to a file or a url
37             :return: a torch.floatTensor
38         """
39         if not self._prepared:
40             raise Exception('You need to call "prepare" before calling "encode" or "decode".')
41 
42         img_tensors = self.prepare(images)
43         vec_arr = []
44         self.model.eval()
45         with torch.no_grad():
46             for img_tensor in img_tensors:
47                 vec = self.model(img_tensor.unsqueeze(0), batch=False)
48                 vec_arr.append(vec)
49         return torch.stack(vec_arr)
50 
51     def decode(self, encoded_values_tensor):
52         raise Exception('This encoder is not bi-directional')
53
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/lightwood/encoder/image/img_2_vec.py b/lightwood/encoder/image/img_2_vec.py
--- a/lightwood/encoder/image/img_2_vec.py
+++ b/lightwood/encoder/image/img_2_vec.py
@@ -3,6 +3,7 @@
 import torchvision.transforms as transforms
 from lightwood.encoder.image.helpers.img_to_vec import Img2Vec
 from lightwood.encoder.base import BaseEncoder
+from PIL import Image
 
 
 class Img2VecEncoder(BaseEncoder):
@@ -10,13 +11,18 @@
     def __init__(self, is_target: bool = False):
         super().__init__(is_target)
         self.model = None
-        # I think we should make this an enum, something like: speed, balance, accuracy
-        self.aim = aim
+        # # I think we should make this an enum, something like: speed, balance, accuracy
+        # self.aim = aim
         self._prepared = False
 
-        self._scaler = transforms.Scale((224, 224))
+        self._scaler = transforms.Resize((224, 224))
         self._normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
         self._to_tensor = transforms.ToTensor()
+        self._img_to_tensor = transforms.Compose([
+            self._scaler,
+            self._to_tensor,
+            self._normalize
+        ])
 
         pil_logger = logging.getLogger('PIL')
         pil_logger.setLevel(logging.ERROR)
@@ -39,8 +45,11 @@
         if not self._prepared:
             raise Exception('You need to call "prepare" before calling "encode" or "decode".')
 
-        img_tensors = self.prepare(images)
+        img_tensors = [self._img_to_tensor(
+            Image.open(img_path)
+        ) for img_path in images]
         vec_arr = []
+
         self.model.eval()
         with torch.no_grad():
             for img_tensor in img_tensors:

{"golden_diff": "diff --git a/lightwood/encoder/image/img_2_vec.py b/lightwood/encoder/image/img_2_vec.py\n--- a/lightwood/encoder/image/img_2_vec.py\n+++ b/lightwood/encoder/image/img_2_vec.py\n@@ -3,6 +3,7 @@\n import torchvision.transforms as transforms\n from lightwood.encoder.image.helpers.img_to_vec import Img2Vec\n from lightwood.encoder.base import BaseEncoder\n+from PIL import Image\n \n \n class Img2VecEncoder(BaseEncoder):\n@@ -10,13 +11,18 @@\n     def __init__(self, is_target: bool = False):\n         super().__init__(is_target)\n         self.model = None\n-        # I think we should make this an enum, something like: speed, balance, accuracy\n-        self.aim = aim\n+        # # I think we should make this an enum, something like: speed, balance, accuracy\n+        # self.aim = aim\n         self._prepared = False\n \n-        self._scaler = transforms.Scale((224, 224))\n+        self._scaler = transforms.Resize((224, 224))\n         self._normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])\n         self._to_tensor = transforms.ToTensor()\n+        self._img_to_tensor = transforms.Compose([\n+            self._scaler,\n+            self._to_tensor,\n+            self._normalize\n+        ])\n \n         pil_logger = logging.getLogger('PIL')\n         pil_logger.setLevel(logging.ERROR)\n@@ -39,8 +45,11 @@\n         if not self._prepared:\n             raise Exception('You need to call \"prepare\" before calling \"encode\" or \"decode\".')\n \n-        img_tensors = self.prepare(images)\n+        img_tensors = [self._img_to_tensor(\n+            Image.open(img_path)\n+        ) for img_path in images]\n         vec_arr = []\n+\n         self.model.eval()\n         with torch.no_grad():\n             for img_tensor in img_tensors:\n", "issue": "`Img2VecEncoder` calls `self.prepare` twice\n## Your Environment\r\n* Python version: Python 3.8.10\r\n* Operating system: Ubuntu 20.04.3 LTS\r\n* Lightwood version: 1.3.0\r\n\r\n## Describe your issue\r\n`Img2VecEncoder` crashes when `.encode(images)` is called.\r\n\r\nInternally there seems to be some confusion on what the `.prepare` method actually does.\r\nFor some reason it is called to convert images to tensors, while in reality it should be used to initialize the model and (maybe) perform some initial training.\r\n\r\n## Fixing the issue\r\n\r\nImplement a method to convert images to torch tensors.\r\n\n", "before_files": [{"content": "import logging\nimport torch\nimport torchvision.transforms as transforms\nfrom lightwood.encoder.image.helpers.img_to_vec import Img2Vec\nfrom lightwood.encoder.base import BaseEncoder\n\n\nclass Img2VecEncoder(BaseEncoder):\n\n    def __init__(self, is_target: bool = False):\n        super().__init__(is_target)\n        self.model = None\n        # I think we should make this an enum, something like: speed, balance, accuracy\n        self.aim = aim\n        self._prepared = False\n\n        self._scaler = transforms.Scale((224, 224))\n        self._normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])\n        self._to_tensor = transforms.ToTensor()\n\n        pil_logger = logging.getLogger('PIL')\n        pil_logger.setLevel(logging.ERROR)\n\n    def prepare(self, priming_data):\n        if self._prepared:\n            raise Exception('You can only call \"prepare\" once for a given encoder.')\n\n        if self.model is None:\n            self.model = Img2Vec(model='resnext-50-small')\n        self._prepared = True\n\n    def encode(self, images):\n        \"\"\"\n            Encode list of images\n\n            :images : list of images, each image is a path to a file or a url\n            :return: a torch.floatTensor\n        \"\"\"\n        if not self._prepared:\n            raise Exception('You need to call \"prepare\" before calling \"encode\" or \"decode\".')\n\n        img_tensors = self.prepare(images)\n        vec_arr = []\n        self.model.eval()\n        with torch.no_grad():\n            for img_tensor in img_tensors:\n                vec = self.model(img_tensor.unsqueeze(0), batch=False)\n                vec_arr.append(vec)\n        return torch.stack(vec_arr)\n\n    def decode(self, encoded_values_tensor):\n        raise Exception('This encoder is not bi-directional')\n", "path": "lightwood/encoder/image/img_2_vec.py"}], "after_files": [{"content": "import logging\nimport torch\nimport torchvision.transforms as transforms\nfrom lightwood.encoder.image.helpers.img_to_vec import Img2Vec\nfrom lightwood.encoder.base import BaseEncoder\nfrom PIL import Image\n\n\nclass Img2VecEncoder(BaseEncoder):\n\n    def __init__(self, is_target: bool = False):\n        super().__init__(is_target)\n        self.model = None\n        # # I think we should make this an enum, something like: speed, balance, accuracy\n        # self.aim = aim\n        self._prepared = False\n\n        self._scaler = transforms.Resize((224, 224))\n        self._normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])\n        self._to_tensor = transforms.ToTensor()\n        self._img_to_tensor = transforms.Compose([\n            self._scaler,\n            self._to_tensor,\n            self._normalize\n        ])\n\n        pil_logger = logging.getLogger('PIL')\n        pil_logger.setLevel(logging.ERROR)\n\n    def prepare(self, priming_data):\n        if self._prepared:\n            raise Exception('You can only call \"prepare\" once for a given encoder.')\n\n        if self.model is None:\n            self.model = Img2Vec(model='resnext-50-small')\n        self._prepared = True\n\n    def encode(self, images):\n        \"\"\"\n            Encode list of images\n\n            :images : list of images, each image is a path to a file or a url\n            :return: a torch.floatTensor\n        \"\"\"\n        if not self._prepared:\n            raise Exception('You need to call \"prepare\" before calling \"encode\" or \"decode\".')\n\n        img_tensors = [self._img_to_tensor(\n            Image.open(img_path)\n        ) for img_path in images]\n        vec_arr = []\n\n        self.model.eval()\n        with torch.no_grad():\n            for img_tensor in img_tensors:\n                vec = self.model(img_tensor.unsqueeze(0), batch=False)\n                vec_arr.append(vec)\n        return torch.stack(vec_arr)\n\n    def decode(self, encoded_values_tensor):\n        raise Exception('This encoder is not bi-directional')\n", "path": "lightwood/encoder/image/img_2_vec.py"}]}