progress print statements
Browse files
app.py
CHANGED
|
@@ -121,22 +121,7 @@ def predict_and_analyze(model_name, num_channels, dim, image):
|
|
| 121 |
|
| 122 |
'''Loads a model with activations, passes through image and shows activations
|
| 123 |
|
| 124 |
-
The image must be a
|
| 125 |
-
using
|
| 126 |
-
|
| 127 |
-
m,n,r = X.shape
|
| 128 |
-
X = np.column_stack((np.repeat(np.arange(C), W),
|
| 129 |
-
X.reshape(C * W, -1)))
|
| 130 |
-
df = pd.DataFrame(X)
|
| 131 |
-
|
| 132 |
-
then get the image back with
|
| 133 |
-
|
| 134 |
-
X = df.values
|
| 135 |
-
X = X[:, 1:]
|
| 136 |
-
X = X.reshape((C, W, W))
|
| 137 |
-
|
| 138 |
-
image = 2d numpy array in shape (C, W*W)
|
| 139 |
-
i.e. take a C,W,W array and reshape into (C, W*W)
|
| 140 |
|
| 141 |
'''
|
| 142 |
|
|
@@ -165,14 +150,13 @@ def predict_and_analyze(model_name, num_channels, dim, image):
|
|
| 165 |
|
| 166 |
model_name += '_%i' % (num_channels)
|
| 167 |
|
| 168 |
-
|
| 169 |
print("Loading model")
|
| 170 |
model = load_model(model_name, activation=True)
|
|
|
|
| 171 |
|
| 172 |
print("Looking at activations")
|
| 173 |
output, input_image, activation_1, activation_2 = get_activations(model, image, sub_mean=True)
|
| 174 |
-
|
| 175 |
-
print(output)
|
| 176 |
|
| 177 |
if output[0] < output[1]:
|
| 178 |
output = 'Planet predicted with %f percent confidence' % (100*output[1])
|
|
|
|
| 121 |
|
| 122 |
'''Loads a model with activations, passes through image and shows activations
|
| 123 |
|
| 124 |
+
The image must be a numpy array of shape (C, W, W) or (1, C, W, W)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
|
| 126 |
'''
|
| 127 |
|
|
|
|
| 150 |
|
| 151 |
model_name += '_%i' % (num_channels)
|
| 152 |
|
|
|
|
| 153 |
print("Loading model")
|
| 154 |
model = load_model(model_name, activation=True)
|
| 155 |
+
print("Model loaded")
|
| 156 |
|
| 157 |
print("Looking at activations")
|
| 158 |
output, input_image, activation_1, activation_2 = get_activations(model, image, sub_mean=True)
|
| 159 |
+
print("Activations and predictions finished")
|
|
|
|
| 160 |
|
| 161 |
if output[0] < output[1]:
|
| 162 |
output = 'Planet predicted with %f percent confidence' % (100*output[1])
|