vdprabhu commited on
Commit
95cb32a
1 Parent(s): 16597f6

Upload app_utils.py

Browse files
Files changed (1) hide show
  1. app_utils.py +38 -0
app_utils.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ # Strings
4
+ replicate = ":bulb: Choose **ResNet50V2** model and **conv3_block4_out** to get the results as in the example."
5
+ credits = ":memo: Keras example by [@fchollet](https://twitter.com/fchollet)."
6
+ vit_info = ":star: For Vision Transformers, check the excellent [probing-vits](https://huggingface.co/probing-vits) space."
7
+
8
+ title = "Visualizing What Convnets Learn"
9
+ info_text = """
10
+ Models in this demo are pre-trained on the ImageNet dataset.
11
+ The simple visualization process involves creation of input images that maximize the activation of specific filters in a target layer.
12
+ Such images represent a visualization of the pattern that the filter responds to.
13
+ """
14
+
15
+
16
+ # Constants and globals
17
+ IMG_WIDTH = 180
18
+ IMG_HEIGHT = 180
19
+ VIS_OPTION = {"only the first filter": 0, "the first 64 filters": 64}
20
+ ITERATIONS = 30
21
+ LEARNING_RATE = 10.0
22
+
23
+
24
+ # Streamlit state variables
25
+ if "model_name" not in st.session_state:
26
+ st.session_state.model_name = None
27
+
28
+ if "layer_name" not in st.session_state:
29
+ st.session_state.layer_name = None
30
+
31
+ if "layer_list" not in st.session_state:
32
+ st.session_state.layer_list = None
33
+
34
+ if "model" not in st.session_state:
35
+ st.session_state.model = None
36
+
37
+ if "feat_extract" not in st.session_state:
38
+ st.session_state.feat_extract = None