Image-to-Text
Transformers
lana_arxiv
feature-extraction
medical-ai
radiology
chest-xray
report-generation
arxiv
legacy-model
custom_code
Instructions to use manu02/LAnA-Arxiv with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use manu02/LAnA-Arxiv 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="manu02/LAnA-Arxiv", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("manu02/LAnA-Arxiv", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
| import torchvision.transforms as T | |
| import fsspec | |
| import io | |
| from PIL import Image | |
| def image_transform(img_size=512): | |
| return T.Compose([ | |
| T.Resize((img_size, img_size), interpolation=T.InterpolationMode.BICUBIC), | |
| T.ToTensor(), | |
| T.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) | |
| ]) | |
| def open_binary(path: str): | |
| """ | |
| Open any (local or gs://) file for binary reading. | |
| Returns a file-like object (context manager). | |
| """ | |
| return fsspec.open(path, mode="rb").open() | |
| def pil_from_path(path: str) -> Image.Image: | |
| """ | |
| Load an image from local or GCS; returns a PIL image in RGB. | |
| """ | |
| with open_binary(path) as f: | |
| img_bytes = f.read() | |
| im = Image.open(io.BytesIO(img_bytes)).convert("RGB") | |
| return im |