shubham680 commited on
Commit
3f7f2ae
·
verified ·
1 Parent(s): c93b580

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -11
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 io import StringIO
6
- import sys
7
 
8
  model = keras.models.load_model("model.keras")
9
 
10
- old_stdout = sys.stdout # Save the current stdout so we can restore it later
11
- sys.stdout = StringIO() # Redirect stdout to StringIO object
12
- model.summary() # This will now be written to the StringIO object
13
- model_summary = sys.stdout.getvalue() # Get the value from StringIO
14
- sys.stdout = old_stdout # Restore original stdout
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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