forked from malgamves/DeepClassifyML
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
2,392 additions
and
69 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
from keras.applications import inception_v3,imagenet_utils | ||
from keras.models import load_model | ||
import cv2 | ||
import numpy as np | ||
from flask import Flask, request, make_response,jsonify | ||
import numpy as np | ||
import json | ||
import urllib.request | ||
from urllib.request import Request, urlopen | ||
import base64 | ||
import numpy as np | ||
from flask import Flask, render_template, request, redirect, url_for, send_from_directory | ||
import logging | ||
|
||
model = None | ||
app = Flask(__name__,static_url_path='') | ||
|
||
|
||
def preprocess_img(img,target_size=(299,299)): | ||
if (img.shape[2] == 4): | ||
img = cv2.cvtColor(img, cv2.COLOR_BGRA2BGR) | ||
img = cv2.resize(img,target_size) | ||
img = np.divide(img,255.) | ||
img = np.subtract(img,0.5) | ||
img = np.multiply(img,2.) | ||
return img | ||
|
||
def load_im_from_url(url): | ||
requested_url = urlopen(Request(url,headers={'User-Agent': 'Mozilla/5.0'})) | ||
image_array = np.asarray(bytearray(requested_url.read()), dtype=np.uint8) | ||
print (image_array.shape) | ||
print (image_array) | ||
image_array = cv2.imdecode(image_array, -1) | ||
image_array = np.expand_dims(image_array,axis=0) | ||
print (image_array.shape) | ||
return image_array | ||
|
||
def load_im_from_system(url): | ||
image_url = url.split(',')[1] | ||
image_url = image_url.replace(" ", "+") | ||
image_array = base64.b64decode(image_url) | ||
#image_array = np.asarray(bytearray(image_array), dtype=np.uint8) | ||
image_array = np.fromstring(image_array, np.uint8) | ||
image_array = cv2.imdecode(image_array, -1) | ||
return image_array | ||
|
||
def predict(img): | ||
img=preprocess_img(img) | ||
print (img.shape) | ||
global model | ||
if model is None: | ||
#model =inception_v3.InceptionV3() | ||
model = load_model('model.h5') | ||
#model.compile(optimizer='adam', loss='categorical_crossentropy') | ||
preds = model.predict(np.array([img])) | ||
return decode_predictions(preds) | ||
|
||
|
||
|
||
@app.route('/classify_system', methods=['GET']) | ||
def classify_system(): | ||
image_url = request.args.get('imageurl') | ||
image_array = load_im_from_system(image_url) | ||
resp = predict(image_array) | ||
result = [] | ||
for r in resp[0]: | ||
result.append({"class_name":r[1],"score":float(r[2])}) | ||
return jsonify({'results':result}) | ||
|
||
@app.route('/classify_url', methods=['GET']) | ||
def classify_url(): | ||
image_url = request.args.get('imageurl') | ||
image_array = load_im_from_url(image_url) | ||
resp = predict(image_array) | ||
result = [] | ||
for r in resp[0]: | ||
result.append({"class_name":r[1],"score":float(r[2])}) | ||
return jsonify({'results':result}) | ||
|
||
|
||
|
||
@app.route('/classify-system', methods=['GET']) | ||
def do_system(): | ||
return app.send_static_file('system.html') | ||
|
||
@app.route('/classify-url', methods=['GET']) | ||
def do_url(): | ||
return app.send_static_file('url.html') | ||
|
||
@app.route('/', methods=['GET']) | ||
def root(): | ||
return app.send_static_file('index.html') | ||
|
||
if __name__ == '__main__': | ||
app.run(host='0.0.0.0', port=8080, debug=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2015, Vincent Garreau | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "particles.js", | ||
"main": "particles.js", | ||
"homepage": "https://github.com/VincentGarreau/particles.js", | ||
"authors": [ | ||
"Vincent Garreau <[email protected]>" | ||
], | ||
"description": "A lightweight JavaScript library for creating particles.", | ||
"keywords": [ | ||
"particle", | ||
"particles" | ||
], | ||
"license": "MIT", | ||
"ignore": [ | ||
"**/.*", | ||
"node_modules", | ||
"bower_components", | ||
"test", | ||
"tests" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* ============================================================================= | ||
HTML5 CSS Reset Minified - Eric Meyer | ||
========================================================================== */ | ||
|
||
html,body,div,span,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,abbr,address,cite,code,del,dfn,em,img,ins,kbd,q,samp,small,strong,sub,sup,var,b,i,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline} | ||
body{line-height:1} | ||
article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block} | ||
nav ul{list-style:none} | ||
blockquote,q{quotes:none} | ||
blockquote:before,blockquote:after,q:before,q:after{content:none} | ||
a{margin:0;padding:0;font-size:100%;vertical-align:baseline;background:transparent;text-decoration:none} | ||
del{text-decoration:line-through} | ||
abbr[title],dfn[title]{border-bottom:1px dotted;cursor:help} | ||
table{border-collapse:collapse;border-spacing:0} | ||
hr{display:block;height:1px;border:0;border-top:1px solid #ccc;margin:1em 0;padding:0} | ||
input,select{vertical-align:middle} | ||
li{list-style:none} | ||
|
||
|
||
/* ============================================================================= | ||
My CSS | ||
========================================================================== */ | ||
|
||
/* ---- base ---- */ | ||
|
||
html,body{ | ||
width:100%; | ||
height:100%; | ||
background: white; | ||
} | ||
|
||
html{ | ||
-webkit-tap-highlight-color: rgba(0, 0, 0, 0); | ||
} | ||
|
||
body{ | ||
font:normal 75% Arial, Helvetica, sans-serif; | ||
} | ||
|
||
canvas{ | ||
display:block; | ||
vertical-align:bottom; | ||
} | ||
|
||
|
||
/* ---- stats.js ---- */ | ||
|
||
.count-particles{ | ||
background: #000022; | ||
position: absolute; | ||
top: 48px; | ||
left: 0; | ||
width: 80px; | ||
color: #13E8E9; | ||
font-size: .8em; | ||
text-align: left; | ||
text-indent: 4px; | ||
line-height: 14px; | ||
padding-bottom: 2px; | ||
font-family: Helvetica, Arial, sans-serif; | ||
font-weight: bold; | ||
} | ||
|
||
.js-count-particles{ | ||
font-size: 1.1em; | ||
} | ||
|
||
#stats, | ||
.count-particles{ | ||
-webkit-user-select: none; | ||
margin-top: 5px; | ||
margin-left: 5px; | ||
} | ||
|
||
#stats{ | ||
border-radius: 3px 3px 0 0; | ||
overflow: hidden; | ||
} | ||
|
||
.count-particles{ | ||
border-radius: 0 0 3px 3px; | ||
} | ||
|
||
|
||
/* ---- particles.js container ---- */ | ||
|
||
#particles-js{ | ||
width: 100%; | ||
height: 100%; | ||
background-color: #000022; | ||
background-image: url(''); | ||
background-size: cover; | ||
background-position: 50% 50%; | ||
background-repeat: no-repeat; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,91 @@ | ||
<html> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<link href="https://fonts.googleapis.com/css?family=PT+Sans:400i" rel="stylesheet"> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> | ||
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script> | ||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> | ||
<link rel="stylesheet" href="css/custom.css"> | ||
<title>DeepClassifyML</title> | ||
<meta charset="utf-8" /> | ||
<title>Respiratory Buddy</title> | ||
<meta | ||
name="description" | ||
content="particles.js is a lightweight JavaScript library for creating particles." | ||
/> | ||
<meta | ||
name="viewport" | ||
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" | ||
/> | ||
<link rel="stylesheet" media="screen" href="css/style.css" /> | ||
<link | ||
href="https://fonts.googleapis.com/css?family=PT+Sans:400i" | ||
rel="stylesheet" | ||
/> | ||
<link | ||
rel="stylesheet" | ||
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" | ||
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" | ||
crossorigin="anonymous" | ||
/> | ||
<script | ||
src="https://code.jquery.com/jquery-3.2.1.min.js" | ||
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" | ||
crossorigin="anonymous" | ||
></script> | ||
<script | ||
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" | ||
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" | ||
crossorigin="anonymous" | ||
></script> | ||
<link rel="stylesheet" href="css/custom.css" /> | ||
<title>Radiology Buddy</title> | ||
</head> | ||
<body id="main"> | ||
<div class="container"> | ||
<div id="particles-js" class="container"> | ||
<div class="over"> | ||
<div id="top"> | ||
<h2>Respiratory Condition Diagnosis Made Easy</h4> | ||
</div> | ||
|
||
<div class="fixed-background"> | ||
<img src="../assets/background.jpg" height="100%" width="100%"> | ||
</div> | ||
<br /><br /> | ||
|
||
</div> | ||
<div class = "over"> | ||
<div id = "top"> | ||
<h4>Image Recogntion Made Easy</h4> | ||
</div> | ||
<div id="middle"> | ||
<h1>Respiratory Buddy</h1> | ||
<h4>AI for Good</h6> | ||
</div> | ||
|
||
<br><br> | ||
<br /><br /> | ||
|
||
<div id = "middle"> | ||
<h1>DeepClassifyML</h1> | ||
<h6>Artificial Intelligence with a Vision</h6> | ||
<div id="last"> | ||
<h2><a href="/classify-url" style="color: white; font-size: 60px">Diagnose</a></h2> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<!-- particles.js container --> | ||
|
||
<br><br> | ||
<!-- scripts --> | ||
<script src="../particles.js"></script> | ||
<script src="js/app.js"></script> | ||
|
||
<div id ="last"> | ||
<h2><a href="/classify-url">GET STARTED</a></h2> | ||
</div> | ||
</div> | ||
<footer><center> Powered By - <b><a href="https://hasura.io">Hasura</a></b> </center></footer> | ||
<!-- stats.js --> | ||
<script> | ||
var count_particles, stats, update; | ||
stats = new Stats(); | ||
stats.setMode(0); | ||
stats.domElement.style.position = "absolute"; | ||
stats.domElement.style.left = "0px"; | ||
stats.domElement.style.top = "0px"; | ||
document.body.appendChild(stats.domElement); | ||
count_particles = document.querySelector(".js-count-particles"); | ||
update = function() { | ||
stats.begin(); | ||
stats.end(); | ||
if ( | ||
window.pJSDom[0].pJS.particles && | ||
window.pJSDom[0].pJS.particles.array | ||
) { | ||
count_particles.innerText = | ||
window.pJSDom[0].pJS.particles.array.length; | ||
} | ||
requestAnimationFrame(update); | ||
}; | ||
requestAnimationFrame(update); | ||
</script> | ||
</body> | ||
</html> | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
Oops, something went wrong.