ashiqu-ali commited on
Commit
7951706
1 Parent(s): 28ecc33
app.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import streamlit as st
3
+ import tensorflow as tf
4
+ import numpy as np
5
+
6
+ # Loading the saved model
7
+ model = tf.keras.models.load_model('model.h5')
8
+
9
+ def predict(input_image):
10
+ try:
11
+ # Preprocessing
12
+ input_image = tf.convert_to_tensor(input_image)
13
+ input_image = tf.image.resize(input_image, [224, 224])
14
+ input_image = tf.expand_dims(input_image, 0) / 255.0
15
+
16
+ # Prediction
17
+ predictions = model.predict(input_image)
18
+ labels = ['Cataract', 'Conjunctivitis', 'Glaucoma', 'Normal']
19
+
20
+ # Get confidence score for each class
21
+ disease_confidence = {label: np.round(predictions[0][idx] * 100, 3) for idx, label in enumerate(labels)}
22
+
23
+ # Get confidence percentage for the "Normal" class
24
+ normal_confidence = disease_confidence['Normal']
25
+
26
+ # Check if Normal confidence is greater than 50%
27
+ if normal_confidence > 50:
28
+ return f"""Congrats! no disease detected
29
+ Normal with confidence: {normal_confidence}%"""
30
+
31
+
32
+ output_lines = [f"\n{disease}: {confidence}%" for disease, confidence in disease_confidence.items()]
33
+ output_string = "\n".join(output_lines[:-1])
34
+ return output_string
35
+
36
+
37
+ except Exception as e:
38
+ return f"An error occurred: {e}"
39
+
40
+ # Example images directory
41
+ examples = [os.path.join("example", file) for file in os.listdir("example")]
42
+
43
+ # Streamlit app
44
+ st.title("👁️ Eye Disease Detection")
45
+ st.write("This model identifies common eye diseases such as Cataract, Conjunctivitis, and Glaucoma. Upload an eye image to see how the model classifies its condition.")
46
+
47
+ uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "png"])
48
+
49
+ if uploaded_file is not None:
50
+ # Display the uploaded image
51
+ image = tf.image.decode_image(uploaded_file.read(), channels=3)
52
+ image_np = image.numpy()
53
+ st.image(image_np, caption='Uploaded Image.', use_column_width=True)
54
+
55
+ # Perform prediction
56
+ prediction = predict(image_np)
57
+ st.write("Prediction:")
58
+ st.write(prediction)
59
+
60
+ # Display examples images
61
+ st.write("Examples:")
62
+ cols = st.columns(len(examples))
63
+ for idx, example in enumerate(examples):
64
+ cols[idx].image(example, caption=os.path.basename(example))
example/cataract.jpg ADDED
example/conj.jpg ADDED
example/glaucoma.jpg ADDED
example/normal.jpg ADDED
model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0503e25aadd98e95209163181ac975dd0c2a27740e5e2d5751e8fc661ee4b454
3
+ size 157265144
requirement.txt ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ absl-py==2.0.0
2
+ aiofiles==23.2.1
3
+ altair==5.3.0
4
+ annotated-types==0.6.0
5
+ anyio==4.3.0
6
+ appdirs==1.4.4
7
+ astunparse==1.6.3
8
+ attrs==23.2.0
9
+ autograd==1.6.2
10
+ autoray==0.6.9
11
+ blinker==1.7.0
12
+ cachetools==5.3.2
13
+ certifi==2023.11.17
14
+ charset-normalizer==3.3.2
15
+ click==8.1.7
16
+ colorama==0.4.6
17
+ contourpy==1.2.0
18
+ cycler==0.12.1
19
+ dill==0.3.8
20
+ fastapi==0.110.2
21
+ ffmpy==0.3.2
22
+ filelock==3.13.1
23
+ Flask==3.0.2
24
+ flatbuffers==23.5.26
25
+ fonttools==4.47.0
26
+ fsspec==2024.2.0
27
+ future==1.0.0
28
+ gast==0.4.0
29
+ gitdb==4.0.11
30
+ GitPython==3.1.43
31
+ google-auth==2.25.2
32
+ google-auth-oauthlib==1.0.0
33
+ google-pasta==0.2.0
34
+ gradio==4.27.0
35
+ gradio_client==0.15.1
36
+ grpcio==1.60.0
37
+ h11==0.14.0
38
+ h5py==3.10.0
39
+ httpcore==1.0.5
40
+ httpx==0.27.0
41
+ huggingface-hub==0.22.2
42
+ idna==3.6
43
+ importlib_resources==6.4.0
44
+ itsdangerous==2.1.2
45
+ jax==0.4.23
46
+ Jinja2==3.1.3
47
+ joblib==1.3.2
48
+ jsonschema==4.21.1
49
+ jsonschema-specifications==2023.12.1
50
+ keras==2.15.0
51
+ kiwisolver==1.4.5
52
+ libclang==16.0.6
53
+ Markdown==3.5.1
54
+ markdown-it-py==3.0.0
55
+ MarkupSafe==2.1.3
56
+ matplotlib==3.8.2
57
+ mdurl==0.1.2
58
+ ml-dtypes==0.2.0
59
+ mpmath==1.3.0
60
+ networkx==3.2.1
61
+ numpy==1.23.5
62
+ oauthlib==3.2.2
63
+ opencv-python==4.8.1.78
64
+ opt-einsum==3.3.0
65
+ orjson==3.10.1
66
+ packaging==23.2
67
+ pandas==2.1.4
68
+ pbr==6.0.0
69
+ PennyLane==0.35.1
70
+ PennyLane_Lightning==0.35.1
71
+ Pillow==10.1.0
72
+ ply==3.11
73
+ protobuf==4.23.4
74
+ psutil==5.9.8
75
+ pyarrow==16.0.0
76
+ pyasn1==0.5.1
77
+ pyasn1-modules==0.3.0
78
+ pydantic==2.7.0
79
+ pydantic_core==2.18.1
80
+ pydeck==0.8.1b0
81
+ pydub==0.25.1
82
+ Pygments==2.17.2
83
+ pyparsing==3.1.1
84
+ python-dateutil==2.8.2
85
+ python-multipart==0.0.9
86
+ pytz==2023.3.post1
87
+ PyYAML==6.0.1
88
+ qiskit==1.0.1
89
+ qiskit-aer==0.13.3
90
+ qiskit-terra==0.46.0
91
+ referencing==0.34.0
92
+ requests==2.31.0
93
+ requests-oauthlib==1.3.1
94
+ rich==13.7.1
95
+ rpds-py==0.18.0
96
+ rsa==4.9
97
+ ruff==0.4.1
98
+ rustworkx==0.14.1
99
+ scikit-learn==1.3.2
100
+ scipy==1.11.4
101
+ semantic-version==2.10.0
102
+ shellingham==1.5.4
103
+ six==1.16.0
104
+ smmap==5.0.1
105
+ sniffio==1.3.1
106
+ starlette==0.37.2
107
+ stevedore==5.2.0
108
+ streamlit==1.33.0
109
+ symengine==0.11.0
110
+ sympy==1.12
111
+ tenacity==8.2.3
112
+ tensorboard==2.15.1
113
+ tensorboard-data-server==0.7.2
114
+ tensorflow==2.15.0
115
+ tensorflow-estimator==2.15.0
116
+ tensorflow-intel==2.15.0
117
+ tensorflow-io-gcs-filesystem==0.31.0
118
+ termcolor==2.4.0
119
+ threadpoolctl==3.2.0
120
+ toml==0.10.2
121
+ tomlkit==0.12.0
122
+ toolz==0.12.1
123
+ torch==2.2.0
124
+ tornado==6.4
125
+ tqdm==4.66.2
126
+ typer==0.12.3
127
+ typing_extensions==4.9.0
128
+ tzdata==2023.3
129
+ urllib3==2.1.0
130
+ uvicorn==0.29.0
131
+ watchdog==4.0.0
132
+ websockets==11.0.3
133
+ Werkzeug==3.0.1
134
+ wrapt==1.14.1