Spaces:
Sleeping
Sleeping
amarsaikhan
commited on
Commit
·
f5cd85c
1
Parent(s):
69431fe
update app.py file
Browse files
app.py
CHANGED
@@ -6,11 +6,11 @@ checkpoint = "openai/clip-vit-large-patch14"
|
|
6 |
classifier = pipeline(model=checkpoint, task="zero-shot-image-classification")
|
7 |
def get_best_label(predictions):
|
8 |
max_score = 0
|
9 |
-
label =
|
10 |
for p in predictions:
|
11 |
if p['score'] > max_score:
|
12 |
max_score = p['score']
|
13 |
-
label = p['label']
|
14 |
return label, max_score
|
15 |
|
16 |
st.markdown('<h1 style="color:black;">Document Classifier</h1>', unsafe_allow_html=True)
|
@@ -30,6 +30,6 @@ if upload is not None:
|
|
30 |
c2.header('Output')
|
31 |
predictions = classifier(image, candidate_labels=["invoice, receipt", "bank statement, financial statement", "credit report"])
|
32 |
label, score = get_best_label(predictions)
|
33 |
-
c2.subheader('Predicted class
|
34 |
c2.subheader('Probabilites:')
|
35 |
c2.write(str(predictions))
|
|
|
6 |
classifier = pipeline(model=checkpoint, task="zero-shot-image-classification")
|
7 |
def get_best_label(predictions):
|
8 |
max_score = 0
|
9 |
+
label = None
|
10 |
for p in predictions:
|
11 |
if p['score'] > max_score:
|
12 |
max_score = p['score']
|
13 |
+
label = str(p['label'])
|
14 |
return label, max_score
|
15 |
|
16 |
st.markdown('<h1 style="color:black;">Document Classifier</h1>', unsafe_allow_html=True)
|
|
|
30 |
c2.header('Output')
|
31 |
predictions = classifier(image, candidate_labels=["invoice, receipt", "bank statement, financial statement", "credit report"])
|
32 |
label, score = get_best_label(predictions)
|
33 |
+
c2.subheader('Predicted class: ' + str(label) + " with score: " + str(score))
|
34 |
c2.subheader('Probabilites:')
|
35 |
c2.write(str(predictions))
|