Update donut_inference.py
Browse files- donut_inference.py +3 -3
donut_inference.py
CHANGED
|
@@ -10,10 +10,10 @@ load_dotenv()
|
|
| 10 |
# imgae = image.resize((1864, 1440))
|
| 11 |
|
| 12 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 13 |
-
device = "cpu"
|
| 14 |
# Load the processor from the local directory
|
| 15 |
processor = DonutProcessor.from_pretrained("Henge-navuuu/donut-base-finetuned-forms-v1")
|
| 16 |
-
|
| 17 |
# Load the model from the local directory
|
| 18 |
model = VisionEncoderDecoderModel.from_pretrained("Henge-navuuu/donut-base-finetuned-forms-v1")
|
| 19 |
model.to(device)
|
|
@@ -25,7 +25,7 @@ def inference(image):
|
|
| 25 |
decoder_input_ids = processor.tokenizer(task_prompt, add_special_tokens=False, return_tensors="pt")["input_ids"]
|
| 26 |
|
| 27 |
# device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 28 |
-
model.to(device)
|
| 29 |
|
| 30 |
outputs = model.generate(pixel_values.to(device),
|
| 31 |
decoder_input_ids=decoder_input_ids.to(device),
|
|
|
|
| 10 |
# imgae = image.resize((1864, 1440))
|
| 11 |
|
| 12 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 13 |
+
# device = "cpu"
|
| 14 |
# Load the processor from the local directory
|
| 15 |
processor = DonutProcessor.from_pretrained("Henge-navuuu/donut-base-finetuned-forms-v1")
|
| 16 |
+
processor.to(device)
|
| 17 |
# Load the model from the local directory
|
| 18 |
model = VisionEncoderDecoderModel.from_pretrained("Henge-navuuu/donut-base-finetuned-forms-v1")
|
| 19 |
model.to(device)
|
|
|
|
| 25 |
decoder_input_ids = processor.tokenizer(task_prompt, add_special_tokens=False, return_tensors="pt")["input_ids"]
|
| 26 |
|
| 27 |
# device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 28 |
+
# model.to(device)
|
| 29 |
|
| 30 |
outputs = model.generate(pixel_values.to(device),
|
| 31 |
decoder_input_ids=decoder_input_ids.to(device),
|