Session 5: AI Hackathon

We will apply learnings from previous sessions to solve real-world problems using Google’s Teachable Machine. The goal is to foster collaboration and innovation while building functional AI models.


keyboard_arrow_down

1. Introduction to the Hackathon

  • What is a Hackathon? A hackathon is an event where participants collaborate intensively on projects to solve real-world problems in a limited time.
  • Objective for this Hackathon: Build an AI model using Teachable Machine to address a real-world challenge.
  • Format:
    • Teams of 3–5 participants.
    • Duration: 1.5 hours.
    • Deliverables: A working AI model and a brief presentation explaining the problem, solution, and model’s performance.

2. Hackathon Guidelines

Problem-Solving Framework

  1. Identify a Problem:
    • Think of daily-life challenges that AI can solve.
    • Examples:
      • Monitoring classroom engagement using facial expressions.
      • Automating fitness tracking through pose detection.
      • Sound detection for security or environment monitoring.
  2. Define the Solution:
    • Specify how AI will solve the problem.
    • Identify the type of model required (image, pose, or sound classification).
  3. Plan the Workflow:
    • Collect training data.
    • Train the model on Teachable Machine.
    • Test and refine the model.

3. Real-World Use Cases and Examples

Classroom Engagement Monitor

  • Problem: Teachers find it difficult to assess student engagement in online or hybrid classes.
  • Solution: Train a model to classify student expressions as attentive, distracted, or neutral.
  • Outcome: Provide live feedback to teachers to improve class delivery.

Home Security Sound Detector

  • Problem: Identifying unusual sounds in homes, such as breaking glass or alarms.
  • Solution: Train a sound detection model to classify sounds as normal or suspicious.
  • Outcome: Alert homeowners for potential threats.

AI-Based Sign Language Interpreter

  • Problem: Bridging the communication gap for hearing-impaired individuals.
  • Solution: Use hand gesture classification to interpret basic sign language.
  • Outcome: Real-time translation for effective communication.

4. Step-by-Step Guide for Participants

Step 1: Team Setup

  • Form teams of 3–5 participants.
  • Assign roles: data collector, trainer, tester, and presenter.

Step 2: Create the Model

  1. Access Teachable Machine.
  2. Select the appropriate model type (image, pose, or sound classification).
  3. Train the model using diverse and representative data.

Step 3: Test and Refine

  • Use real-world examples to test the model.
  • Collect additional data if necessary to improve accuracy.

Step 4: Export and Integrate

  • Export the model as TensorFlow.js or TensorFlow Lite.
  • Optionally, integrate the model into a Python application.

Example Python Code for Model DeploymentWe

# Example to integrate a Teachable Machine image classification model in Python
import tensorflow as tf
from PIL import Image
import numpy as np

# Load model
model = tf.keras.models.load_model('path_to_model.h5')

# Preprocess image
def preprocess_image(image_path):
    image = Image.open(image_path).resize((224, 224))
    image_array = np.array(image) / 255.0  # Normalize pixel values
    return np.expand_dims(image_array, axis=0)

# Predict
def predict(image_path):
    processed_image = preprocess_image(image_path)
    predictions = model.predict(processed_image)
    return predictions

# Test
image_path = 'test_image.jpg'
result = predict(image_path)
print("Predictions:", result)
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-2-bd108a2eaefa> in <cell line: 0>()
      5 
      6 # Load model
----> 7 model = tf.keras.models.load_model('path_to_model.h5')
      8 
      9 # Preprocess image


                                     3 frames
/usr/local/lib/python3.11/dist-packages/keras/src/saving/saving_api.py in load_model(filepath, custom_objects, compile, safe_mode)
    194         )
    195     if str(filepath).endswith((".h5", ".hdf5")):
--> 196         return legacy_h5_format.load_model_from_hdf5(
    197             filepath, custom_objects=custom_objects, compile=compile
    198         )

/usr/local/lib/python3.11/dist-packages/keras/src/legacy/saving/legacy_h5_format.py in load_model_from_hdf5(filepath, custom_objects, compile)
    114     opened_new_file = not isinstance(filepath, h5py.File)
    115     if opened_new_file:
--> 116         f = h5py.File(filepath, mode="r")
    117     else:
    118         f = filepath

/usr/local/lib/python3.11/dist-packages/h5py/_hl/files.py in __init__(self, name, mode, driver, libver, userblock_size, swmr, rdcc_nslots, rdcc_nbytes, rdcc_w0, track_order, fs_strategy, fs_persist, fs_threshold, fs_page_size, page_buf_size, min_meta_keep, min_raw_keep, locking, alignment_threshold, alignment_interval, meta_block_size, **kwds)
    559                                  fs_persist=fs_persist, fs_threshold=fs_threshold,
    560                                  fs_page_size=fs_page_size)
--> 561                 fid = make_fid(name, mode, userblock_size, fapl, fcpl, swmr=swmr)
    562 
    563             if isinstance(libver, tuple):

/usr/local/lib/python3.11/dist-packages/h5py/_hl/files.py in make_fid(name, mode, userblock_size, fapl, fcpl, swmr)
    233         if swmr and swmr_support:
    234             flags |= h5f.ACC_SWMR_READ
--> 235         fid = h5f.open(name, flags, fapl=fapl)
    236     elif mode == 'r+':
    237         fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl)

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/_objects.pyx in h5py._objects.with_phil.wrapper()

h5py/h5f.pyx in h5py.h5f.open()

FileNotFoundError: [Errno 2] Unable to synchronously open file (unable to open file: name = 'path_to_model.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)

5. Presentation and Feedback

  1. List item
  2. List item
  • List item
  • List item
  1. List item
  2. List item

Each team will:

  1. Present their problem statement and solution.
  2. Showcase the working model.
  3. Share learnings and challenges faced during development.

6. Judging Criteria

  • Creativity: Novelty of the problem and solution.
  • Technical Implementation: Model accuracy and performance.
  • Practicality: Real-world applicability of the solution.
  • Teamwork: Collaboration and division of tasks.

7. Resources Provided

  • Notebooks with example Python code.
  • Access to Teachable Machine and additional datasets.
  • Guides for exporting and integrating models.

8. Key Takeaways

  • Hackathons provide hands-on experience in applying AI to solve real-world problems.
  • Collaboration fosters creativity and innovation.
  • Learning to deploy models bridges the gap between theory and practice.

We will apply learnings from previous sessions to solve real-world problems using Google’s Teachable Machine. The goal is to foster collaboration and innovation while building functional AI models.