Spaces:
Running
Running
example
Browse files
app.py
CHANGED
@@ -4,16 +4,13 @@ import torch
|
|
4 |
import onnxruntime as rt
|
5 |
from transformers import AutoTokenizer
|
6 |
|
7 |
-
|
8 |
tokenizer = AutoTokenizer.from_pretrained("distilroberta-base")
|
9 |
|
10 |
with open("genre_types_encoded_kaggle_onnx.json", "r") as file:
|
11 |
encode_genre_types = json.load(file)
|
12 |
|
13 |
-
|
14 |
genres = list(encode_genre_types.keys())
|
15 |
|
16 |
-
|
17 |
inf_session = rt.InferenceSession("game-classifier-quantized-kaggle.onnx")
|
18 |
input_name = inf_session.get_inputs()[0].name
|
19 |
output_name = inf_session.get_outputs()[0].name
|
@@ -27,6 +24,11 @@ def classify_game_genre(summary):
|
|
27 |
return dict(zip(genres, map(float, probs)))
|
28 |
|
29 |
|
|
|
|
|
|
|
|
|
|
|
30 |
labels = gr.outputs.Label(num_top_classes=5)
|
31 |
-
iface = gr.Interface(fn=classify_game_genre, inputs="text", outputs=labels)
|
32 |
iface.launch(inline=False)
|
|
|
4 |
import onnxruntime as rt
|
5 |
from transformers import AutoTokenizer
|
6 |
|
|
|
7 |
tokenizer = AutoTokenizer.from_pretrained("distilroberta-base")
|
8 |
|
9 |
with open("genre_types_encoded_kaggle_onnx.json", "r") as file:
|
10 |
encode_genre_types = json.load(file)
|
11 |
|
|
|
12 |
genres = list(encode_genre_types.keys())
|
13 |
|
|
|
14 |
inf_session = rt.InferenceSession("game-classifier-quantized-kaggle.onnx")
|
15 |
input_name = inf_session.get_inputs()[0].name
|
16 |
output_name = inf_session.get_outputs()[0].name
|
|
|
24 |
return dict(zip(genres, map(float, probs)))
|
25 |
|
26 |
|
27 |
+
examples = [
|
28 |
+
["March Of Soldiers is a real time strategy single player,"
|
29 |
+
"It is a military game based on the player's skill and the strength of his financial economy"]
|
30 |
+
]
|
31 |
+
|
32 |
labels = gr.outputs.Label(num_top_classes=5)
|
33 |
+
iface = gr.Interface(fn=classify_game_genre, inputs="text", outputs=labels, examples=examples)
|
34 |
iface.launch(inline=False)
|