Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -7,11 +7,12 @@ from huggingface_hub import HfApi
|
|
7 |
import os
|
8 |
|
9 |
PATH_MODEL = os.environ.get('MODEL_REPO_ID')
|
10 |
-
|
|
|
11 |
|
12 |
# PATH_MODEL = "fruk19/donut_nfact_v4"
|
13 |
-
processor = DonutProcessor.from_pretrained(PATH_MODEL)
|
14 |
-
model = VisionEncoderDecoderModel.from_pretrained(PATH_MODEL)
|
15 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
16 |
model.eval()
|
17 |
model.to(device)
|
@@ -20,7 +21,6 @@ def predict(test_image):
|
|
20 |
pixel_values = processor(test_image, return_tensors="pt").pixel_values
|
21 |
pixel_values = pixel_values.to(device)
|
22 |
|
23 |
-
task_prompt = "<s_nfact>"
|
24 |
decoder_input_ids = processor.tokenizer(task_prompt, add_special_tokens=False, return_tensors="pt").input_ids
|
25 |
decoder_input_ids = decoder_input_ids.to(device)
|
26 |
|
|
|
7 |
import os
|
8 |
|
9 |
PATH_MODEL = os.environ.get('MODEL_REPO_ID')
|
10 |
+
token = os.environ.get("HF_TOKEN")
|
11 |
+
task_prompt = os.environ.get("taskprompt")
|
12 |
|
13 |
# PATH_MODEL = "fruk19/donut_nfact_v4"
|
14 |
+
processor = DonutProcessor.from_pretrained(PATH_MODEL, token=token)
|
15 |
+
model = VisionEncoderDecoderModel.from_pretrained(PATH_MODEL, token=token)
|
16 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
17 |
model.eval()
|
18 |
model.to(device)
|
|
|
21 |
pixel_values = processor(test_image, return_tensors="pt").pixel_values
|
22 |
pixel_values = pixel_values.to(device)
|
23 |
|
|
|
24 |
decoder_input_ids = processor.tokenizer(task_prompt, add_special_tokens=False, return_tensors="pt").input_ids
|
25 |
decoder_input_ids = decoder_input_ids.to(device)
|
26 |
|