This commit is contained in:
Pünkösd Marcell 2021-11-23 19:58:56 +01:00
parent ad7a48de4c
commit dd2a3cfff5
2 changed files with 8 additions and 10 deletions

View File

@ -2,11 +2,11 @@
import sentry_sdk
import os
import requests
import tempfile
import numpy
import json
import uwsgi
import pickle
from urllib.parse import urljoin
from config import Config
from pyAudioAnalysis.audioTrainTest import load_model, load_model_knn, classifier_wrapper
from pyAudioAnalysis import audioBasicIO
@ -41,13 +41,13 @@ class ModelMemer:
r.raise_for_status()
self.model_details = r.json()
r = requests.get(self.model_details['files']['model'])
r = requests.get(urljoin(Config.MODEL_INFO_URL,self.model_details['files']['model']))
r.raise_for_status()
with open(model_file, 'wb') as f:
f.write(r.content)
r = requests.get(self.model_details['files']['means'])
r = requests.get(urljoin(Config.MODEL_INFO_URL,self.model_details['files']['means']))
r.raise_for_status()
with open(means_file, 'wb') as f:
@ -109,7 +109,7 @@ def main():
while True:
message = uwsgi.mule_get_msg()
task = json.loads(message)
task = pickle.loads(message)
audio_file_path = task['audio_file_path']
description = task['description']
try:

View File

@ -1,19 +1,17 @@
#!/usr/bin/env python3
import tempfile
from flask import jsonify, request, abort, current_app, Response
from flask import request, abort, current_app, Response
from flask_classful import FlaskView
from utils import json_required
import opentracing
from schemas import SampleSchema
import json
import uwsgi
import pickle
class FilterView(FlaskView):
sampleschema = SampleSchema(many=False)
@json_required
def post(self):
if current_app.config.get('DROPALL'):
return Response(status=200)
@ -46,6 +44,6 @@ class FilterView(FlaskView):
"description": desc
}
uwsgi.mule_msg(json.dumps(task))
uwsgi.mule_msg(pickle.dumps(task))
return Response(status=200)