我在Python中创建了一个模型,用于根据图像预测结果,运行它时会得到以下错误:
以下错误:
(base) MacBook-Air:Backend desktop$ python main.py
Traceback (most recent call last):
File "main.py", line 3, in <module>
from returndata import Content
ModuleNotFoundError: No module named 'returndata',我找不到任何相关的东西。,这是我的模型的代码:app.py:
import os
from flask import *
from returndata import Content
import predict as pred
from werkzeug.utils import secure_filename
UPLOAD_FOLDER = './static/UPLOADFOLDER'
ALLOWED_EXTENSIONS = set(['png', 'jpg', 'jpeg', 'bmp'])
TOPIC_DICT = Content()
app = Flask(__name__)
app._static_folder = "static"
@app.route('/')
def homepage():
return render_template("index.html")
@app.route('/skin/')
def skin():
return render_template("skinLesion.html")
@app.route('/retinopathy/')
def retinopathy():
return render_template("retinopathy.html")
@app.route('/upload/', methods=["POST"])
def upload():
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
if request.method == 'POST':
# check if the post request has the file part
if 'file' not in request.files:
print(request.files)
d = Response("Error",status=201,mimetype='application/json')
return d
file = request.files['file']
# if user does not select file, browser also
# submit a empty part without filename
if file.filename == '':
d = Response("No filename",status=201,mimetype='application/json')
return d
if file:
filename = secure_filename(file.filename)
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
return pred.classify(filename, response=True)
@app.route('/uploadPC/', methods=["POST"])
def uploadPC():
print("in upload")
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
if request.method == 'POST':
# check if the post request has the file part
if 'file' not in request.files:
print(request.files)
d = Response("Error",status=201,mimetype='application/json')
return d
file = request.files['file']
# if user does not select file, browser also
# submit a empty part without filename
if file.filename == '':
d = Response("No filename",status=201,mimetype='application/json')
return d
if file:
filename = secure_filename(file.filename)
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
category, confidence = pred.classify(filename, response=False)
print(category, confidence)
confidence = '%.2f'%(confidence*100)
if category == "malignant":
return render_template("malignant.html", confidence=confidence)
else:
return render_template("benign.html", confidence=confidence)
@app.route('/uploadDiabetic/', methods=["POST"])
def uploadDiabetic():
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
if request.method == 'POST':
# check if the post request has the file part
if 'file' not in request.files:
print(request.files)
d = Response("Error",status=201,mimetype='application/json')
return d
file = request.files['file']
# if user does not select file, browser also
# submit a empty part without filename
if file.filename == '':
d = Response("No filename",status=201,mimetype='application/json')
return d
if file:
filename = secure_filename(file.filename)
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
return pred.classify_retino(filename, response=True)我不知道如何解决这个问题。有人能帮我吗?在此之前,非常感谢您。
我该给你换什么?
发布于 2019-10-04 20:08:12
您实际使用的是"returndata“和"TOPIC_DICT = Content()”吗?
Python不能导入这个模块。要么安装它,要么给出正确的路径,从哪里导入模块。
https://stackoverflow.com/questions/58242524
复制相似问题