
<!-- 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. -->

# vit-base-patch16-224-finetuned-forgery

This model is a fine-tuned version of [google/vit-base-patch16-224](https://huggingface.co/google/vit-base-patch16-224) on the imagefolder dataset.
It achieves the following results on the evaluation set:
- Loss: 0.0659
- Accuracy: 0.9762

## Model description

More information needed

## Intended uses & limitations

To use, combine known genuine signature with questioned signature into a single image, then run inference.

```python
from PIL import Image

def create_comparison_image(img1_path, img2_path):
    # Open images
    img1 = Image.open(img1_path).convert("RGB")
    img2 = Image.open(img2_path).convert("RGB")
    
    # Resize to same height
    height = max(img1.height, img2.height)
    width1 = int(img1.width * (height / img1.height))
    width2 = int(img2.width * (height / img2.height))
    
    img1 = img1.resize((width1, height), Image.LANCZOS)
    img2 = img2.resize((width2, height), Image.LANCZOS)
    
    # Create new image with space for both images
    total_width = width1 + width2
    comparison = Image.new('RGB', (total_width, height))
    
    # Paste images side by side
    comparison.paste(img1, (0, 0))
    comparison.paste(img2, (width1, 0))
    
    return comparison
```


## Training procedure

### Training hyperparameters

The following hyperparameters were used during training:
- learning_rate: 2.1687073595562957e-05
- train_batch_size: 29
- eval_batch_size: 8
- seed: 42
- gradient_accumulation_steps: 5
- total_train_batch_size: 145
- optimizer: Use OptimizerNames.ADAMW_TORCH with betas=(0.9,0.999) and epsilon=1e-08 and optimizer_args=No additional optimizer arguments
- lr_scheduler_type: linear
- lr_scheduler_warmup_steps: 1
- num_epochs: 5

### Training results

| Training Loss | Epoch  | Step | Validation Loss | Accuracy |
|:-------------:|:------:|:----:|:---------------:|:--------:|
| 0.3114        | 0.9991 | 470  | 0.1464          | 0.9477   |
| 0.2831        | 1.9991 | 940  | 0.0803          | 0.9697   |
| 0.2806        | 2.9991 | 1410 | 0.0727          | 0.9756   |
| 0.2779        | 3.9991 | 1880 | 0.0744          | 0.9758   |
| 0.2588        | 4.9991 | 2350 | 0.0659          | 0.9762   |


### Framework versions

- Transformers 4.51.3
- Pytorch 2.7.0+cu126
- Datasets 3.6.0
- Tokenizers 0.21.1
forgery genuine