Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

editing req files #1

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified BrainTumorDetection.h5
Binary file not shown.
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: python app.py
web: python app.py
3 changes: 3 additions & 0 deletions To-Do
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Add auto-deleter for images
optimize model
add useful tips
17 changes: 6 additions & 11 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
from flask import Flask, request, render_template, jsonify
from flask_cors import CORS

from utils import *


app = Flask(__name__)
CORS(app)

__model = None


@app.route("/")
def home():
return render_template("index.html")


@app.route("/predict", methods=['POST'])
def predict():
try:
data = request.files["myFile"]
data.save(f"data/{data.filename}")
result = predict_the_pic(f"data/{data.filename}", model=__model)
result = make_final_result(result=result)
return jsonify({"Result": result})
data = request.files["myFile"]
data.save(f"data/{data.filename}")
result = predict_the_pic(f"data/{data.filename}", model=__model)
result = make_final_result(result=result)
return jsonify({"Result": result})
except:
return jsonify({"Result" : "An Error Occurred"})

Expand All @@ -31,4 +26,4 @@ def predict():

__model = return_model()

app.run(host='0.0.0.0', port=5000)
app.run()
7 changes: 3 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
gunicorn
Flask
flask_cors
pandas
keras
numpy
opencv-python
pillow
tensorflow
keras
opencv-python-headless
6 changes: 1 addition & 5 deletions utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from keras.models import load_model
import cv2
from PIL import Image
import numpy



from keras.models import load_model

def return_model():
model = load_model("BrainTumorDetection.h5")
Expand All @@ -16,7 +13,6 @@ def make_final_result(result):
else:
return "OK"


def predict_the_pic(picture,model):

image = cv2.imread(picture)
Expand Down