File size: 690 Bytes
e053588
817d742
e053588
ae611ab
e053588
 
 
 
 
3bff423
 
e053588
3bff423
e053588
a69b26a
3bff423
 
e053588
 
 
c3e7cdd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import tensorflow as tf
import numpy as np

nomanet = tf.keras.models.load_model("Nomanet.h5")

import gradio as gr
labels = {0: "melanoma", 1: "nevus", 2: "seborrheic_keratosis"}

def classify_image(inp):
    image_array = tf.keras.preprocessing.image.img_to_array(
                      tf.keras.preprocessing.image.load_img(inp, target_size=(256,256)))

    image_array_with_batchdim = image_array[np.newaxis, :]
    
    model_prediction = np.argmax(nomanet.predict(image_array_with_batchdim), axis=-1)[0]

    return labels[model_prediction]
    
gr.Interface(fn=classify_image, 
             inputs=gr.inputs.Image(type="filepath"), 
             outputs=gr.outputs.Label()).launch()