0
0
Computer Visionml~10 mins

Style transfer concept in Computer Vision - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to load the content image for style transfer.

Computer Vision
content_image = load_image('[1]')
Drag options to blanks, or click blank then click option'
A'content.jpg'
B'style.jpg'
C'output.jpg'
D'noise.jpg'
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing the style image filename instead of the content image.
Using an output filename before processing.
2fill in blank
medium

Complete the code to extract features from the style image using a pre-trained model.

Computer Vision
style_features = model.[1](style_image)
Drag options to blanks, or click blank then click option'
Apredict
Btransform
Cfit
Dextract_features
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'predict' which is for classification.
Using 'fit' which is for training the model.
3fill in blank
hard

Fix the error in the loss calculation for style transfer.

Computer Vision
style_loss = tf.reduce_mean(tf.square([1] - target_style))
Drag options to blanks, or click blank then click option'
Acontent_features
Boutput_image
Cstyle_features
Dinput_image
Attempts:
3 left
💡 Hint
Common Mistakes
Using content features instead of style features.
Using the input or output image directly instead of features.
4fill in blank
hard

Fill both blanks to create a dictionary of style and content weights for the loss function.

Computer Vision
loss_weights = {'style': [1], 'content': [2]
Drag options to blanks, or click blank then click option'
A1e-2
B1e-4
C1e-3
D1e-5
Attempts:
3 left
💡 Hint
Common Mistakes
Setting content weight higher than style weight.
Using very small weights that make training ineffective.
5fill in blank
hard

Fill all three blanks to update the generated image using gradient descent.

Computer Vision
with tf.GradientTape() as tape:
    outputs = model([1])
    loss = compute_loss(outputs, [2], [3])
grads = tape.gradient(loss, [1])
optimizer.apply_gradients([(grads, [1])])
Drag options to blanks, or click blank then click option'
Agenerated_image
Bstyle_targets
Ccontent_targets
Dinput_image
Attempts:
3 left
💡 Hint
Common Mistakes
Using input image instead of generated image for updates.
Mixing up style and content targets in loss computation.