Commit
•
d92088b
1
Parent(s):
f6c0139
Update app.py
Browse files
app.py
CHANGED
@@ -68,17 +68,18 @@ The model is trained on a particular collection of books digitised by the Britis
|
|
68 |
tokenizer = AutoTokenizer.from_pretrained("BritishLibraryLabs/bl-books-genre")
|
69 |
|
70 |
model = AutoModelForSequenceClassification.from_pretrained("BritishLibraryLabs/bl-books-genre")
|
71 |
-
classifier = pipeline('text-classification',model=model, tokenizer=tokenizer,
|
72 |
|
73 |
|
74 |
def predict(text):
|
75 |
predictions = classifier(text)
|
76 |
-
return {pred['label']: pred['score'] for pred in predictions
|
|
|
|
|
77 |
|
78 |
gr.Interface(predict,
|
79 |
inputs=gr.inputs.Textbox(label="Book title"),
|
80 |
-
outputs=
|
81 |
-
interpretation='shap', num_shap=
|
82 |
examples=sample_text,description=description,article=article,
|
83 |
-
).launch(enable_queue=True
|
84 |
-
|
|
|
68 |
tokenizer = AutoTokenizer.from_pretrained("BritishLibraryLabs/bl-books-genre")
|
69 |
|
70 |
model = AutoModelForSequenceClassification.from_pretrained("BritishLibraryLabs/bl-books-genre")
|
71 |
+
classifier = pipeline('text-classification',model=model, tokenizer=tokenizer, top_k=10)
|
72 |
|
73 |
|
74 |
def predict(text):
|
75 |
predictions = classifier(text)
|
76 |
+
return {pred['label']: pred['score'] for pred in predictions}
|
77 |
+
|
78 |
+
|
79 |
|
80 |
gr.Interface(predict,
|
81 |
inputs=gr.inputs.Textbox(label="Book title"),
|
82 |
+
outputs='label',
|
83 |
+
interpretation='shap', num_shap=10.0, theme="huggingface",
|
84 |
examples=sample_text,description=description,article=article,
|
85 |
+
).launch(enable_queue=True)
|
|