ferferefer commited on
Commit
faa10a9
1 Parent(s): 46d2136

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -51
app.py DELETED
@@ -1,51 +0,0 @@
1
- import streamlit as st
2
- import tensorflow as tf
3
- from tf.keras.applications import EfficientNetV2B0
4
- from keras.layers import Flatten,Dense,Dropout,GlobalAveragePooling2D
5
- from tf.keras.models import load_model
6
- from tf.keras.preprocessing.image import load_img
7
- from tf.keras.preprocessing.image import img_to_array
8
- from keras.models import Model
9
- from transformers import pipeline
10
- import numpy as np
11
- from huggingface_hub import hf_hub_url, cached_download
12
-
13
- img_shape = (224,224,3)
14
- model = EfficientNetV2B0(include_top = False,input_shape=img_shape)
15
- flat_1=GlobalAveragePooling2D()(model.output)
16
- capa_3 = Dense(1,activation='sigmoid')(flat_1)
17
- model = Model(inputs=model.inputs,outputs = capa_3)
18
- model.compile(optimizer=tf.keras.optimizers.Adam(learning_rate=1e-4),loss="BinaryCrossentropy", metrics=["accuracy"])
19
- #Subir los pesos del modelo
20
- repo_id = "ferferefer/RIM_ONE_Glaucoma"
21
- filename = "vgg_rim_checkpoint.h5" # o el path a tu SavedModel
22
- # Obtener la URL y descargar el archivo (temporalmente)
23
- model_file = cached_download(hf_hub_url(repo_id, filename))
24
- # Cargar el modelo
25
- model.load_weights(model_file)
26
-
27
-
28
- st.title('RIM_ONE Glaucoma Image Classifier')
29
- input_image = st.file_uploader('Upload image')
30
-
31
- if st.button('PREDICT'):
32
-
33
- predict = load_img(input_image, target_size=img_shape)
34
- predict_modified = img_to_array(predict)
35
- predict_modified = np.expand_dims(predict_modified, axis=0)
36
- result = model.predict(predict_modified)
37
- if result < 0.5:
38
- probability = 1 - result[0][0]
39
- print(f"Healthy with {probability}%")
40
-
41
- else:
42
- probability = result[0][0]
43
- print(f"Glaucoma with {probability}%")
44
-
45
- image1 = load_img(input_image)
46
- image1 = img_to_array(image1)
47
- image1 = np.array(image1)
48
-
49
-
50
- st.image(image1, width=500)
51
-