コード例 #1
0
 def __init__(self, cb_id, ner_model_id):
     """
     init global variables
     """
     self.cb_id = cb_id
     self.ner_model_id = ner_model_id
     self.bilstmcrf_model = PredictNetBiLstmCrf()
コード例 #2
0
    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))
コード例 #3
0
    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))
コード例 #4
0
    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))