File size: 2,888 Bytes
ecac85b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a321cb0
 
 
ecac85b
69598ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ecac85b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
---
library_name: transformers
license: mit
base_model: microsoft/git-base
tags:
- generated_from_trainer
model-index:
- name: git-base-lucy1
  results: []
---

<!-- This model card has been generated automatically according to the information the Trainer had access to. You
should probably proofread and complete it, then remove this comment. -->

# git-base-lucy1

This model is a fine-tuned version of [microsoft/git-base](https://huggingface.co/microsoft/git-base) on an unknown dataset.
It achieves the following results on the evaluation set:
- Loss: 5.9368
- Wer Score: 3.1310

## Model description

Fine-tuned captioning model on Lucy in the Sky images.

Dataset: [tonyassi/lucy-caption-2](https://huggingface.co/datasets/tonyassi/lucy-caption-2)

## Usage
```python
import torch
from PIL import Image
from transformers import AutoProcessor, AutoModelForCausalLM
import requests

# Load model directly
processor = AutoProcessor.from_pretrained("tonyassi/git-base-lucy1")
model = AutoModelForCausalLM.from_pretrained("tonyassi/git-base-lucy1")

# Load image
url = "https://datasets-server.huggingface.co/cached-assets/tonyassi/lucy-caption-2/--/94d2ffc965a7a0a50beebbeb60d04fa38a24ff66/--/default/train/6/image/image.jpg?Expires=1727109954&Signature=IMpoIBQV-ICPaC8V4NF2SUn0OQE7cOtIJZIeGSpOQLifkjlXl3rx6CAukc2Ax3Gkl4eQ3BfcDrnV2HNzE-c3c5WC5lcj30PWTkSczcqN7YtkKGFHOxlS6-Gv8zotQw8NJPn0d-LoCERHlxA75Sbh8vF8X6DE1SCRJIitT3DFcObTdKpZpHYDv21BYq4-A4EN04wX6aKHWyz8xR0NorlOtcB8dzPdsSpRGy3gcgLU9kHeBNWpa22KsMDJmDP8QferzrnG5bnb5fi9RxrMCTURCPUB8AyNJ1mVwuAorW4GJIdm40UEoqanQzrST3hIp-dTEH47w5-GY5PnOrWUcaxYGQ__&Key-Pair-Id=K3EI6M078Z3AC3"
image = Image.open(requests.get(url, stream=True).raw)

# GPU or CPU
device = "cuda" if torch.cuda.is_available() else "cpu"

# Inference
inputs = processor(images=image, return_tensors="pt").to(device)
pixel_values = inputs.pixel_values
generated_ids = model.generate(pixel_values=pixel_values, max_length=50)
generated_caption = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
print(generated_caption)

```

## Intended uses & limitations

More information needed

## Training and evaluation data

More information needed

## Training procedure

### Training hyperparameters

The following hyperparameters were used during training:
- learning_rate: 5e-05
- train_batch_size: 32
- eval_batch_size: 32
- seed: 42
- gradient_accumulation_steps: 2
- total_train_batch_size: 64
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: linear
- num_epochs: 50
- mixed_precision_training: Native AMP

### Training results

| Training Loss | Epoch | Step | Validation Loss | Wer Score |
|:-------------:|:-----:|:----:|:---------------:|:---------:|
| 3.589         | 50.0  | 50   | 5.9368          | 3.1310    |


### Framework versions

- Transformers 4.44.2
- Pytorch 2.4.0+cu121
- Datasets 2.21.0
- Tokenizers 0.19.1