def _internal_service_call(self, share_data) : try: # internal : IMAGE print("■■■■■■■■■■ 이미지 분석 결과 분석 시작 ■■■■■■■■■■ ") temp = {} request_type = share_data.get_request_type() decode_text = base64.decodebytes(str.encode(share_data.get_request_data())) temp['test'] = [InMemoryUploadedFile(io.BytesIO(decode_text), None, 'test.jpg', 'image/jpeg', len(decode_text), None)] ml = MultiValueDict(temp) # fp = open("/hoya_src_root/nn00004/1/test1.jpg", 'wb') # fp.write(decode_text) # fp.close() # CNN Prediction if(request_type == "image"): return_val = PredictNetCnn().run('nn00004', None, ml ) name_tag = {"KYJ" : "김영재", "KSW" : "김승우", "LTY" : "이태영", "LSH" : "이상현", "PJH" : "백지현", "KSS" : "김수상", "PSC" : "박성찬"} print("■■■■■■■■■■ 이미지 분석 결과 분석 결과 : " + return_val['test.jpg']['key'][0]) share_data.set_output_data(name_tag[return_val['test.jpg']['key'][0]] + "인거 같은데 맞나요?") else : share_data.set_output_data("이미지 분석 결과가 없습니다") return share_data except Exception as e: raise Exception(e)
def post(self, request, type, nnid, ver): """ - desc : insert cnn configuration data """ try: if (ver == 'active'): if (type == 'w2v'): return_data = PredictNetW2V().run(nnid, request.data) elif (type == "d2v"): return_data = PredictNetD2V().run(nnid, request.data) elif (type == "cnn"): # TO-DO : need predict function for active taged version raise Exception("on developing now !") elif (type == "wdnn"): return_data = PredictNetWdnn().run(nnid, ver, request.FILES) elif (type == "seq2seq"): return_data = PredictNetSeq2Seq().run(nnid, request.data) elif (type == "autoencoder"): return_data = PredictNetAutoEncoder().run( nnid, request.data) elif (type == "renet"): #return_data = PredictNetRenet().run(nnid, ver, request.FILES) # TO-DO : need to create PredictNetRenet class first raise Exception("on developing now !") elif (type == "anomaly"): return_data = PredictNetAnomaly().run(nnid, request.data) elif (type == "wcnn"): return_data = PredictNetWcnn().run(nnid, request.data) elif (type == "bilstmcrf"): return_data = PredictNetBiLstmCrf().run(nnid, request.data) else: raise Exception("Not defined type error") else: if (type == 'w2v'): # TO-DO : need predict function for specific version raise Exception("on developing now !") elif (type == "d2v"): # TO-DO : need predict function for specific version raise Exception("on developing now !") elif (type == "cnn"): return_data = PredictNetCnn().run(nnid, ver, request.FILES) elif (type == "wdnn"): return_data = PredictNetWdnn().run(nnid, ver, request.FILES) elif (type == "seq2seq"): # TO-DO : need predict function for specific version raise Exception("on developing now !") elif (type == "renet"): return_data = PredictNetRenet().run( nnid, ver, request.FILES) else: raise Exception("Not defined type error") return Response(json.dumps(return_data)) except Exception as e: return_data = {"status": "404", "result": str(e)} return Response(json.dumps(return_data))
def post(self, request, type, nnid, ver): """ Request Deep Neural Network to predict result with given data \n input formats can be varies on type of networks \n but usually you can use it with parm input_data \n --- # Class Name : ServiceManagerPredict # Description: request predict service via rest service It caches the model and vectors on first request It may can take some time at first for caching, after than we can response the request within 1.0 sec """ try: if ver == 'active': condition = {'nn_id': nnid} ver = NNCommonManager().get_nn_info( condition)[0]['nn_wf_ver_id'] if (type == "resnet" or type == "inceptionv4"): return_data = PredictNetImage().run(nnid, ver, request) elif (type == 'w2v'): return_data = PredictNetW2V().run(nnid, request.data) elif (type == "d2v"): return_data = PredictNetD2V().run(nnid, request.data) elif (type == "cnn"): return_data = PredictNetCnn().run(nnid, ver, request.FILES) elif (type == "wdnn"): return_data = PredictNetWdnn().run(nnid, ver, request) elif (type == "seq2seq"): return_data = PredictNetSeq2Seq().run(nnid, request.data) elif (type == "autoencoder"): return_data = PredictNetAutoEncoder().run(nnid, request.data) elif (type == "anomaly"): return_data = PredictNetAnomaly().run(nnid, request.data) elif (type == "wcnn"): return_data = PredictNetWcnn().run(nnid, request.data) elif (type == "bilstmcrf"): return_data = PredictNetBiLstmCrf().run(nnid, request.data) elif (type == "ngram_mro"): return_data = PredictNetNgram().run(type, nnid, ver, request.data) elif (type == "xgboost_reg"): return_data = PredictNetXgboost().run(nnid, ver, request.FILES) return Response(return_data) except Exception as e: return_data = {"status": "404", "result": str(e)} return Response(json.dumps(return_data))
def run_chatbot_with_file(self, req_ctx): """ uplaod files :return: """ PredictNetCnn().run("", "", req_ctx)
def post(self, request, type, nnid, ver): """ Request Deep Neural Network to predict result with given data \n input formats can be varies on type of networks \n but usually you can use it with parm input_data \n --- # Class Name : ServiceManagerPredict # Description: request predict service via rest service It caches the model and vectors on first request It may can take some time at first for caching, after than we can response the request within 1.0 sec """ try: if (ver == 'active'): if (type == 'w2v'): return_data = PredictNetW2V().run(nnid, request.data) elif (type == "d2v"): return_data = PredictNetD2V().run(nnid, request.data) elif (type == "cnn"): # TO-DO : need predict function for active taged version raise Exception("on developing now !") elif (type == "wdnn"): return_data = PredictNetWdnn().run(nnid, ver, request.FILES) elif (type == "seq2seq"): return_data = PredictNetSeq2Seq().run(nnid, request.data) elif (type == "autoencoder"): return_data = PredictNetAutoEncoder().run( nnid, request.data) elif (type == "renet"): #return_data = PredictNetRenet().run(nnid, ver, request.FILES) # TO-DO : need to create PredictNetRenet class first raise Exception("on developing now !") elif (type == "anomaly"): return_data = PredictNetAnomaly().run(nnid, request.data) elif (type == "wcnn"): return_data = PredictNetWcnn().run(nnid, request.data) elif (type == "bilstmcrf"): return_data = PredictNetBiLstmCrf().run(nnid, request.data) else: raise Exception("Not defined type error") else: if (type == 'w2v'): # TO-DO : need predict function for specific version raise Exception("on developing now !") elif (type == "d2v"): # TO-DO : need predict function for specific version raise Exception("on developing now !") elif (type == "cnn"): return_data = PredictNetCnn().run(nnid, ver, request.FILES) elif (type == "wdnn"): return_data = PredictNetWdnn().run(nnid, ver, request.FILES) elif (type == "seq2seq"): # TO-DO : need predict function for specific version raise Exception("on developing now !") elif (type == "renet"): return_data = PredictNetRenet().run( nnid, ver, request.FILES) else: raise Exception("Not defined type error") return Response(json.dumps(return_data)) except Exception as e: return_data = {"status": "404", "result": str(e)} return Response(json.dumps(return_data))