File size: 930 Bytes
8853256
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ae08ded
 
 
 
 
 
 
 
8853256
 
ae08ded
 
 
 
8853256
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
29
30
31
""""
We are going to deploy our model using Gradio.
"""
import gradio as gr
import numpy as np
import tensorflow as tf
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing import image

# Load the model
model = load_model('melanoma_cancer_model.h5')

# Define the function to make predictions
def classify_image(img):
    img = np.expand_dims(img, axis=0)
    # Resize image
    resized_img = tf.image.resize(img, [160, 160])
    # Predict the image
    prediction = model.predict(resized_img)[0][0]
    # Convert to float value
    prediction = float(prediction)
    # return dictionary for Gradio
    return {"melanoma": prediction, "not melanoma": 1 - prediction}
    

# Launch the Gradio interface
gr.Interface(fn=classify_image, inputs='image', outputs="label").launch()
# Launch shareble Gradio interface 
# gr.Interface(fn=classify_image, inputs='image', outputs="label").launch(share=True)