Shoaib-33 commited on
Commit
69f1205
·
1 Parent(s): 61b3ffa

Upload 5 files

Browse files
README.md CHANGED
@@ -1,10 +1,10 @@
1
  ---
2
- title: Mutilabel Tv Series Classifier
3
- emoji: 🏃
4
- colorFrom: red
5
- colorTo: indigo
6
  sdk: gradio
7
- sdk_version: 4.12.0
8
  app_file: app.py
9
  pinned: false
10
  license: mit
 
1
  ---
2
+ title: Multilabel MDB TV Series Classifier
3
+ emoji: 🏢
4
+ colorFrom: purple
5
+ colorTo: pink
6
  sdk: gradio
7
+ sdk_version: 3.39.0
8
  app_file: app.py
9
  pinned: false
10
  license: mit
Tv_Series-classifier-quantized.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:85696e6c038bdd44c0b547ecb1389ea763d68ce018ad229e423fa70b57536524
3
+ size 82496318
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import onnxruntime as rt
3
+ from transformers import AutoTokenizer
4
+ import torch, json
5
+
6
+ tokenizer = AutoTokenizer.from_pretrained("distilroberta-base")
7
+
8
+ with open("genre_types_encoded.json", "r") as fp:
9
+ encode_genre_types = json.load(fp)
10
+
11
+ genres = list(encode_genre_types.keys())
12
+
13
+ inf_session = rt.InferenceSession('Tv_Series-classifier-quantized.onnx')
14
+ input_name = inf_session.get_inputs()[0].name
15
+ output_name = inf_session.get_outputs()[0].name
16
+
17
+ def classify_book_genre(description):
18
+ input_ids = tokenizer(description)['input_ids'][:512]
19
+ logits = inf_session.run([output_name], {input_name: [input_ids]})[0]
20
+ logits = torch.FloatTensor(logits)
21
+ probs = torch.sigmoid(logits)[0]
22
+ return dict(zip(genres, map(float, probs)))
23
+
24
+ label = gr.outputs.Label(num_top_classes=5)
25
+ iface = gr.Interface(fn=classify_book_genre, inputs="text", outputs=label)
26
+ iface.launch(inline=False)
27
+
genre_types_encoded.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"Action": 0, "Adventure": 1, "Drama": 2, "Comedy": 3, "Thriller": 4, "Sci-Fi": 5, "Mystery": 6, "Completed": 7, "Romance": 8, "Animation": 9, "Crime": 10, "Fantasy": 11, "Western": 12, "Sport": 13, "Horror": 14, "Music": 15, "Post-production": 16, "Filming": 17, "War": 18, "History": 19, "Biography": 20, "Family": 21, "37 min": 22, "Game-Show": 23, "Reality-TV": 24, "Short": 25, "Documentary": 26, "Musical": 27}
requirements.txt ADDED
Binary file (146 Bytes). View file