reciouiikram commited on
Commit
5abac60
·
verified ·
1 Parent(s): 29e01fb

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -127
app.py DELETED
@@ -1,127 +0,0 @@
1
- import streamlit as st
2
- import tensorflow as tf
3
- from tensorflow.keras.models import load_model
4
- from PIL import Image, ImageOps
5
- import numpy as np
6
-
7
- # Set the page title and layout
8
- st.set_page_config(page_title="Breast Histology Classification 🔬", layout="wide")
9
-
10
- # Add custom pink-themed CSS
11
- st.markdown(
12
- """
13
- <style>
14
- body {
15
- background-color: #ffe4e6;
16
- }
17
- .stApp {
18
- background: linear-gradient(to right, #ff9a9e, #fecfef);
19
- }
20
- .stTitle {
21
- color: #ff69b4;
22
- }
23
- .stHeader {
24
- color: #db7093;
25
- }
26
- .stMarkdown {
27
- color: #c71585;
28
- }
29
- .stSidebar {
30
- background-color: #ffc1cc;
31
- }
32
- .stButton > button {
33
- background-color: #ff6f91;
34
- color: white;
35
- border: none;
36
- border-radius: 5px;
37
- }
38
- .stButton > button:hover {
39
- background-color: #ff4d6d;
40
- }
41
- </style>
42
- <footer>
43
- &copy; 2024 By: Ikram Recioui. All Rights Reserved.
44
- </footer>
45
- """,
46
- unsafe_allow_html=True,
47
- )
48
-
49
- # Load the pre-trained model
50
- @st.cache_resource
51
- def load_trained_model():
52
- return load_model(r"Breast_Histo_model.h5", compile=False)
53
-
54
- model = load_trained_model()
55
-
56
- # Define class labels
57
- class_labels = [
58
- "Benign",
59
- "InSitu",
60
- "Invasive",
61
- "Normal"
62
- ]
63
-
64
- # Home page content
65
- def home():
66
- st.title("Welcome to the Breast Histology Classification App 🔬")
67
- st.markdown("This application helps classify breast histological images into four distinct categories using AI.4️⃣")
68
-
69
- # Section: About Breast Histology
70
- st.subheader("What is Breast Histology? 🤔")
71
- st.markdown("""
72
- Breast histology refers to the microscopic examination of breast tissue samples. It is essential in diagnosing various
73
- conditions, including breast cancer. This app assists pathologists by automating the classification process into four categories:
74
- Benign, InSitu, Invasive, and Normal. 🤖⚙️
75
- """)
76
-
77
- # Embed a YouTube video
78
- st.subheader("Learn More About Breast Histology 📘💡")
79
- st.video("https://www.youtube.com/watch?v=nasLAO21juo")
80
-
81
- # Additional description
82
- st.markdown("""
83
- ### Features of this App ✨🔍:
84
- - Upload your histological images.
85
- - View AI predictions for 4 different categories:
86
- 1. **Benign**: Non-cancerous tissue.
87
- 2. **InSitu**: Pre-cancerous condition.
88
- 3. **Invasive**: Cancerous tissue spreading to surrounding areas.
89
- 4. **Normal**: Healthy tissue.
90
- """)
91
-
92
- # Prediction page content
93
- def upload_and_predict():
94
- st.title("Upload and Predict 📤")
95
-
96
- # File uploader for image upload
97
- uploaded_file = st.file_uploader("Choose a histology image... 🖼️", type=["jpg", "jpeg", "png"])
98
-
99
- if uploaded_file is not None:
100
- # Display the uploaded image
101
- st.image(uploaded_file, caption="Uploaded Image", use_container_width=True)
102
-
103
- # Load the image for prediction
104
- image = Image.open(uploaded_file)
105
- image = ImageOps.fit(image, (224, 224), Image.Resampling.LANCZOS)
106
- image_array = np.asarray(image) / 255.0 # Normalize the image
107
- image_array = np.expand_dims(image_array, axis=0) # Add batch dimension
108
-
109
- # Make prediction
110
- predictions = model.predict(image_array)
111
- predicted_class = class_labels[np.argmax(predictions)]
112
- confidence = np.max(predictions) * 100
113
-
114
- # Display the prediction
115
- st.subheader("Prediction Result: 📊")
116
- st.markdown(f"**Predicted Class:** {predicted_class}")
117
- st.markdown(f"**Confidence:** {confidence:.2f}%")
118
-
119
- # Main function to control navigation
120
- if __name__ == "__main__":
121
- st.sidebar.title("Navigation")
122
- page = st.sidebar.radio("Go to", ["Home", "Upload and Predict"])
123
-
124
- if page == "Home":
125
- home()
126
- elif page == "Upload and Predict":
127
- upload_and_predict()