Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
@@ -12,23 +12,19 @@ model = load_model('melanoma_cancer_model.h5')
|
|
12 |
|
13 |
# Define the function to make predictions
|
14 |
def classify_image(img):
|
15 |
-
img = np.array(img)
|
16 |
img = np.expand_dims(img, axis=0)
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
# return
|
24 |
-
return {"melanoma": prediction
|
25 |
|
26 |
|
27 |
-
#
|
28 |
-
|
29 |
-
|
30 |
-
#
|
31 |
-
gr.Interface(fn=classify_image, inputs="image", outputs="label").launch()
|
32 |
-
#gr.Interface(fn=classify_image, inputs=image, outputs=label).launch(server_port=7860)
|
33 |
|
34 |
-
# Run the app
|
|
|
12 |
|
13 |
# Define the function to make predictions
|
14 |
def classify_image(img):
|
|
|
15 |
img = np.expand_dims(img, axis=0)
|
16 |
+
# Resize image
|
17 |
+
resized_img = tf.image.resize(img, [160, 160])
|
18 |
+
# Predict the image
|
19 |
+
prediction = model.predict(resized_img)[0][0]
|
20 |
+
# Convert to float value
|
21 |
+
prediction = float(prediction)
|
22 |
+
# return dictionary for Gradio
|
23 |
+
return {"melanoma": prediction, "not melanoma": 1 - prediction}
|
24 |
|
25 |
|
26 |
+
# Launch the Gradio interface
|
27 |
+
gr.Interface(fn=classify_image, inputs='image', outputs="label").launch()
|
28 |
+
# Launch shareble Gradio interface
|
29 |
+
# gr.Interface(fn=classify_image, inputs='image', outputs="label").launch(share=True)
|
|
|
|
|
30 |
|
|