Views
No views yet
1from transformers import AutoProcessor, AutoModelForCausalLM
2from PIL import Image
3import torch
4
5processor = AutoProcessor.from_pretrained("JayRay5/DIVE-Doc-FRD", trust_remote_code=True)
6model = AutoModelForCausalLM.from_pretrained("JayRay5/DIVE-Doc-FRD", trust_remote_code=True)
7
8image = Image.open("your_image_document_path/image_document.png").convert("RGB")
9question_example = "What the the name of the author"
10
11inputs = (
12 processor(text=question_example, images=image, return_tensors="pt", padding=True)
13 .to(model.device)
14 .to(model.dtype)
15 )
16input_length = inputs["input_ids"].shape[-1]
17
18with torch.inference_mode():
19 output_ids = model.generate(**inputs, max_new_tokens=100, do_sample=False)
20
21generated_ids = output_ids[0][input_length:]
22answer = processor.decode(generated_ids, skip_special_tokens=True)
23
24print(answer)1git clone https://github.com/JayRay5/DIVE-Doc.git
2cd DIVE-Doc
3conda create -n dive-doc-env python=3.11.5
4conda activate dive-doc-env
5pip install -r requirements.txt1if __name__ == "__main__":
2 path = "JayRay5/DIVE-Doc-FRD"
3 app(path) python app.py1@inproceedings{Bencharef_2025_ICCV,
2 author = {Bencharef, Rayane and Rahiche, Abderrahmane and Cheriet, Mohamed},
3 title = {DIVE-Doc: Downscaling foundational Image Visual Encoder into hierarchical architecture for DocVQA},
4 booktitle = {Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV) Workshops},
5 month = {October},
6 year = {2025},
7 pages = {7547-7556}
8}