File size: 745 Bytes
525f3dd
e3cece8
40fa99d
a75241a
cffbee3
 
e3cece8
a75241a
 
5b0a672
525f3dd
ed88d55
 
a75241a
7854bc4
ed88d55
525f3dd
67022df
 
ed88d55
 
67022df
ed88d55
3e75f70
ed88d55
3e75f70
525f3dd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import gradio as gr
import tensorflow as tf
import numpy as np
import cv2
from huggingface_hub import from_pretrained_keras


def resize_image(img_in,input_height,input_width):
    return cv2.resize( img_in, ( input_width,input_height) ,interpolation=cv2.INTER_NEAREST)


def greet(image):
    model = from_pretrained_keras("vahidrezanezhad/sbb_binarization")
    image = resize_image(image, 224,448)
    prediction = model.predict(image.reshape(1,224,448,image.shape[2]))
    prediction = tf.squeeze(tf.round(prediction))

    prediction = np.argmax(prediction,axis=2)

    print(prediction.shape)
    
    
    #print(model.summary())
    return prediction

iface = gr.Interface(fn=greet, inputs=gr.Image(), outputs=gr.Image())
iface.launch()