Christian Kauth commited on
Commit
b8fa518
·
1 Parent(s): 41ec723

Monicet animals model

Browse files
app.py CHANGED
@@ -1,7 +1,31 @@
1
  import gradio as gr
 
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import numpy as np
3
+ import os
4
+ import PIL
5
 
6
+ import tensorflow as tf
7
+ from tensorflow import keras
8
 
9
+ def predict(img):
10
+ img_cropped = np.array(img, dtype='float32')[:100, 15:-15, :] / 255
11
+ img_bw = np.mean(img_cropped, axis=-1)
12
+
13
+ # predict
14
+ img_input = np.expand_dims(img_bw, axis=0)
15
+ prediction = model.predict(img_input)[0]
16
+ animals = ['common bottlenose dolphin', 'fin whale', 'risso dolphin', 'short finned pilot whale', 'sperm whale']
17
+
18
+ #bw image for display
19
+ im = PIL.Image.fromarray(np.uint8(img_bw*255))
20
+
21
+ return [{animals[i]: float(prediction[i]) for i in range(len(animals))}, im]
22
+
23
+
24
+ model = keras.models.load_model('model')
25
+
26
+ iface = gr.Interface(predict,\
27
+ inputs = gr.Image(shape=(130, 120)),\
28
+ outputs = [gr.outputs.Label(num_top_classes=5),\
29
+ gr.Image(shape=(100, 100), image_mode='L')])
30
+
31
+ iface.launch()
model/keras_metadata.pb ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:98551dbae106811bc2c33bf7e0927fe5466a98d12dbd6f43ca1a2153a5cc25af
3
+ size 32822
model/saved_model.pb ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5670f4e19cd462fac3777e9334cbe9bfcefb5949c0c3ae2f1b579c26e6352d7e
3
+ size 434207
model/variables/variables.data-00000-of-00001 ADDED
Binary file (679 kB). View file
 
model/variables/variables.index ADDED
Binary file (4.26 kB). View file