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.
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!
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.
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.
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.