DHEIVER commited on
Commit
7e43527
·
1 Parent(s): 2cc1c9f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -29,11 +29,16 @@ def build_model(img_height, img_width, n):
29
  loaded_model = build_model(IMG_HEIGHT, IMG_WIDTH, 3)
30
  loaded_model.load_weights('modelo_treinado.h5')
31
 
32
- # Function to preprocess the uploaded image
33
- def preprocess_uploaded_image(input_image):
34
- input_image = tf.image.decode_image(input_image.read(), channels=3)
35
  input_image = tf.image.resize(input_image, (IMG_HEIGHT, IMG_WIDTH))
 
 
36
  input_image = input_image / 255.0
 
 
 
37
  return input_image
38
 
39
  # Função para fazer previsões usando o modelo treinado
@@ -58,13 +63,9 @@ def predict_image(input_image):
58
  # Crie uma interface Gradio para fazer previsões
59
  iface = gr.Interface(
60
  fn=predict_image,
61
- inputs=gr.inputs.Image(label="Upload an Image", type="file"),
62
- outputs=gr.outputs.Text(label="Prediction", type="markdown"),
63
- interpretation="default",
64
- title="Image Classifier",
65
- description="Upload an image to classify it as 'Normal' or 'Cataract'.",
66
- theme="compact",
67
- loading="circle"
68
  )
69
 
70
  # Execute a interface Gradio
 
29
  loaded_model = build_model(IMG_HEIGHT, IMG_WIDTH, 3)
30
  loaded_model.load_weights('modelo_treinado.h5')
31
 
32
+ # Função para realizar o pré-processamento da imagem de entrada
33
+ def preprocess_image(input_image):
34
+ # Redimensione a imagem para as dimensões esperadas pelo modelo
35
  input_image = tf.image.resize(input_image, (IMG_HEIGHT, IMG_WIDTH))
36
+
37
+ # Normalização dos valores de pixel para o intervalo [0, 1]
38
  input_image = input_image / 255.0
39
+
40
+ # Outras transformações, se necessárias (por exemplo, normalização adicional)
41
+
42
  return input_image
43
 
44
  # Função para fazer previsões usando o modelo treinado
 
63
  # Crie uma interface Gradio para fazer previsões
64
  iface = gr.Interface(
65
  fn=predict_image,
66
+ inputs="image",
67
+ outputs="text",
68
+ interpretation="default"
 
 
 
 
69
  )
70
 
71
  # Execute a interface Gradio