DGurgurov commited on
Commit
19791d1
1 Parent(s): 839de42

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +61 -0
README.md ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # Your Model Name
3
+
4
+ This model is a VisionEncoderDecoderModel fine-tuned on a dataset for generating LaTeX formulas from images.
5
+
6
+ ## Model Details
7
+
8
+ - **Encoder**: Swin Transformer
9
+ - **Decoder**: GPT-2
10
+ - **Framework**: PyTorch
11
+ - **DDP (Distributed Data Parallel)**: Used for training
12
+
13
+ ## Training Data
14
+
15
+ The data is taken from [OleehyO/latex-formulas](https://huggingface.co/datasets/OleehyO/latex-formulas). The data was divided into 80:10:10 for train, val and test. The splits were made as follows:
16
+
17
+ ```python
18
+ dataset = load_dataset(OleehyO/latex-formulas, cleaned_formulas)
19
+ train_val_split = dataset["train"].train_test_split(test_size=0.2, seed=42)
20
+ train_ds = train_val_split["train"]
21
+ val_test_split = train_val_split["test"].train_test_split(test_size=0.5, seed=42)
22
+ val_ds = val_test_split["train"]
23
+ test_ds = val_test_split["test"]
24
+ ```
25
+
26
+ ## Evaluation Metrics
27
+
28
+ The model was evaluated on a test set with the following results:
29
+ - **Test Loss**: 0.10473818009443304
30
+ - **Test BLEU Score**: 0.6661951245257148
31
+
32
+ ## Usage
33
+
34
+ You can use the model directly with the `transformers` library:
35
+
36
+ ```python
37
+ from transformers import VisionEncoderDecoderModel, AutoTokenizer, AutoFeatureExtractor
38
+ import torch
39
+ from PIL import Image
40
+
41
+ # Load model, tokenizer, and feature extractor
42
+ model = VisionEncoderDecoderModel.from_pretrained("your-username/your-model-name")
43
+ tokenizer = AutoTokenizer.from_pretrained("your-username/your-model-name")
44
+ feature_extractor = AutoFeatureExtractor.from_pretrained("your-username/your-model-name")
45
+
46
+ # Prepare an image
47
+ image = Image.open("path/to/your/image.png")
48
+ pixel_values = feature_extractor(images=image, return_tensors="pt").pixel_values
49
+
50
+ # Generate LaTeX formula
51
+ generated_ids = model.generate(pixel_values)
52
+ generated_texts = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
53
+
54
+ print("Generated LaTeX formula:", generated_texts[0])
55
+ ```
56
+
57
+ ## Training Script
58
+ The training script for this model can be found in the following repository: [GitHub](https://github.com/d-gurgurov/im2latex)
59
+
60
+ License
61
+ [MIT]