kxm1k4m1 commited on
Commit
195bfc0
·
verified ·
1 Parent(s): b44ec80

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +31 -0
README.md ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ license: mit
4
+ language:
5
+ - th
6
+ pipeline_tag: image-to-text
7
+ base_model: Salesforce/blip2-opt-2.7b-coco
8
+ ---
9
+
10
+ ## THAI-BLIP-2
11
+ fine-tuned for image captioning task from [blip2-opt-2.7b-coco](Salesforce/blip2-opt-2.7b-coco) with MSCOCO2017 thai caption.
12
+
13
+ ## How to use:
14
+ ```python
15
+ from transformers import Blip2ForConditionalGeneration, Blip2Processor
16
+ from PIL import Image
17
+ import torch
18
+
19
+ device = "cuda" if torch.cuda.is_available() else "cpu"
20
+
21
+ processor = Blip2Processor.from_pretrained("kxm1k4m1/icu-mama-cooking")
22
+ model = Blip2ForConditionalGeneration.from_pretrained("kxm1k4m1/icu-mama-cooking", device_map=device, torch_dtype=torch.bfloat16)
23
+
24
+ img = Image.open("Your image...")
25
+ inputs = processor(images=img, return_tensors="pt").to(device, torch.bfloat16)
26
+
27
+ # Adjust your `max_length`
28
+ generated_ids = model.generate(**inputs, max_length=20)
29
+ generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)
30
+ print(generated_text)
31
+ ```