Python ModuleNotFoundError: нет модуля с именем 'returndata' - PullRequest
0 голосов
/ 04 октября 2019

Я создал модель в 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)

Я не знаю, как решить эту проблему. Кто-нибудь может мне помочь? Заранее большое спасибо.

Что мне изменить?

1 Ответ

0 голосов
/ 04 октября 2019

Вы действительно используете "returndata" и "TOPIC_DICT = Content ()"?

Python не может импортировать этот модуль. Либо установите его, либо укажите правильный путь для импорта модуля.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...