Spaces:
Runtime error
Runtime error
Parameter check
Browse files
app.py
CHANGED
|
@@ -15,12 +15,15 @@ def run_prediction(sample, model, processor, mode):
|
|
| 15 |
no_repeat_ngram_size = 10
|
| 16 |
elif mode == "Table":
|
| 17 |
prompt = "<s><s_hierarchical>"
|
| 18 |
-
no_repeat_ngram_size =
|
| 19 |
else:
|
| 20 |
prompt = "<s><s_hierarchical>"
|
| 21 |
no_repeat_ngram_size = 10
|
| 22 |
|
| 23 |
|
|
|
|
|
|
|
|
|
|
| 24 |
pixel_values = processor(np.array(
|
| 25 |
sample,
|
| 26 |
np.float32,
|
|
@@ -32,7 +35,7 @@ def run_prediction(sample, model, processor, mode):
|
|
| 32 |
decoder_input_ids=processor.tokenizer(prompt, add_special_tokens=False, return_tensors="pt").input_ids.to(device),
|
| 33 |
do_sample=True,
|
| 34 |
top_p=0.92, #.92,
|
| 35 |
-
top_k=
|
| 36 |
no_repeat_ngram_size=no_repeat_ngram_size,
|
| 37 |
num_beams=3,
|
| 38 |
output_attentions=False,
|
|
@@ -67,7 +70,7 @@ with st.sidebar:
|
|
| 67 |
image_bytes_data = uploaded_file.getvalue()
|
| 68 |
image_upload = Image.open(BytesIO(image_bytes_data))
|
| 69 |
|
| 70 |
-
mode = st.selectbox('Mode', ('OCR', '
|
| 71 |
|
| 72 |
if image_upload:
|
| 73 |
image = image_upload
|
|
|
|
| 15 |
no_repeat_ngram_size = 10
|
| 16 |
elif mode == "Table":
|
| 17 |
prompt = "<s><s_hierarchical>"
|
| 18 |
+
no_repeat_ngram_size = 0
|
| 19 |
else:
|
| 20 |
prompt = "<s><s_hierarchical>"
|
| 21 |
no_repeat_ngram_size = 10
|
| 22 |
|
| 23 |
|
| 24 |
+
print("prompt:", prompt)
|
| 25 |
+
print("no_repeat_ngram_size:", no_repeat_ngram_size)
|
| 26 |
+
|
| 27 |
pixel_values = processor(np.array(
|
| 28 |
sample,
|
| 29 |
np.float32,
|
|
|
|
| 35 |
decoder_input_ids=processor.tokenizer(prompt, add_special_tokens=False, return_tensors="pt").input_ids.to(device),
|
| 36 |
do_sample=True,
|
| 37 |
top_p=0.92, #.92,
|
| 38 |
+
top_k=5,
|
| 39 |
no_repeat_ngram_size=no_repeat_ngram_size,
|
| 40 |
num_beams=3,
|
| 41 |
output_attentions=False,
|
|
|
|
| 70 |
image_bytes_data = uploaded_file.getvalue()
|
| 71 |
image_upload = Image.open(BytesIO(image_bytes_data))
|
| 72 |
|
| 73 |
+
mode = st.selectbox('Mode', ('OCR', 'Table', 'Element annotation'), index=2)
|
| 74 |
|
| 75 |
if image_upload:
|
| 76 |
image = image_upload
|