Spaces:
Sleeping
Sleeping
João Pedro
commited on
Commit
·
5639711
1
Parent(s):
b5975ad
use sequence classifier and print encoding
Browse files
app.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from transformers import LayoutLMv3Processor,
|
| 3 |
from pdf2image import convert_from_bytes
|
| 4 |
from PIL import Image
|
| 5 |
|
| 6 |
# Load model and processor
|
| 7 |
processor = LayoutLMv3Processor.from_pretrained("microsoft/layoutlmv3-base")
|
| 8 |
-
model =
|
| 9 |
|
| 10 |
st.title("Document Classification with LayoutLMv3")
|
| 11 |
|
|
@@ -26,6 +26,7 @@ if uploaded_file:
|
|
| 26 |
st.image(image, caption=f'Uploaded Image {i}', use_container_width=True)
|
| 27 |
# Prepare image for model input
|
| 28 |
encoding = processor(image, return_tensors="pt")
|
|
|
|
| 29 |
outputs = model(**encoding)
|
| 30 |
predictions = outputs.logits.argmax(-1)
|
| 31 |
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from transformers import LayoutLMv3Processor, LayoutLMv3ForSequenceClassification
|
| 3 |
from pdf2image import convert_from_bytes
|
| 4 |
from PIL import Image
|
| 5 |
|
| 6 |
# Load model and processor
|
| 7 |
processor = LayoutLMv3Processor.from_pretrained("microsoft/layoutlmv3-base")
|
| 8 |
+
model = LayoutLMv3ForSequenceClassification.from_pretrained("microsoft/layoutlmv3-base")
|
| 9 |
|
| 10 |
st.title("Document Classification with LayoutLMv3")
|
| 11 |
|
|
|
|
| 26 |
st.image(image, caption=f'Uploaded Image {i}', use_container_width=True)
|
| 27 |
# Prepare image for model input
|
| 28 |
encoding = processor(image, return_tensors="pt")
|
| 29 |
+
st.text(f'encoding: {encoding}')
|
| 30 |
outputs = model(**encoding)
|
| 31 |
predictions = outputs.logits.argmax(-1)
|
| 32 |
|