Spaces:
Running
Running
Test updates
Browse files
app.py
CHANGED
@@ -117,24 +117,26 @@ def predict(image, reader, processor: LayoutLMv3Processor, model: LayoutLMv3ForS
|
|
117 |
predicted_class = logits.argmax()
|
118 |
probabilities = F.softmax(logits, dim=-1).flatten().tolist()
|
119 |
return predicted_class.detach().item(), probabilities
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
|
|
|
|
140 |
|
|
|
117 |
predicted_class = logits.argmax()
|
118 |
probabilities = F.softmax(logits, dim=-1).flatten().tolist()
|
119 |
return predicted_class.detach().item(), probabilities
|
120 |
+
|
121 |
+
st.markdown(f"Test")
|
122 |
+
|
123 |
+
# reader = create_ocr_reader()
|
124 |
+
# processor = create_processor()
|
125 |
+
# model = create_model()
|
126 |
+
|
127 |
+
# uploaded_file = st.file_uploader("Choose a JPG file", ["jpg", "png"])
|
128 |
+
# if uploaded_file is not None:
|
129 |
+
# bytes_data = io.BytesIO(uploaded_file.read())
|
130 |
+
# image = Image.open(bytes_data)
|
131 |
+
# st.image(image, caption="Uploaded Image", use_column_width=True)
|
132 |
+
# predicted, probabilities = predict(image, reader, processor, model)
|
133 |
+
# predicted_label = model.config.id2label[predicted]
|
134 |
+
# st.markdown(f"Predicted Label: {predicted_label}")
|
135 |
+
|
136 |
+
# df = pd.DataFrame({
|
137 |
+
# "Label": list(model.config.id2label.values()),
|
138 |
+
# "Probability": probabilities
|
139 |
+
# })
|
140 |
+
# fig = px.bar(df, x="Label", y="Probability")
|
141 |
+
# st.plotly_chart(fig, use_container_width=True)
|
142 |
|