Instructions to use hoangthan/img-caption-demo with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use hoangthan/img-caption-demo with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://hoangthan/img-caption-demo") - Notebooks
- Google Colab
- Kaggle
Update pipeline.py
Browse files- pipeline.py +2 -1
pipeline.py
CHANGED
|
@@ -36,7 +36,8 @@ class PreTrainedPipeline():
|
|
| 36 |
A :obj:`list`:. The list contains items that are dicts should be liked {"label": "XXX", "score": 0.82}
|
| 37 |
It is preferred if the returned list is in decreasing `score` order
|
| 38 |
"""
|
| 39 |
-
|
|
|
|
| 40 |
initial = self.word_to_index([['[START]']]) # (batch, sequence)
|
| 41 |
img_features = self.model.feature_extractor(image[tf.newaxis, ...])
|
| 42 |
temperature = 0
|
|
|
|
| 36 |
A :obj:`list`:. The list contains items that are dicts should be liked {"label": "XXX", "score": 0.82}
|
| 37 |
It is preferred if the returned list is in decreasing `score` order
|
| 38 |
"""
|
| 39 |
+
img_array = tf.keras.utils.img_to_array(inputs)
|
| 40 |
+
image = load_image(img_array)
|
| 41 |
initial = self.word_to_index([['[START]']]) # (batch, sequence)
|
| 42 |
img_features = self.model.feature_extractor(image[tf.newaxis, ...])
|
| 43 |
temperature = 0
|