Spaces:
Runtime error
Runtime error
Commit
·
c8d0eb9
1
Parent(s):
854d0a5
adjusted description; adjusted examples
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import gradio
|
| 2 |
import cv2
|
| 3 |
from sklearn.naive_bayes import BernoulliNB
|
|
@@ -7,7 +8,17 @@ import numpy as np
|
|
| 7 |
# multiclass_model = pickle.load(open('models/MulticlassModel_200x200', 'rb'))
|
| 8 |
ensemble_model = pickle.load(open('models/EnsembleModels_200x200', 'rb'))
|
| 9 |
|
| 10 |
-
examples = ["images/Conso.jpg", "images/Incom.jpg"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
def preprocess(img):
|
| 13 |
img = cv2.resize(img, (200,200))
|
|
@@ -23,7 +34,7 @@ def predict(img):
|
|
| 23 |
"Cons": 0,
|
| 24 |
"Publ": 4,
|
| 25 |
"Econ": 3,
|
| 26 |
-
"
|
| 27 |
|
| 28 |
proba = np.zeros((6))
|
| 29 |
for key in categories.keys():
|
|
@@ -38,7 +49,7 @@ def generate_results(proba):
|
|
| 38 |
"IDR",
|
| 39 |
"EHD",
|
| 40 |
"PLSF",
|
| 41 |
-
"
|
| 42 |
"UNKNOWN"]
|
| 43 |
|
| 44 |
scores = [0,0,0,0,0,0,0]
|
|
@@ -63,7 +74,7 @@ demo = gradio.Interface(
|
|
| 63 |
outputs=gradio.Label(),
|
| 64 |
title='Document Classification',
|
| 65 |
description='Loan Document Classification Using A Naive Bayes Classifier Ensemble',
|
| 66 |
-
article='
|
| 67 |
examples=examples)
|
| 68 |
|
| 69 |
demo.launch()
|
|
|
|
| 1 |
+
from errno import EHOSTDOWN
|
| 2 |
import gradio
|
| 3 |
import cv2
|
| 4 |
from sklearn.naive_bayes import BernoulliNB
|
|
|
|
| 8 |
# multiclass_model = pickle.load(open('models/MulticlassModel_200x200', 'rb'))
|
| 9 |
ensemble_model = pickle.load(open('models/EnsembleModels_200x200', 'rb'))
|
| 10 |
|
| 11 |
+
examples = ["images/Conso.jpg", "images/Incom.jpg",'DBF.jpg'
|
| 12 |
+
'images/DLC.jpg',
|
| 13 |
+
'images/EHD.jpg',
|
| 14 |
+
'images/IDR.jpg',
|
| 15 |
+
'images/PPD.jpg',
|
| 16 |
+
'images/PSLF.jpg',
|
| 17 |
+
'images/REA.jpg',
|
| 18 |
+
'images/SCD.jpg',
|
| 19 |
+
'images/TDD.jpg',
|
| 20 |
+
'images/TLF.jpg',
|
| 21 |
+
'images/UD.jpg']
|
| 22 |
|
| 23 |
def preprocess(img):
|
| 24 |
img = cv2.resize(img, (200,200))
|
|
|
|
| 34 |
"Cons": 0,
|
| 35 |
"Publ": 4,
|
| 36 |
"Econ": 3,
|
| 37 |
+
"Rea": 5}
|
| 38 |
|
| 39 |
proba = np.zeros((6))
|
| 40 |
for key in categories.keys():
|
|
|
|
| 49 |
"IDR",
|
| 50 |
"EHD",
|
| 51 |
"PLSF",
|
| 52 |
+
"REA",
|
| 53 |
"UNKNOWN"]
|
| 54 |
|
| 55 |
scores = [0,0,0,0,0,0,0]
|
|
|
|
| 74 |
outputs=gradio.Label(),
|
| 75 |
title='Document Classification',
|
| 76 |
description='Loan Document Classification Using A Naive Bayes Classifier Ensemble',
|
| 77 |
+
article='The purpose of this demo was to provide a simple baseline for the classification of document images. View the complete write up here https://github.com/PatrickTyBrown/document_classification/blob/main/project_writeup.pdf\n\n\nLinkedin: https://www.linkedin.com/in/patrick-ty-brown/\nGithub: https://github.com/PatrickTyBrown/document_classification\nPortfolio: https://sites.google.com/view/patrick-brown/home',
|
| 78 |
examples=examples)
|
| 79 |
|
| 80 |
demo.launch()
|