Feature Extraction
Transformers
Safetensors
clip_vision_model
vision
clip
fine-tuned
PatchCamelyon
medical-imaging
Instructions to use lens-ai/clip-vit-base-patch32_pcam_finetuned with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lens-ai/clip-vit-base-patch32_pcam_finetuned with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="lens-ai/clip-vit-base-patch32_pcam_finetuned")# Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("lens-ai/clip-vit-base-patch32_pcam_finetuned") model = AutoModel.from_pretrained("lens-ai/clip-vit-base-patch32_pcam_finetuned", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Commit ·
f7782b6
1
Parent(s): 7a35ecb
Added Finetuned model.
Browse files- README.md +55 -0
- model.pt +3 -0
- model.safetensors +3 -0
README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# CLIP ViT Base Patch32 Fine-Tuned on PatchCamelyon (PCAM)
|
| 2 |
+
|
| 3 |
+
## Overview
|
| 4 |
+
This repository contains a fine-tuned version of the [CLIP ViT Base Patch32](https://huggingface.co/tanganke/clip-vit-base-patch32_pcam) model on the [PatchCamelyon (PCAM)](https://huggingface.co/datasets/1aurent/PatchCamelyon) dataset. The model is optimized for histopathological image classification.
|
| 5 |
+
|
| 6 |
+
## Model Details
|
| 7 |
+
- **Base Model**: CLIP ViT Base Patch32
|
| 8 |
+
- **Dataset**: PatchCamelyon (PCAM)
|
| 9 |
+
- **Optimizer**: AdamW
|
| 10 |
+
- **Loss Function**: Cross-Entropy Loss
|
| 11 |
+
- **Batch Size**: 32
|
| 12 |
+
- **Hardware**: Trained on GPU
|
| 13 |
+
|
| 14 |
+
## Training Performance
|
| 15 |
+
- **Epoch 1 Results:**
|
| 16 |
+
- **Train Loss**: 0.1520
|
| 17 |
+
- **Train Accuracy**: 94.35%
|
| 18 |
+
- **Validation Accuracy**: 95.16%
|
| 19 |
+
|
| 20 |
+
## Usage
|
| 21 |
+
### Installation
|
| 22 |
+
Ensure you have `transformers`, `torch`, and `safetensors` installed:
|
| 23 |
+
```bash
|
| 24 |
+
pip install transformers torch safetensors
|
| 25 |
+
```
|
| 26 |
+
|
| 27 |
+
### Loading the Model
|
| 28 |
+
```python
|
| 29 |
+
from transformers import CLIPProcessor, CLIPModel
|
| 30 |
+
import torch
|
| 31 |
+
|
| 32 |
+
model_path = "lens-ai/clip-vit-base-patch32_pcam_finetuned"
|
| 33 |
+
model = CLIPModel.from_pretrained(model_path)
|
| 34 |
+
processor = CLIPProcessor.from_pretrained(model_path)
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
### Running Inference
|
| 38 |
+
```python
|
| 39 |
+
from PIL import Image
|
| 40 |
+
|
| 41 |
+
image = Image.open("sample_image.png")
|
| 42 |
+
inputs = processor(images=image, return_tensors="pt")
|
| 43 |
+
outputs = model.get_image_features(**inputs)
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
## Evaluation
|
| 47 |
+
We plan to release additional metrics, including robustness evaluation with adversarial attacks in future updates.
|
| 48 |
+
|
| 49 |
+
## License
|
| 50 |
+
This model is released under the MIT License.
|
| 51 |
+
|
| 52 |
+
## Contact
|
| 53 |
+
For any questions, please reach out to **Venkata Tej** at [LensAI](https://huggingface.co/lens-ai).
|
| 54 |
+
|
| 55 |
+
|
model.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9ccba33e2776d169fe9e403f28d15f4ea9fa2afbc33353e6250eb0f5aff390a9
|
| 3 |
+
size 349914376
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fd8789b2b8f9bf20ed6576c7670c52b37eb917f292b7c6759e4dcd1d0c57b1c7
|
| 3 |
+
size 349847824
|