File size: 1,423 Bytes
7e3b597 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
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)
|