Build an image classifier using pre-trained models.
1. Introduction to AI
What is AI?
2. Machine Learning Basics
How Machine Learning Works
3. AI Applications
AI in the Real World
10. Reinforcement Learning
Reinforcement Learning Basics
Syntax
AI
from tensorflow.keras.applications import ResNet50
from tensorflow.keras.preprocessing import image
import numpy as np
model = ResNet50(weights="imagenet")
img = image.load_img("cat.jpg", target_size=(224, 224))
Image Classifier Concept
PYTHON
# Conceptual image classifier def classify_by_color(r, g, b): if r > 200 and g < 100 and b < 100: return "Red object" elif r < 100 and g > 200 and b < 100: return "Green object" elif r < 100 and g < 100 and b > 200: return "Blue object" elif r > 200 and g > 200 and b > 200: return "White/bright object" else: return "Mixed color" # Test print(classify_by_color(255, 0, 0)) print(classify_by_color(0, 255, 0)) print(classify_by_color(128, 128, 128))
Up next
Reinforcement Learning Basics
Lesson 17 of 17 · Reinforcement Learning