Jezia commited on
Commit
76d0152
1 Parent(s): 8cdf267

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ from huggingface_hub import from_pretrained_keras
4
+
5
+ model = from_pretrained_keras('SimSiam')
6
+
7
+ index_to_name = {0:'Airplane', 1:'Car', 2:'Bird',
8
+ 3:'Cat', 4:'Deer', 5:'Dog',
9
+ 6:'Frog', 7:'Horse', 8:'Ship',
10
+ 9:'Truck'}
11
+
12
+ def predict_with_simsiam(original_image):
13
+ image = asarray(original_image)
14
+ image = np.expand_dims(image, axis=0)
15
+ pred_prob = m.predict(image).flatten().tolist()
16
+ return {index_to_name[i]: pred_prob[i] for i in range(10)}
17
+
18
+
19
+ title = "Self-supervised contrastive learning with SimSiam"
20
+ description = "This space implements a SimSiam network to the task of image classification of the Cifar 10 dataset."
21
+ examples = ['horse1.png', 'airplane4.png', 'dog6.png']
22
+ article = """<p style='text-align: center'>
23
+ <a href='https://keras.io/examples/vision/simsiam/#evaluating-our-ssl-method' target='_blank'>Keras Example given by Sayak Paul</a>
24
+ <br>
25
+ Space by @Jezia
26
+ </p>
27
+ """
28
+
29
+ iface = gr.Interface(predict_with_simsiam, inputs=[gr.inputs.Image(label="image", type="pil")], outputs="label", title=title, description=description, article=article, examples=examples)
30
+ iface.launch(debug='True')