|
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) |
|
|
|
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) |