Giedrius Blazys commited on
Commit
416e479
·
1 Parent(s): a2a1cc9

first commit

Browse files
Files changed (6) hide show
  1. .gitignore +2 -0
  2. app.py +24 -0
  3. happy.jpg +0 -0
  4. my_model.h5 +3 -0
  5. requirements.txt +1 -0
  6. sad.jpg +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 = (128, 128)
5
+
6
+ # load keras model
7
+ model_path = 'my_model.h5'
8
+ model = tf.keras.models.load_model(model_path)
9
+
10
+ categories = ('happy', 'sad')
11
+
12
+ def classify_image(img):
13
+ img_array_expanded_dims = img.reshape((-1, 128, 128, 3))
14
+ prediction = model.predict(img_array_expanded_dims)
15
+ prediction_prob = float(tf.nn.sigmoid(prediction))
16
+ probs = [prediction_prob, 1-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 = ['happy.jpg', 'sad.jpg']
22
+
23
+ iface = gr.Interface(fn=classify_image, inputs=gr_image, outputs=label, examples=examples)
24
+ iface.launch(inline=False)
happy.jpg ADDED
my_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5ee3128a8b6ccdf0b26fa8c0b7caafb77f7b7c0adca4763eaf6084b436e0c595
3
+ size 13549184
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ tensorflow
sad.jpg ADDED