Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,18 +1,35 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import numpy as np
|
| 3 |
-
import matplotlib.pyplot as plt
|
| 4 |
import keras
|
| 5 |
-
from
|
| 6 |
-
import sys
|
| 7 |
|
| 8 |
model = keras.models.load_model("model.keras")
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
# Display model summary using Streamlit
|
| 17 |
-
st.write("### Model Summary:")
|
| 18 |
-
st.text(model_summary)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import numpy as np
|
| 3 |
+
import matplotlib.pyplot as plt
|
| 4 |
import keras
|
| 5 |
+
from sklearn.preprocessing import MinMaxScaler
|
|
|
|
| 6 |
|
| 7 |
model = keras.models.load_model("model.keras")
|
| 8 |
|
| 9 |
+
uploaded_img = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
| 10 |
+
|
| 11 |
+
options = ['1st Convolution', '2nd Convolution', '3rd Convolution']
|
| 12 |
+
|
| 13 |
+
# Create the selectbox
|
| 14 |
+
selected_option = st.selectbox(
|
| 15 |
+
'Choose an option:',
|
| 16 |
+
options
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
conv_layers = [layer for layer in model.layers if isinstance(layer, Conv2D)]
|
| 20 |
+
|
| 21 |
+
plt.figure(figsize=(12, 4))
|
| 22 |
+
scaler = MinMaxScaler()
|
| 23 |
+
|
| 24 |
+
# for i in range(3):
|
| 25 |
+
for j in range(6):
|
| 26 |
+
layer=conv_layers[0]
|
| 27 |
+
weights=layer.get_weights()[0][:,:,0,j]
|
| 28 |
+
norm_weights = scaler.fit_transform(weights)
|
| 29 |
+
plt.subplot(2,3,j+1)
|
| 30 |
+
plt.imshow(norm_weights,cmap='gray')
|
| 31 |
+
plt.title(f"Conv Layer")
|
| 32 |
+
plt.axis('off')
|
| 33 |
+
plt.tight_layout()
|
| 34 |
+
plt.show();
|
| 35 |
|
|
|
|
|
|
|
|
|