File size: 537 Bytes
d0eb713
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import gradio as gr
import numpy as np
from huggingface_hub import from_pretrained_keras

siamese = from_pretrained_keras("rushic24/keras-siamese-contrastive")

def predict_image(img1, img2):
  assert img1.shape == (28, 28)
  assert img1.shape == img2.shape
  print('img 1 shape', img1.shape)
  img1 = np.expand_dims(img1, 0)
  img2 = np.expand_dims(img2, 0)
  lab = str(siamese.predict([img1, img2])[0][0])
  return lab

iface = gr.Interface(predict_image, inputs=["sketchpad", "sketchpad"], outputs="label")
iface.launch(debug='True')