This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir coco | |
cd coco | |
mkdir images | |
cd images | |
wget http://images.cocodataset.org/zips/train2017.zip | |
wget http://images.cocodataset.org/zips/val2017.zip | |
wget http://images.cocodataset.org/zips/test2017.zip | |
wget http://images.cocodataset.org/zips/unlabeled2017.zip |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def model_nn(sess, input_image, num_iterations = 200): | |
# Initialize global variables (you need to run the session on the initializer) | |
### START CODE HERE ### (1 line) | |
sess.run(tf.global_variables_initializer()) | |
### END CODE HERE ### | |
# Run the noisy input image (initial generated image) through the model. Use assign(). | |
### START CODE HERE ### (1 line) | |
sess.run(model["input"].assign(input_image)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def iou(box1, box2): | |
"""Implement the intersection over union (IoU) between box1 and box2 | |
# Calculate the (y1, x1, y2, x2) coordinates of the intersection of box1 and box2. Calculate its Area. | |
### START CODE HERE ### (≈ 5 lines) | |
xi1 = max(box1[0],box2[0]) | |
yi1 = max(box1[1],box2[1]) | |
xi2 = min(box1[2],box2[2]) | |
yi2 = min(box1[3],box2[3]) | |
inter_area = (yi2-yi1) * (xi2-xi1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def HappyModel(input_shape): | |
""" | |
Implementation of the HappyModel. | |
Arguments: | |
input_shape -- shape of the images of the dataset | |
Returns: | |
model -- a Model() instance in Keras | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def model(X, Y, learning_rate = 0.3, num_iterations = 30000, print_cost = True, lambd = 0, keep_prob = 1): | |
grads = {} | |
costs = [] # to keep track of the cost | |
m = X.shape[1] # number of examples | |
layers_dims = [X.shape[0], 20, 3, 1] | |
# Initialize parameters dictionary. | |
parameters = initialize_parameters(layers_dims) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for l in range(1, L + 1): | |
### START CODE HERE ### (≈ 2 lines of code) | |
parameters['W' + str(l)] = np.random.randn(layers_dims[l],layers_dims[l-1])*np.sqrt((2./layers_dims[l-1])) | |
parameters['b' + str(l)] = np.zeros((layers_dims[l],1)) | |
### END CODE HERE ### | |
return parameters |