professorbrat commited on
Commit
3bff423
1 Parent(s): 2b5dc41

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -6,15 +6,14 @@ import gradio as gr
6
  labels = {0: "melanoma", 1: "nevus", 2: "seborrheic_keratosis"}
7
 
8
  def classify_image(inp):
9
- img = tf.keras.utils.load_img(
10
- inp, target_size=(256,256)
11
- )
12
- img_array = tf.keras.utils.img_to_array(img)
13
- img_array = tf.expand_dims(img_array, 0)
14
 
15
- predictions = nomanet.predict(img_array)[0]
16
 
17
- return labels[predictions]
 
 
18
 
19
  gr.Interface(fn=classify_image,
20
  inputs=gr.inputs.Image(type="filepath"),
 
6
  labels = {0: "melanoma", 1: "nevus", 2: "seborrheic_keratosis"}
7
 
8
  def classify_image(inp):
9
+ image_array = tf.keras.preprocessing.image.img_to_array(
10
+ tf.keras.preprocessing.image.load_img(inp, target_size=(256,256)))
 
 
 
11
 
12
+ image_array_with_batchdim = image_array[np.newaxis, :]
13
 
14
+ model_prediction = np.argmax(model.predict(image_array_with_batchdim), axis=-1)[0]
15
+
16
+ return labels[model_prediction]
17
 
18
  gr.Interface(fn=classify_image,
19
  inputs=gr.inputs.Image(type="filepath"),