-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwsgi.py
29 lines (23 loc) · 849 Bytes
/
wsgi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# wsgi.py
import torch
import wget
from app.classifier import Classifier
from app import create_app
import math
def bar_custom(current, total, width=80):
width=30
avail_dots = width-2
shaded_dots = int(math.floor(float(current) / total * avail_dots))
percent_bar = '[' + '■'*shaded_dots + ' '*(avail_dots-shaded_dots) + ']'
progress = "%d%% %s [%d / %d]" % (current / total * 100, percent_bar, current, total)
return progress
use_cuda = torch.cuda.is_available()
wget.download(
url="https://malware-detection.s3.ap-northeast-2.amazonaws.com/detector_sectionInfo_allData.prm",
out="./model/"
)
file = "./model/detector_sectionInfo_allData.prm"
params = torch.load(file,map_location=torch.device('cpu'))
classifier = Classifier(params)
app = create_app(classifier)
app.run(host='0.0.0.0', port=8000, debug=True)