Sadihsn commited on
Commit
efa0ef6
Β·
verified Β·
1 Parent(s): 65caa26

Upload 5 files

Browse files
Question-classifier-quantized.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aac525e979fd0703ce26aa728dd76b2b101a151ba3e9f96cb7f19dd66f6e5608
3
+ size 82585133
README.md CHANGED
@@ -1,13 +1,13 @@
1
  ---
2
- title: StackOverflow Question Classifier
3
- emoji: 🌍
4
- colorFrom: red
5
  colorTo: purple
6
  sdk: gradio
7
- sdk_version: 4.14.0
8
  app_file: app.py
9
  pinned: false
10
- license: mit
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Stackoverflow Question Classifier
3
+ emoji: πŸŒ–
4
+ colorFrom: indigo
5
  colorTo: purple
6
  sdk: gradio
7
+ sdk_version: 3.17.0
8
  app_file: app.py
9
  pinned: false
10
+ license: apache-2.0
11
  ---
12
 
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
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("/Users/sadihossain/Desktop/Question_Classifier/tags_types_encoded.json", "r") as fp:
9
+ encode_tags_types = json.load(fp)
10
+
11
+ Tags = list(encode_tags_types.keys())
12
+
13
+ inf_session = rt.InferenceSession('/Users/sadihossain/Desktop/Question_Classifier/Question-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_Question_tags(Summary):
18
+ input_ids = tokenizer(Summary)['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(Tags, map(float, probs)))
23
+
24
+ label = gr.outputs.Label(num_top_classes=5)
25
+ iface = gr.Interface(fn=classify_Question_tags, inputs="text", outputs=label)
26
+ iface.launch(inline=False)
27
+
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio==3.17.0
2
+ onnxruntime==1.13.1
3
+ torch==1.13.1
4
+ transformers==4.26.0
tags_types_encoded.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"java": 0, "angular": 1, "python": 2, "python-3.x": 3, "javascript": 4, "html": 5, "css": 6, "react-native": 7, "c#": 8, "ios": 9, "r": 10, "android": 11, "django": 12, "azure": 13, "reactjs": 14, "flutter": 15, "kotlin": 16, "laravel": 17, "c++": 18, "postgresql": 19, "c": 20, "sql": 21, "mysql": 22, "docker": 23, "swift": 24, "visual-studio-code": 25, "excel": 26, "typescript": 27, "pandas": 28, "node.js": 29, "spring-boot": 30, "next.js": 31, "php": 32, ".net": 33, "amazon-web-services": 34, "dart": 35}