Giedrius Blazys commited on
Commit
c34536f
1 Parent(s): 2fb5cdc

first commit

Browse files
Files changed (7) hide show
  1. .gitignore +2 -0
  2. app.py +24 -0
  3. banana_model.h5 +3 -0
  4. green.jpeg +0 -0
  5. requirements.txt +1 -0
  6. ripe.jpeg +0 -0
  7. unknown.jpeg +0 -0
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ .DS_Store
2
+ .ipynb_checkpoints/
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import tensorflow as tf
3
+
4
+ IMG_SIZE = (120, 120)
5
+
6
+ # load keras model
7
+ model_path = 'banana_model.h5'
8
+ model = tf.keras.models.load_model(model_path)
9
+
10
+ categories = ('ripe', 'unripe')
11
+
12
+ def classify_image(img):
13
+ img_array_expanded_dims = img.reshape((-1, 120, 120, 3))
14
+ prediction = model.predict(img_array_expanded_dims)
15
+ prediction_prob = float(tf.nn.sigmoid(prediction))
16
+ probs = [1-prediction_prob, prediction_prob]
17
+ return dict(zip(categories, probs))
18
+
19
+ gr_image = gr.inputs.Image(shape=IMG_SIZE)
20
+ label = gr.outputs.Label()
21
+ examples = ['ripe.jpeg', 'green.jpeg', 'unknown.jpeg']
22
+
23
+ iface = gr.Interface(fn=classify_image, inputs=gr_image, outputs=label, examples=examples)
24
+ iface.launch(inline=False)
banana_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:572dc383e5c8e16e8d9e294b2b8fff70bef4babdcb056f65881c372d708aab6d
3
+ size 13548640
green.jpeg ADDED
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ tensorflow
ripe.jpeg ADDED
unknown.jpeg ADDED