Skip to content
Home Tutorials Roadmaps Courses
Log in Join free
Tutorials AI Image Recognition
AI Intermediate FREE

Image Recognition

Lesson 1 of 17 Intermediate Interactive

Computer vision enables machines to interpret and understand visual information from images and videos.

Syntax

AI
from tensorflow.keras.applications import ResNet50
from tensorflow.keras.preprocessing import image

model = ResNet50(weights='imagenet')
img = image.load_img('photo.jpg', target_size=(224, 224))
Image Classification Concept
PYTHON
# Concept: pixel-based classification
def simple_image_classifier(pixels):
    avg_brightness = sum(pixels) / len(pixels)

    if avg_brightness > 200:
        return "Bright image (likely sky/snow)"
    elif avg_brightness > 100:
        return "Medium brightness (normal photo)"
    else:
        return "Dark image (night/shadow)"

# Simulate 8x8 grayscale image
dark_image = [30] * 64
bright_image = [220] * 64
normal_image = [128] * 64

print(simple_image_classifier(dark_image))
print(simple_image_classifier(bright_image))
print(simple_image_classifier(normal_image))

Practice

1
Exercise

Practice this concept.

Answer
Write the code as shown above.

Quick Quiz

1

What did you learn?

This covers the basics.

Interview Questions

It is a fundamental AI feature.