Spaces:
Runtime error
Runtime error
Create app.py
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344import gradio as grimport numpy as npimport tensorflow as tffrom tensorflow import kerasfrom PIL import Image
model = keras.models.load_model("skinCancerClassification_UsningCNN.h5")
class_labels = { 0: 'dermatofibroma', 1: 'melanoma', 2: 'nevus', 3: 'seborrheic keratosis', 4: 'squamous cell carcinoma', 5: 'pigmented benign keratosis', 6: 'basal cell carcinoma', 7: 'vascular lesion', 8: 'actinic keratosis'}
def classify_skin_cancer(image): # Preprocess the image image = np.array(image) image = tf.image.resize(image, (75, 100)) # Resize to match model input shape image = np.expand_dims(image, axis=0)
predictions = model.predict(image) class_index = np.argmax(predictions) class_name = class_labels[class_index]
confidence = np.max(predictions)
return f"Predicted Class: {class_name}\nConfidence: {confidence:.2f}"
iface = gr.Interface( fn=classify_skin_cancer, inputs="image", outputs="text", live=True, title="Skin Cancer Classification", description="Upload an image of a skin lesion to classify its type.")
iface.launch()app.pyAdded+44