Commit
·
c7ba2d7
1
Parent(s):
85d1447
App created
Browse files- app.py +55 -0
- bert_quantized.onnx +3 -0
- encoded_keywords.json +1 -0
- requirements.txt +0 -0
app.py
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""app_creation.ipynb
|
3 |
+
|
4 |
+
Automatically generated by Colaboratory.
|
5 |
+
|
6 |
+
Original file is located at
|
7 |
+
https://colab.research.google.com/drive/1sguK4GohScbDFj7Toyodw7faqhPrfc1a
|
8 |
+
"""
|
9 |
+
|
10 |
+
import json
|
11 |
+
import torch
|
12 |
+
import gradio as gr
|
13 |
+
import onnxruntime as rt
|
14 |
+
from transformers import AutoTokenizer
|
15 |
+
|
16 |
+
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
|
17 |
+
|
18 |
+
with open("encoded_keywords.json", "r") as fp:
|
19 |
+
encode_keywords = json.load(fp)
|
20 |
+
|
21 |
+
keywords = list(encode_keywords.keys())
|
22 |
+
|
23 |
+
inf_session = rt.InferenceSession('bert_quantized.onnx')
|
24 |
+
input_name = inf_session.get_inputs()[0].name
|
25 |
+
output_name = inf_session.get_outputs()[0].name
|
26 |
+
|
27 |
+
def classify_keywords(abstract):
|
28 |
+
input_ids = tokenizer(abstract)['input_ids'][:512]
|
29 |
+
|
30 |
+
logits = inf_session.run([output_name], {
|
31 |
+
input_name: [input_ids]
|
32 |
+
})[0]
|
33 |
+
|
34 |
+
logits = torch.FloatTensor(logits)
|
35 |
+
|
36 |
+
probs = torch.sigmoid(logits)[0]
|
37 |
+
|
38 |
+
return dict(zip(keywords, map(float, probs)))
|
39 |
+
|
40 |
+
label = gr.Label(num_top_classes = 5)
|
41 |
+
|
42 |
+
interface = gr.Interface(
|
43 |
+
fn = classify_keywords,
|
44 |
+
inputs = "text",
|
45 |
+
outputs = label
|
46 |
+
)
|
47 |
+
|
48 |
+
interface.launch()
|
49 |
+
|
50 |
+
|
51 |
+
|
52 |
+
|
53 |
+
|
54 |
+
|
55 |
+
|
bert_quantized.onnx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:73344e20c1ec07be292749f4d93458442ba9dd103ee7f81caeb1c6dd49eb965c
|
3 |
+
size 110398163
|
encoded_keywords.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"internet of things": 0, "privacy": 1, "blockchain": 2, "machine learning": 3, "prediction algorithms": 4, "biological system modeling": 5, "security": 6, "5g mobile communication": 7, "cloud computing": 8, "wireless communication": 9, "wireless sensor networks": 10, "antenna arrays": 11, "bandwidth": 12, "imaging": 13, "remote sensing": 14, "computational modeling": 15, "neural networks": 16, "task analysis": 17, "predictive models": 18, "deep learning": 19, "training": 20, "testing": 21, "support vector machines": 22, "databases": 23, "artificial intelligence": 24, "logic gates": 25, "servers": 26, "computer architecture": 27, "feature extraction": 28, "optimization": 29, "data mining": 30, "real-time systems": 31, "convergence": 32, "convolution": 33, "convolutional neural networks": 34, "optical fiber communication": 35, "radio frequency": 36, "modulation": 37, "algorithm design and analysis": 38, "data models": 39, "monitoring": 40, "time series analysis": 41, "convolutional neural network": 42, "classification algorithms": 43, "object detection": 44, "detectors": 45, "strain": 46, "standards": 47, "solid modeling": 48, "buildings": 49, "planning": 50, "sensors": 51, "urban areas": 52, "energy consumption": 53, "analytical models": 54, "protocols": 55, "quality of service": 56, "switches": 57, "ofdm": 58, "indexes": 59, "optical transmitters": 60, "clustering algorithms": 61, "reliability": 62, "resource management": 63, "measurement": 64, "ions": 65, "atmospheric modeling": 66, "batteries": 67, "estimation": 68, "integrated circuit modeling": 69, "mathematical model": 70, "renewable energy sources": 71, "heuristic algorithms": 72, "sociology": 73, "performance evaluation": 74, "visualization": 75, "shape": 76, "image segmentation": 77, "three-dimensional displays": 78, "hyperspectral imaging": 79, "spatial resolution": 80, "kernel": 81, "encryption": 82, "temperature sensors": 83, "temperature measurement": 84, "control systems": 85, "optical sensors": 86, "software": 87, "generators": 88, "resistance": 89, "receivers": 90, "modeling": 91, "couplings": 92, "robots": 93, "image reconstruction": 94, "adaptation models": 95, "voltage control": 96, "genetic algorithms": 97, "signal to noise ratio": 98, "semantics": 99, "power generation": 100, "trajectory": 101, "routing": 102, "synthetic aperture radar": 103, "radar": 104, "power system stability": 105, "stability analysis": 106, "interference": 107, "cameras": 108, "rotors": 109, "mathematical models": 110, "delays": 111, "synthetic aperture radar (sar)": 112, "robustness": 113, "satellites": 114, "image color analysis": 115, "electroencephalography": 116, "reactive power": 117, "topology": 118, "legged locomotion": 119, "load modeling": 120, "antennas": 121, "correlation": 122, "force": 123, "complexity theory": 124, "absorption": 125, "decoding": 126, "impedance": 127, "brain modeling": 128, "sensitivity": 129, "optical imaging": 130, "uncertainty": 131, "substrates": 132, "roads": 133, "simulation": 134, "optical fiber sensors": 135, "stress": 136, "encoding": 137, "laser beams": 138, "electrodes": 139, "metals": 140, "earth": 141, "power systems": 142, "numerical models": 143, "relays": 144, "torque": 145, "cavity resonators": 146, "scattering": 147, "lighting": 148, "costs": 149, "light emitting diodes": 150, "optical fibers": 151, "photonics": 152, "silicon": 153, "frequency modulation": 154, "optical receivers": 155, "optical filters": 156, "nonlinear optics": 157, "optical waveguides": 158, "adaptive optics": 159, "optical polarization": 160, "optical fiber polarization": 161, "educational institutions": 162, "vectors": 163, "equations": 164}
|
requirements.txt
ADDED
Binary file (170 Bytes). View file
|
|