Spaces:
Build error
Build error
App update
Browse files
app.py
CHANGED
|
@@ -14,7 +14,7 @@ inf_session = rt.InferenceSession('news-classifier-quantized.onnx')
|
|
| 14 |
input_name = inf_session.get_inputs()[0].name
|
| 15 |
output_name = inf_session.get_outputs()[0].name
|
| 16 |
|
| 17 |
-
def
|
| 18 |
input_ids = tokenizer(Body)['input_ids'][:512]
|
| 19 |
logits = inf_session.run([output_name], {input_name: [input_ids]})[0]
|
| 20 |
logits = torch.FloatTensor(logits)
|
|
@@ -22,5 +22,5 @@ def classify_book_genre(Body):
|
|
| 22 |
return dict(zip(genres, map(float, probs)))
|
| 23 |
|
| 24 |
label = gr.outputs.Label(num_top_classes=4)
|
| 25 |
-
iface = gr.Interface(fn=
|
| 26 |
iface.launch(inline=False)
|
|
|
|
| 14 |
input_name = inf_session.get_inputs()[0].name
|
| 15 |
output_name = inf_session.get_outputs()[0].name
|
| 16 |
|
| 17 |
+
def classify_news_label(Body):
|
| 18 |
input_ids = tokenizer(Body)['input_ids'][:512]
|
| 19 |
logits = inf_session.run([output_name], {input_name: [input_ids]})[0]
|
| 20 |
logits = torch.FloatTensor(logits)
|
|
|
|
| 22 |
return dict(zip(genres, map(float, probs)))
|
| 23 |
|
| 24 |
label = gr.outputs.Label(num_top_classes=4)
|
| 25 |
+
iface = gr.Interface(fn=classify_news_label, inputs="text", outputs=label)
|
| 26 |
iface.launch(inline=False)
|