Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
#!/usr/bin/env python3
|
2 |
import streamlit as st
|
3 |
import torch
|
|
|
4 |
from PIL import ExifTags
|
5 |
from PIL import Image
|
6 |
from transformers import DonutProcessor
|
@@ -102,13 +103,12 @@ col1, col2 = st.columns(2)
|
|
102 |
if uploaded_file is not None:
|
103 |
image = Image.open(uploaded_file)
|
104 |
else:
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
# image = Image.open(image_choice_map[image_choice])
|
112 |
|
113 |
|
114 |
if information == "Low Res (1200 * 900) 5 epochs":
|
@@ -129,20 +129,24 @@ if st.button("Parse sample! 🐍"):
|
|
129 |
processor = DonutProcessor.from_pretrained(
|
130 |
"Jac-Zac/thesis_test_donut",
|
131 |
revision="12900abc6fb551a0ea339950462a6a0462820b75",
|
|
|
132 |
)
|
133 |
pretrained_model = VisionEncoderDecoderModel.from_pretrained(
|
134 |
"Jac-Zac/thesis_test_donut",
|
135 |
revision="12900abc6fb551a0ea339950462a6a0462820b75",
|
|
|
136 |
)
|
137 |
|
138 |
elif information == "Mid res (1600 ^ 1200) 10 epochs":
|
139 |
processor = DonutProcessor.from_pretrained(
|
140 |
"Jac-Zac/thesis_test_donut",
|
141 |
revision="8c5467cb66685e801ec6ff8de7e7fdd247274ed0",
|
|
|
142 |
)
|
143 |
pretrained_model = VisionEncoderDecoderModel.from_pretrained(
|
144 |
"Jac-Zac/thesis_test_donut",
|
145 |
revision="8c5467cb66685e801ec6ff8de7e7fdd247274ed0",
|
|
|
146 |
)
|
147 |
|
148 |
# this is the same for both models
|
|
|
1 |
#!/usr/bin/env python3
|
2 |
import streamlit as st
|
3 |
import torch
|
4 |
+
import os
|
5 |
from PIL import ExifTags
|
6 |
from PIL import Image
|
7 |
from transformers import DonutProcessor
|
|
|
103 |
if uploaded_file is not None:
|
104 |
image = Image.open(uploaded_file)
|
105 |
else:
|
106 |
+
image_choice_map = {
|
107 |
+
'1': '../donut_example/copy/img_resized/test/00021.jpg',
|
108 |
+
'2': '../donut_example/copy/img_resized/test/00031.jpg',
|
109 |
+
'3': '../donut_example/copy/img_resized/test/00050.jpg',
|
110 |
+
}
|
111 |
+
image = Image.open(image_choice_map[image_choice])
|
|
|
112 |
|
113 |
|
114 |
if information == "Low Res (1200 * 900) 5 epochs":
|
|
|
129 |
processor = DonutProcessor.from_pretrained(
|
130 |
"Jac-Zac/thesis_test_donut",
|
131 |
revision="12900abc6fb551a0ea339950462a6a0462820b75",
|
132 |
+
use_auth_token=os.environ["TOKEN"],
|
133 |
)
|
134 |
pretrained_model = VisionEncoderDecoderModel.from_pretrained(
|
135 |
"Jac-Zac/thesis_test_donut",
|
136 |
revision="12900abc6fb551a0ea339950462a6a0462820b75",
|
137 |
+
use_auth_token=os.environ["TOKEN"],
|
138 |
)
|
139 |
|
140 |
elif information == "Mid res (1600 ^ 1200) 10 epochs":
|
141 |
processor = DonutProcessor.from_pretrained(
|
142 |
"Jac-Zac/thesis_test_donut",
|
143 |
revision="8c5467cb66685e801ec6ff8de7e7fdd247274ed0",
|
144 |
+
use_auth_token=os.environ["TOKEN"],
|
145 |
)
|
146 |
pretrained_model = VisionEncoderDecoderModel.from_pretrained(
|
147 |
"Jac-Zac/thesis_test_donut",
|
148 |
revision="8c5467cb66685e801ec6ff8de7e7fdd247274ed0",
|
149 |
+
use_auth_token=os.environ["TOKEN"],
|
150 |
)
|
151 |
|
152 |
# this is the same for both models
|