Fixed paths
Browse files- pipeline.py +3 -3
pipeline.py
CHANGED
|
@@ -18,7 +18,7 @@ class PreTrainedPipeline():
|
|
| 18 |
hidden_dim = 1024
|
| 19 |
num_heads = 8
|
| 20 |
self.nutr_names = ('energy', 'fat', 'protein', 'carbs')
|
| 21 |
-
with open(
|
| 22 |
self.ingredients = json.load(f)
|
| 23 |
self.ing_names = {ing['name']: int(ing_id) for ing_id, ing in self.ingredients.items()}
|
| 24 |
self.vocab_size = len(self.ingredients) + 3
|
|
@@ -35,7 +35,7 @@ class PreTrainedPipeline():
|
|
| 35 |
)
|
| 36 |
self.tfing.compile()
|
| 37 |
self.tfing((tf.zeros((1, 224, 224, 3)), tf.zeros((1, seq_length))))
|
| 38 |
-
self.tfing.load_weights(
|
| 39 |
|
| 40 |
self.tfport = TFPort(
|
| 41 |
crop_size,
|
|
@@ -50,7 +50,7 @@ class PreTrainedPipeline():
|
|
| 50 |
)
|
| 51 |
self.tfport.compile()
|
| 52 |
self.tfport((tf.zeros((1, 224, 224, 3)), tf.zeros((1, seq_length)), tf.zeros((1, seq_length))))
|
| 53 |
-
self.tfport.load_weights(
|
| 54 |
|
| 55 |
def __call__(self, inputs: "Image.Image") -> List[Dict[str, Any]]:
|
| 56 |
image = tf.keras.preprocessing.image.img_to_array(inputs)
|
|
|
|
| 18 |
hidden_dim = 1024
|
| 19 |
num_heads = 8
|
| 20 |
self.nutr_names = ('energy', 'fat', 'protein', 'carbs')
|
| 21 |
+
with open(os.path.join(path, "ingredients_metadata.json"), encoding='UTF-8') as f:
|
| 22 |
self.ingredients = json.load(f)
|
| 23 |
self.ing_names = {ing['name']: int(ing_id) for ing_id, ing in self.ingredients.items()}
|
| 24 |
self.vocab_size = len(self.ingredients) + 3
|
|
|
|
| 35 |
)
|
| 36 |
self.tfing.compile()
|
| 37 |
self.tfing((tf.zeros((1, 224, 224, 3)), tf.zeros((1, seq_length))))
|
| 38 |
+
self.tfing.load_weights(os.path.join(path, 'tfing.h5'))
|
| 39 |
|
| 40 |
self.tfport = TFPort(
|
| 41 |
crop_size,
|
|
|
|
| 50 |
)
|
| 51 |
self.tfport.compile()
|
| 52 |
self.tfport((tf.zeros((1, 224, 224, 3)), tf.zeros((1, seq_length)), tf.zeros((1, seq_length))))
|
| 53 |
+
self.tfport.load_weights(os.path.join(path, 'tfport.h5'))
|
| 54 |
|
| 55 |
def __call__(self, inputs: "Image.Image") -> List[Dict[str, Any]]:
|
| 56 |
image = tf.keras.preprocessing.image.img_to_array(inputs)
|