Update README.md
Browse files
README.md
CHANGED
@@ -11,6 +11,42 @@ model-index:
|
|
11 |
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
12 |
should probably proofread and complete it, then remove this comment. -->
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
# git-base-pokemon
|
15 |
|
16 |
This model is a fine-tuned version of [microsoft/git-base](https://huggingface.co/microsoft/git-base) on an unknown dataset.
|
|
|
11 |
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
12 |
should probably proofread and complete it, then remove this comment. -->
|
13 |
|
14 |
+
#dataset used: polinaeterna/pokemon-blip-captions
|
15 |
+
|
16 |
+
#code
|
17 |
+
```python
|
18 |
+
|
19 |
+
from transformers import AutoProcessor, AutoModelForCausalLM
|
20 |
+
import torch
|
21 |
+
from PIL import Image
|
22 |
+
import requests
|
23 |
+
|
24 |
+
#Preprocess the dataset
|
25 |
+
#Since the dataset has two modalities (image and text), the pre-processing pipeline will preprocess images and the captions.
|
26 |
+
#To do so, load the processor class associated with the model you are about to fine-tune.
|
27 |
+
|
28 |
+
from transformers import AutoProcessor
|
29 |
+
|
30 |
+
checkpoint = "microsoft/git-base"
|
31 |
+
processor = AutoProcessor.from_pretrained(checkpoint)
|
32 |
+
|
33 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
34 |
+
|
35 |
+
model_name = "kr-manish/git-base-pokemon" # Replace with your actual username and model name
|
36 |
+
model = AutoModelForCausalLM.from_pretrained(model_name).to(device)
|
37 |
+
|
38 |
+
url = "https://huggingface.co/datasets/sayakpaul/sample-datasets/resolve/main/pokemon.png" # Replace with the URL of your image
|
39 |
+
image = Image.open(requests.get(url, stream=True).raw)
|
40 |
+
inputs = processor(images=image, return_tensors="pt").to(device)
|
41 |
+
|
42 |
+
generated_ids = model.generate(pixel_values=inputs.pixel_values, max_length=50)
|
43 |
+
generated_caption = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
44 |
+
print(generated_caption)
|
45 |
+
|
46 |
+
#a pink and purple pokemon character with big eyes
|
47 |
+
|
48 |
+
```
|
49 |
+
|
50 |
# git-base-pokemon
|
51 |
|
52 |
This model is a fine-tuned version of [microsoft/git-base](https://huggingface.co/microsoft/git-base) on an unknown dataset.
|