Update README.md
Browse files
README.md
CHANGED
@@ -6,30 +6,48 @@ tags:
|
|
6 |
datasets:
|
7 |
- imagefolder
|
8 |
model-index:
|
9 |
-
- name:
|
10 |
results: []
|
11 |
---
|
12 |
|
13 |
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
14 |
should probably proofread and complete it, then remove this comment. -->
|
15 |
|
16 |
-
#
|
17 |
|
18 |
-
This model is a fine-tuned version of [google/paligemma-3b-pt-224](https://huggingface.co/google/paligemma-3b-pt-224) on the
|
19 |
|
20 |
-
## Model description
|
21 |
|
22 |
-
More information needed
|
23 |
|
24 |
-
|
25 |
|
26 |
-
|
|
|
|
|
|
|
27 |
|
28 |
-
|
29 |
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
-
## Training procedure
|
33 |
|
34 |
### Training hyperparameters
|
35 |
|
@@ -45,9 +63,6 @@ The following hyperparameters were used during training:
|
|
45 |
- lr_scheduler_warmup_steps: 2
|
46 |
- num_epochs: 5
|
47 |
|
48 |
-
### Training results
|
49 |
-
|
50 |
-
|
51 |
|
52 |
### Framework versions
|
53 |
|
|
|
6 |
datasets:
|
7 |
- imagefolder
|
8 |
model-index:
|
9 |
+
- name: paligemma_Malaysian_plate_recognition
|
10 |
results: []
|
11 |
---
|
12 |
|
13 |
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
14 |
should probably proofread and complete it, then remove this comment. -->
|
15 |
|
16 |
+
# paligemma_Malaysian_plate_recognition
|
17 |
|
18 |
+
This model is a fine-tuned version of [google/paligemma-3b-pt-224](https://huggingface.co/google/paligemma-3b-pt-224) on the Malaysian license plate dataset.
|
19 |
|
|
|
20 |
|
|
|
21 |
|
22 |
+
``` python
|
23 |
|
24 |
+
from PIL import Image
|
25 |
+
import torch
|
26 |
+
from transformers import PaliGemmaProcessor, PaliGemmaForConditionalGeneration, BitsAndBytesConfig, TrainingArguments, Trainer
|
27 |
+
import time
|
28 |
|
29 |
+
model = PaliGemmaForConditionalGeneration.from_pretrained('NYUAD-ComNets/paligemma_Malaysian_plate_recognition',torch_dtype=torch.bfloat16)
|
30 |
|
31 |
+
input_text ="extract the text from the image"
|
32 |
+
|
33 |
+
processor = PaliGemmaProcessor.from_pretrained("google/paligemma-3b-pt-224")
|
34 |
+
|
35 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
36 |
+
|
37 |
+
model.to(device)
|
38 |
+
|
39 |
+
input_image = Image.open('/home/jovyan/work/image/'+k)
|
40 |
+
|
41 |
+
inputs = processor(text=input_text, images=input_image, padding="longest", do_convert_rgb=True, return_tensors="pt").to(device)
|
42 |
+
inputs = inputs.to(dtype=model.dtype)
|
43 |
+
|
44 |
+
with torch.no_grad():
|
45 |
+
output = model.generate(**inputs, max_length=500)
|
46 |
+
|
47 |
+
result=processor.decode(output[0], skip_special_tokens=True)[len(input_text):].strip()
|
48 |
+
|
49 |
+
```
|
50 |
|
|
|
51 |
|
52 |
### Training hyperparameters
|
53 |
|
|
|
63 |
- lr_scheduler_warmup_steps: 2
|
64 |
- num_epochs: 5
|
65 |
|
|
|
|
|
|
|
66 |
|
67 |
### Framework versions
|
68 |
|