简体   繁体   English

如何在 django web 应用程序中部署机器学习模型?

[英]How to deploy a machine learning model in a django web app?

My project is the conception and realization of a web application for the detection of ransomwares based on machine learning.我的项目是基于机器学习检测勒索软件的 Web 应用程序的概念和实现。 For the realization, I made a web application with python, Django, HTML and CSS.为了实现,我用 python、Django、HTML 和 CSS 制作了一个 Web 应用程序。 On the other hand i have to create a machine learning code that makes the detection of these ransomware viruses.另一方面,我必须创建一个机器学习代码来检测这些勒索软件病毒。

Now what I have to do is deploy the machine learning code in my web app.现在我要做的是在我的网络应用程序中部署机器学习代码。 I'll explain a little how it works, the user first registers and then he chooses a csv file to scan, he uploads it and then he chooses the machine learning model he wants use and then he clicks on scan, when he clicks on scan the file will be scanned by the model he has chosen and a result will be returned to him which is either 1: the file is a ransomware or 0: it is not a ransomware.我将解释一下它是如何工作的,用户首先注册,然后他选择一个 csv 文件进行扫描,他上传它,然后他选择他想要使用的机器学习模型,然后他点击扫描,当他点击扫描该文件将由他选择的模型扫描,并返回给他的结果是 1:该文件是勒索软件或 0:它不是勒索软件。 So, I built the web app, I built the model Now my problem is how to pass user input to the model And than take the model's out put to the user.所以,我构建了网络应用程序,我构建了模型现在我的问题是如何将用户输入传递给模型而不是将模型的输出传递给用户。

Need help please.请需要帮助。

I've managed to do something like this using a deep learning model.我已经设法使用深度学习模型来做这样的事情。 It's fairly simple everything you're doing in python can be done in the django project you just have to create views and forms to handle the user data input.你在 python 中所做的一切都可以在 django 项目中完成,这相当简单,你只需要创建视图和表单来处理用户数据输入。 So you're either new to django or want the whole code snippets ?所以你要么是 django 的新手,要么想要整个代码片段?

Basically you are going to create a view like this.基本上你要创建一个像这样的视图。

def do_some_prediction_view(request,id):
    categories = Categorie.objects.exclude(name="Customized Tshirts")
    if request.method == 'POST':
        form_tshirt_size = ShirtSize(request.POST)
        if form_tshirt_size.is_valid():
            weight=form_tshirt_size.cleaned_data['weight']
            height=form_tshirt_size.cleaned_data['height']
            age=form_tshirt_size.cleaned_data['age']
            y_pr = pd.DataFrame(np.array([[weight, height, age]]),
                        columns=['weight', 'height', 'age'])
            prediction = model.predict(y_pr)[0] - 1
            return JsonResponse(classes[prediction],safe=False)
        else:
            return JsonResponse({'status':'error'})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将我的Python机器学习模型部署为Web服务 - To Deploy my Python machine learning model as web service 如何将机器学习分类器连接到Web App? - How to connect a Machine Learning classifier to a Web App? 如何在机器学习 web 应用程序中显示 output - How to display output in a machine learning web app 我们如何使用 Flask 部署机器学习 Model? - How can we deploy a Machine Learning Model using Flask? 如何部署机器学习模型以使用多个特征数据进行预测 - How to deploy machine learning model to predict with multiple feature data 如何将我的机器学习 model 从 python 移植到 java web 应用程序? - how do i port my machine learning model from python to java web app? 部署端点 model Azure 机器学习失败 - Failed deploy endpoint model Azure Machine Learning 如何使用从 Python 中的 pickle 文件加载的模型部署机器学习模型? - How to deploy machine Learning model with model loaded from pickle file in Python? 如何启动机器学习模型? - How to launch a Machine Learning model? 如何在EC2上部署机器学习模型并连接到没有Lambda的API网关? - How to deploy a machine learning model on EC2 and connect to API Gateway without Lambda?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM