File size: 782 Bytes
7df6ff3
 
ff6a264
7df6ff3
 
 
 
20aa822
e8585dd
 
7df6ff3
20aa822
7df6ff3
 
 
 
 
 
 
 
 
 
 
6199b9e
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
from huggingface_hub import from_pretrained_keras
import gradio as gr
import tensorflow as tf  

model = from_pretrained_keras("araeynn/e")

def image_classifier(inp):
    class_names = ["Gingivitis", "Hypodontia"]
    inp.save("why.png")
    sunflower_path = "why.png"
    img = tf.keras.utils.load_img(
      sunflower_path, target_size=(180, 180)
    )
    img_array = tf.keras.utils.img_to_array(img)
    img_array = tf.expand_dims(img_array, 0) # Create a batch

    predictions = model.predict(img_array)
    score = tf.nn.softmax(predictions)
    r = {}
    for class_name in class_names:
      r[class_name] = score[0][class_names.index(class_name)]
    return r
demo = gr.Interface(fn=image_classifier, inputs=gr.Image(type="pil"), outputs="label")
demo.launch(debug=True)