Coding Activities by Bhargav Venkat

Activity

Image-to-Text Conversion Project part 1

Use the Hugging Face Inference API to: Generate a basic caption from an input image. Offer user options to truncate (for a short caption), expand (for a 30-word description), or summarize (for a 50-word summary) the caption using GPT-2.

Single Image AI captions

In this activity, a local image file is processed through the robust "nlpconnect/vit-gpt2-image-captioning" model from Hugging Face. The model generates a descriptive caption by analyzing visual content in the image.

Inpainting and Restoration Challenge

In this activity, you’ll explore the power of image inpainting to transform or repair images. Instead of generating an image solely from text, you’ll provide an existing image and a corresponding mask (where white areas indicate regions to be modified or restored). By supplying a textual prompt that describes the desired change, the AI model fills in the masked regions to create a seamless, restored, or altered image. This exercise is perfect for learning how to guide the creative process beyond full image synthesis—enabling detailed editing and repair of existing visuals.

Post-Processing Magic Workshop

In this activity, you'll generate an image using a text-to-image model (Stable Diffusion) and then enhance it with post-processing techniques. The session focuses on applying practical image adjustments such as increasing brightness, boosting contrast, and adding a soft-focus effect with Gaussian blur. Using Python libraries like Pillow, you'll learn how to transform raw AI-generated images into polished artworks, highlighting the impact of subtle adjustments on the overall visual quality. Enjoy exploring how post-processing can refine and elevate your creative output!

Generating Images from Text using Hugging Face Models

In this activity, students will build an interactive Text-to-Image Generator that takes textual descriptions (prompts) as input and generates corresponding images using the Hugging Face API with the Stable Diffusion model. The tool will allow users to generate creative artwork from simple descriptions, explore the potential of AI in creative fields, and understand how machine learning models process and generate images based on text.

Sentiment Analysis Application

Sentiment Analysis Inference API

In this activity, you'll build a Python script that leverages the Hugging Face Inference API to perform sentiment analysis on text input. The script demonstrates how to securely import your API key, set up the necessary HTTP headers for authentication, and send a JSON payload containing your text to the Hugging Face API endpoint. Using a pre-trained DistilBERT model fine-tuned on sentiment analysis (SST-2), the API returns a JSON response with classification results, which the script then prints. This exercise reinforces essential concepts such as API integration, secure token handling, and processing JSON responses in Python.

Setting Up Your Hugging Face API Key

This activity guides you through the process of integrating a Hugging Face API key into your Python project in a secure manner. You'll start by creating a Hugging Face account, completing your profile, and verifying your email. Once your account is set up, you'll generate a read-only access token and securely store it in a config.py file. To protect your sensitive information, you'll also learn how to configure Git to ignore the file containing your API key. Finally, you'll integrate the API key into your main Python script, ensuring a smooth and secure connection to Hugging Face services.

Random Technology Facts

In this project learn to access a particular endpoint

Fetching Trivia Questions and Displaying Them

Students will use a Trivia API to fetch trivia questions and create an interactive quiz where they can answer the questions and receive feedback.

Gesture-Controlled Photo App with Filters

In this activity, students will build a real-time gesture-controlled photo app that allows them to apply different filters (grayscale, sepia, negative, blur) and take screenshots using hand gestures.