AlvinSiang commited on
Commit
a4dac84
·
verified ·
1 Parent(s): 7e07e4f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -4
app.py CHANGED
@@ -1,3 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  class_names = ['cataracts', 'diabetic retinopathy', 'glaucoma', 'normal']
2
 
3
  def predict_input_image(img):
@@ -11,7 +59,7 @@ def predict_input_image(img):
11
  # Add a batch dimension.
12
  image_tensor = tf.expand_dims(image_tensor, 0)
13
  # Normalize the data.
14
- image_tensor = image_tensor / 255.0
15
 
16
  from keras.models import load_model
17
  model = load_model('vgg16_model.keras')
@@ -20,11 +68,9 @@ def predict_input_image(img):
20
 
21
  return {class_names[i]: float(prediction[i]) for i in range(4)}
22
 
23
- import gradio as gr
24
-
25
  title=(
26
  '''<style>h1 {text-align: center;}</style>
27
- <h1> A Eye: Eye Disease Classifier </h1>'''
28
  )
29
 
30
  demo = gr.Interface(fn = predict_input_image,
 
1
+ import gradio as gr
2
+ import PIL import Image
3
+
4
+ js = """
5
+ function createGradioAnimation() {
6
+ var container = document.createElement('div');
7
+ container.id = 'gradio-animation';
8
+ container.style.fontSize = '2em';
9
+ container.style.fontWeight = 'bold';
10
+ container.style.textAlign = 'center';
11
+ container.style.marginBottom = '20px';
12
+
13
+ var text = 'Stress Prediction Model';
14
+ for (var i = 0; i < text.length; i++) {
15
+ (function(i){
16
+ setTimeout(function(){
17
+ var letter = document.createElement('span');
18
+ letter.style.opacity = '0';
19
+ letter.style.transition = 'opacity 0.5s';
20
+ letter.innerText = text[i];
21
+
22
+ container.appendChild(letter);
23
+
24
+ setTimeout(function() {
25
+ letter.style.opacity = '1';
26
+ }, 50);
27
+ }, i * 250);
28
+ })(i);
29
+ }
30
+
31
+ var gradioContainer = document.querySelector('.gradio-container');
32
+ gradioContainer.insertBefore(container, gradioContainer.firstChild);
33
+
34
+ return 'Animation created';
35
+ }
36
+ """
37
+
38
+ background = Image.open('quote.jpg')
39
+ with gr.Blocks(js=js,theme=gr.themes.Soft()) as demo:
40
+ gr.Image(background, height = '400px',interactive = False)
41
+ gr.Markdown(
42
+ '''
43
+ Eye disease could lead to vision impairment and complete blindness that affect one's ability in daily life.
44
+ Early detection and timely treatment are crucial to prevent the worsening of eye disease.
45
+ A Deep Learning Model are potential to assist ophthalmologists in giving first screening of suspected eye disease through retinal fundus images.
46
+ '''
47
+ )
48
+
49
  class_names = ['cataracts', 'diabetic retinopathy', 'glaucoma', 'normal']
50
 
51
  def predict_input_image(img):
 
59
  # Add a batch dimension.
60
  image_tensor = tf.expand_dims(image_tensor, 0)
61
  # Normalize the data.
62
+ image_tensor = image_tensor #/ 255.0
63
 
64
  from keras.models import load_model
65
  model = load_model('vgg16_model.keras')
 
68
 
69
  return {class_names[i]: float(prediction[i]) for i in range(4)}
70
 
 
 
71
  title=(
72
  '''<style>h1 {text-align: center;}</style>
73
+ <h1> A-Eye: Eye Disease Classifier </h1>'''
74
  )
75
 
76
  demo = gr.Interface(fn = predict_input_image,