Instructions to use stevenlearns/caption-tool with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use stevenlearns/caption-tool with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "image-to-text" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # 'pip install "transformers<5.0.0' from transformers import pipeline pipe = pipeline("image-to-text", model="stevenlearns/caption-tool")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("stevenlearns/caption-tool", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload folder using huggingface_hub
Browse files- README.md +1 -2
- caption.py +1 -2
- caption_config.json +1 -1
README.md
CHANGED
|
@@ -117,8 +117,7 @@ detailed, but uses more VRAM.
|
|
| 117 |
|
| 118 |
| Model | Size | Best for |
|
| 119 |
| --- | --- | --- |
|
| 120 |
-
| **florence2-large
|
| 121 |
-
| florence2-large | ~1.5 GB | Slightly less accurate. |
|
| 122 |
| **florence2-base** | ~0.45 GB | **2 GB GPUs**, or when you want it fast. |
|
| 123 |
|
| 124 |
If your card only has 2 GB of VRAM, choose **florence2-base**.
|
|
|
|
| 117 |
|
| 118 |
| Model | Size | Best for |
|
| 119 |
| --- | --- | --- |
|
| 120 |
+
| **florence2-large** (default) | ~1.5 GB | Slightly less accurate. Needs a normal GPU. |
|
|
|
|
| 121 |
| **florence2-base** | ~0.45 GB | **2 GB GPUs**, or when you want it fast. |
|
| 122 |
|
| 123 |
If your card only has 2 GB of VRAM, choose **florence2-base**.
|
caption.py
CHANGED
|
@@ -42,13 +42,12 @@ CONFIG_PATH = Path(__file__).parent / "caption_config.json"
|
|
| 42 |
|
| 43 |
# Model choices. Sizes are approximate fp16 GPU footprint.
|
| 44 |
MODELS = {
|
| 45 |
-
"florence2-large-ft": ("microsoft/Florence-2-large-ft", "~1.5 GB — best quality (recommended)"),
|
| 46 |
"florence2-large": ("microsoft/Florence-2-large", "~1.5 GB — base, slightly less accurate"),
|
| 47 |
"florence2-base": ("microsoft/Florence-2-base", "~0.45 GB — fast, great for 2 GB GPUs"),
|
| 48 |
}
|
| 49 |
|
| 50 |
DEFAULT_CONFIG = {
|
| 51 |
-
"model": "microsoft/Florence-2-large
|
| 52 |
"prefix": "",
|
| 53 |
"suffix": "",
|
| 54 |
"max_new_tokens": 256,
|
|
|
|
| 42 |
|
| 43 |
# Model choices. Sizes are approximate fp16 GPU footprint.
|
| 44 |
MODELS = {
|
|
|
|
| 45 |
"florence2-large": ("microsoft/Florence-2-large", "~1.5 GB — base, slightly less accurate"),
|
| 46 |
"florence2-base": ("microsoft/Florence-2-base", "~0.45 GB — fast, great for 2 GB GPUs"),
|
| 47 |
}
|
| 48 |
|
| 49 |
DEFAULT_CONFIG = {
|
| 50 |
+
"model": "microsoft/Florence-2-large",
|
| 51 |
"prefix": "",
|
| 52 |
"suffix": "",
|
| 53 |
"max_new_tokens": 256,
|
caption_config.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
{
|
| 2 |
-
"model": "microsoft/Florence-2-large
|
| 3 |
"prefix": "",
|
| 4 |
"suffix": "",
|
| 5 |
"max_new_tokens": 256,
|
|
|
|
| 1 |
{
|
| 2 |
+
"model": "microsoft/Florence-2-large",
|
| 3 |
"prefix": "",
|
| 4 |
"suffix": "",
|
| 5 |
"max_new_tokens": 256,
|