Rifat Mamayusupov
commited on
Update README.md
Browse files
README.md
CHANGED
|
@@ -15,33 +15,42 @@ train_time: o'rtacha 45 minute.
|
|
| 15 |
|
| 16 |
misol uchun :
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
|
| 22 |
### Usage model
|
| 23 |
|
| 24 |
-
|
|
|
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
image = example["image"]
|
| 32 |
-
image ```
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
-
|
| 36 |
|
| 37 |
|
| 38 |
-
|
| 39 |
-
pixel_values = inputs.pixel_values
|
| 40 |
-
|
| 41 |
-
generated_ids = model.generate(pixel_values=pixel_values, max_length=50)
|
| 42 |
-
generated_caption = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 43 |
-
print(generated_caption) ```
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
|
|
|
| 46 |
|
| 47 |
**Yuqorida ko'rsatgan tartibda modeldan foydalanishni tavsiya qilaman.**
|
|
|
|
| 15 |
|
| 16 |
misol uchun :
|
| 17 |
|
| 18 |
+
```
|
| 19 |
+
from datasets import load_dataset
|
| 20 |
+
dataset = load_dataset("ybelkada/football-dataset", split="train")
|
| 21 |
+
|
| 22 |
+
```
|
| 23 |
|
| 24 |
|
| 25 |
### Usage model
|
| 26 |
|
| 27 |
+
```
|
| 28 |
+
from transformers import AutoProcessor, BlipForConditionalGeneration
|
| 29 |
|
| 30 |
+
processor = AutoProcessor.from_pretrained("ai-nightcoder/Image2text")
|
| 31 |
+
model = BlipForConditionalGeneration.from_pretrained("ai-nightcoder/Image2text")
|
| 32 |
|
| 33 |
+
```
|
| 34 |
+
# image olamiz
|
|
|
|
|
|
|
| 35 |
|
| 36 |
+
```
|
| 37 |
+
example = dataset[0]
|
| 38 |
+
image = example["image"]
|
| 39 |
+
image
|
| 40 |
|
| 41 |
+
```
|
| 42 |
|
| 43 |
|
| 44 |
+
#### generate qismi.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
+
```
|
| 47 |
+
inputs = processor(images=image, return_tensors="pt").to(device)
|
| 48 |
+
pixel_values = inputs.pixel_values
|
| 49 |
+
|
| 50 |
+
generated_ids = model.generate(pixel_values=pixel_values, max_length=50)
|
| 51 |
+
generated_caption = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 52 |
+
print(generated_caption)
|
| 53 |
|
| 54 |
+
```
|
| 55 |
|
| 56 |
**Yuqorida ko'rsatgan tartibda modeldan foydalanishni tavsiya qilaman.**
|