Spaces:
Sleeping
Sleeping
MikeTrizna
commited on
Commit
•
8f09449
1
Parent(s):
74f09da
Added in handling for blank label text
Browse files
app.py
CHANGED
@@ -8,7 +8,15 @@ classifier = pipeline(model=checkpoint,
|
|
8 |
task="zero-shot-image-classification")
|
9 |
|
10 |
def shot(image, labels_text):
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
results = classifier(image,
|
13 |
candidate_labels=labels)
|
14 |
return {result["label"]: result["score"] for result in results}
|
|
|
8 |
task="zero-shot-image-classification")
|
9 |
|
10 |
def shot(image, labels_text):
|
11 |
+
if len(labels_text):
|
12 |
+
labels = labels_text.split(";")
|
13 |
+
else:
|
14 |
+
labels = ['A page of printed text',
|
15 |
+
'A page of handwritten text',
|
16 |
+
'A blank page with no text',
|
17 |
+
'A cover of a book',
|
18 |
+
'A page of a book that contains a large illustration',
|
19 |
+
'A page that features a table with multiple columns and rows']
|
20 |
results = classifier(image,
|
21 |
candidate_labels=labels)
|
22 |
return {result["label"]: result["score"] for result in results}
|