Fix snippet
Browse files
README.md
CHANGED
|
@@ -96,6 +96,18 @@ Now, let's instantiate the model and processor.
|
|
| 96 |
>>> processor = get_processor()
|
| 97 |
```
|
| 98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
### Feature extraction
|
| 100 |
|
| 101 |
```python
|
|
@@ -111,23 +123,11 @@ torch.Size([1, 1, 192, 192, 192])
|
|
| 111 |
>>> patch_embeddings.shape
|
| 112 |
torch.Size([1, 768, 24, 24, 24])
|
| 113 |
>>> with torch.no_grad():
|
| 114 |
-
... pooled_embeddings = model.encode_image(images_batch, pool=True)
|
| 115 |
>>> pooled_embeddings.shape
|
| 116 |
torch.Size([1, 768])
|
| 117 |
```
|
| 118 |
|
| 119 |
-
### Zero-shot classification
|
| 120 |
-
|
| 121 |
-
```python
|
| 122 |
-
>>> from colipri import ZeroShotImageClassificationPipeline
|
| 123 |
-
>>> pipeline = ZeroShotImageClassificationPipeline(model, processor)
|
| 124 |
-
>>> pipeline(image, ["No lung nodules", "Lung nodules"])
|
| 125 |
-
[
|
| 126 |
-
{'score': 0.005, 'label': 'No lung nodules'},
|
| 127 |
-
{'score': 0.995, 'label': 'Lung nodules'}
|
| 128 |
-
]
|
| 129 |
-
```
|
| 130 |
-
|
| 131 |
## Environmental impact
|
| 132 |
|
| 133 |
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
|
|
|
| 96 |
>>> processor = get_processor()
|
| 97 |
```
|
| 98 |
|
| 99 |
+
### Zero-shot classification
|
| 100 |
+
|
| 101 |
+
```python
|
| 102 |
+
>>> from colipri import ZeroShotImageClassificationPipeline
|
| 103 |
+
>>> pipeline = ZeroShotImageClassificationPipeline(model, processor)
|
| 104 |
+
>>> pipeline(image, ["No lung nodules", "Lung nodules"])
|
| 105 |
+
[
|
| 106 |
+
{'score': 0.005, 'label': 'No lung nodules'},
|
| 107 |
+
{'score': 0.995, 'label': 'Lung nodules'}
|
| 108 |
+
]
|
| 109 |
+
```
|
| 110 |
+
|
| 111 |
### Feature extraction
|
| 112 |
|
| 113 |
```python
|
|
|
|
| 123 |
>>> patch_embeddings.shape
|
| 124 |
torch.Size([1, 768, 24, 24, 24])
|
| 125 |
>>> with torch.no_grad():
|
| 126 |
+
... pooled_embeddings = model.encode_image(images_batch, pool=True, project=True)
|
| 127 |
>>> pooled_embeddings.shape
|
| 128 |
torch.Size([1, 768])
|
| 129 |
```
|
| 130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
## Environmental impact
|
| 132 |
|
| 133 |
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|