mayerantoine commited on
Commit
cefd102
·
1 Parent(s): 96aa427

Add application file and mode file

Browse files
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ import numpy as np
4
+ import tensorflow as tf
5
+ from tensorflow.keras import models
6
+
7
+ IMG_SIZE = 300
8
+ class_names = ['none','mild','severe']
9
+
10
+ cwd = os.getcwd()
11
+ outpath= os.path.join(cwd,"model")
12
+ model_name = 'cross_event_ecuador_efficientnet_1643984852.h5'
13
+ loaded_model = models.load_model(os.path.join(outpath,model_name))
14
+
15
+ def _classifier(inp):
16
+ img = np.asarray(tf.cast(inp, dtype=tf.float32)) * 1 / 255.0
17
+ img = img.reshape((-1, IMG_SIZE, IMG_SIZE, 3))
18
+ preds = loaded_model.predict(img).flatten()
19
+ return {class_names[i]:float(preds[i]) for i in range(len(class_names))}
20
+
21
+ iface = gr.Interface(fn=_classifier,
22
+ inputs=gr.inputs.Image(shape=(IMG_SIZE, IMG_SIZE)),
23
+ outputs=gr.outputs.Label()
24
+ )
25
+
26
+ iface.launch()
model/cross_event_ecuador_efficientnet_1643984852.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b38a2aa64ecee1e19e897341f346f14c788424db8838e8498d882c549de9e93b
3
+ size 43817776
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ tensorflow==2.7.1
2
+ numpy==1.19.5