Tumor / app.py
RANA
u1
7e3b597
from flask import Flask, render_template, request
from model import btd
import numpy as np
import cv2
app = Flask(__name__)
@app.route("/", methods=["GET", "POST"])
def index():
message = "Welcome to the API! Here are the available endpoints:"
fm_url = request.host_url + "fusion-predicition"
response = {
"message": message,
"endpoints": {
"fused_prediction": fm_url,
}
}
return response, 200
@app.route("/fusion-predicition", methods=["GET", "POST"])
def test():
result = None
if request.method == "POST":
if 'img1' not in request.files or 'img2' not in request.files or 'img3' not in request.files:
return "No file uploaded for Tumor prediction", 400
img1 = request.files['img1']
img2 = request.files['img2']
img3 = request.files['img3']
img_array1 = cv2.imdecode(np.frombuffer(
img1.read(), np.uint8), cv2.IMREAD_COLOR)
img_array2 = cv2.imdecode(np.frombuffer(
img2.read(), np.uint8), cv2.IMREAD_COLOR)
img_array3 = cv2.imdecode(np.frombuffer(
img3.read(), np.uint8), cv2.IMREAD_COLOR)
model = btd.FusedFuctionModel(img_array1, img_array2, img_array3)
response = {
"Tumor Predicition": model
}
result = response
return result
if __name__ == "__main__":
app.run(debug=True)