diff --git a/01_materials/labs/lab_4.ipynb b/01_materials/labs/lab_4.ipynb index 90bd4fffb..49316d21a 100644 --- a/01_materials/labs/lab_4.ipynb +++ b/01_materials/labs/lab_4.ipynb @@ -603,7 +603,17 @@ "outputs": [], "source": [ "from keras.applications.resnet50 import preprocess_input, decode_predictions\n", - "\n" + "\n", + "# Resize the image\n", + "input_image = resize(image, (224, 224, 3), mode='reflect', anti_aliasing=True)\n", + "\n", + "# Scale to [0, 255] range (resize returns [0, 1])\n", + "input_image = input_image * 255\n", + "\n", + "# Prepare for model (add batch dimension)\n", + "input_image = np.expand_dims(input_image, axis=0)\n", + "\n", + "# Now use preprocess_input and predict to classify the image\n" ] }, { @@ -680,7 +690,20 @@ "id": "b1pXoFQgI_fk" }, "outputs": [], - "source": [] + "source": [ + "# Apply the same preprocessing as before and classify the webcam image\n", + "\n", + "# Resize the image\n", + "input_image = resize(image, (224, 224, 3), mode='reflect', anti_aliasing=True)\n", + "\n", + "# Scale to [0, 255] range (resize returns [0, 1])\n", + "input_image = input_image * 255\n", + "\n", + "# Prepare for model (add batch dimension)\n", + "input_image = np.expand_dims(input_image, axis=0)\n", + "\n", + "# Now use preprocess_input and predict to classify the image\n" + ] }, { "cell_type": "code",