![Image is not seen](https://i.stack.imgur.com/Od3PT.png)
Я перепробовал все возможности, но когда я нажимаю кнопку, на ней не отображается изображение, которое я динамически взял из локального p c. Is имеет от 3 до 4 app-маршрутов с 3 - 4 различными Html. (Один был bs. html). В этом у меня есть два модуля: один для определения сегментации тела и другой для обнаружения опухоли головного мозга. app.py
model = tf.keras.models.load_model("CNN1.model")
the_model = torch.load('cnn.pt')
app = Flask(__name__,instance_relative_config=True, static_url_path = "/static", static_folder = "static")
UPLOAD_FOLDER = './static'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
def prepare(file): #image-processing for body segmentation
---------
---------
return sample_array
def transform(file): #image-processing for brain tumor
----------
----------
return img_t
@app.route('/')
def index():
# Main page
return render_template('RCnn.html')
@app.route('/body_seg')
def body_seg():
return render_template('bs1.html')
@app.route('/brain_t')
def brain_t():
return render_template('brain1.html')
@app.route('/body', methods=['POST','GET']) #to detect body segmentation parts
def body():
if request.method =='POST':
file1 = request.files['file']
if file1:
filename = secure_filename(file1.filename)
# task 1. let's get a clear path
path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
path = os.path.abspath(path)
# task 2. make sure the folder exists
folder = os.path.dirname(path)
if not os.path.isdir(folder):
raise IOError('no such folder: %s' % folder)
file1.save(path)
abc=prepare(os.path.join(app.config['UPLOAD_FOLDER'],filename))
uploadimage=file1.filename
prediction = model.predict(abc)
return render_template('bs1.html',image=uploadimage, data=data2, data3=data3)
@app.route('/brain', methods=['POST','GET']) #module to detect brain tumor
def brain():
if request.method =='POST':
file1 = request.files['file']
if file1:
filename = secure_filename(file1.filename)
# task 1. let's get a clear path
path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
path = os.path.abspath(path)
# task 2. make sure the folder exists
folder = os.path.dirname(path)
if not os.path.isdir(folder):
raise IOError('no such folder: %s' % folder)
file1.save(path)
#torch.save(model_conv,'cnn.pt')
the_model = torch.load('cnn.pt')
img_t = transform(os.path.join(app.config['UPLOAD_FOLDER'],filename))
uploadimage1=file1.filename
batch_t = torch.unsqueeze(img_t, 0)
out = the_model(batch_t)
return render_template('brain1.html',image1=uploadimage1,data=data4, data3=data5)
if __name__ == '__main__':
app.run(debug=True, use_reloader=False)
bs. html
</style>
</head>
<body bgcolor = "#ffeee6">
<h1><center><u>Radiological Image Classification</u></center></h1>
<h2><u>Body Part Segment Detection </u></h2>
<p><bold>Upload your Radiological image with different body parts: </bold></p>
<form action = "/body" method ='POST' enctype=multipart/form-data>
<input type="file" name="file" >
<input type="submit" value="upload" >
<h3><u>Results</u></h3>
<img src="{{url_for('static',filename = image)}}" align="middle" style="width:150px"/>
<p>{{data}}</p>
<p>{{data3}}</p>
</form>