dltjwl commited on
Commit
1f5289b
1 Parent(s): fe44f2b

ADD : How to use

Browse files
Files changed (1) hide show
  1. README.md +22 -0
README.md CHANGED
@@ -14,6 +14,28 @@ deplot_kr은 google의 pix2struct 구조를 기반으로 한 한국어 image-to-
14
 
15
  ## How to use
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
 
19
  ### Training data
 
14
 
15
  ## How to use
16
 
17
+ You can run a prediction by input an image.
18
+ Model predict the data table of text form in the image.
19
+
20
+ ```python
21
+ from transformers import Pix2StructForConditionalGeneration, Pix2StructImageProcessor, AutoTokenizer, Pix2StructProcessor
22
+ from PIL import Image
23
+
24
+ image_processor = Pix2StructImageProcessor()
25
+ tokenizer = AutoTokenizer.from_pretrained("brainventures/deplot_kr")
26
+ processor = Pix2StructProcessor(image_processor=image_processor, tokenizer=tokenizer)
27
+
28
+ model = Pix2StructForConditionalGeneration.from_pretrained("brainventures/deplot_kr")
29
+
30
+ image_path = "IMAGE_PATH"
31
+ image = Image.open(image_path)
32
+
33
+ inputs = processor(images=image, return_tensors="pt")
34
+ pred = model.generate(flattened_patches=flattened_patches, attention_mask=attention_mask, max_length=1024)
35
+ print(processor.batch_decode(deplot_generated_ids, skip_special_token=True)[0])
36
+
37
+ ```
38
+
39
 
40
 
41
  ### Training data