Let's build a AI Photo Generator with Python and FastAPI

CodingEntrepreneurs November 22, 2024
Video Thumbnail
CodingEntrepreneurs Logo

CodingEntrepreneurs

@codingentrepreneurs

About

Learn, Build, and Earn. Coding Entrepreneurs is here to help you learn the skills you need to build the projects you want. Learn by doing everything we do step-by-step. Practical and hands-on. Let's do this. 💽 Code: https://github.com/codingforentrepreneurs 🚀 Enroll. Learn to code. Launch your project: https://cfe.sh/enroll 🚀

Video Description

"I want an image of me riding a unicorn" - is now here. In this course we fine-tune the amazing Flux open-source image generation AI model. To make this happen, we use Replicate's AI services to train and fine-tune Flux with our data. You can upload about 12 images of yourself and automagically have an AI tool like Midjourney with your data. It's incredible. The best part? It costs about $3 USD to fine-tune this model then about $0.05 to generate images with it using Replicate's GPUs. Once you have a fine-tuned model, we need a reliable way to access it without racking up bills. Enter FastAPI. We create our own API service that we can call at anytime to generate our images. I'm shocked how good image generation is with our own data! Topics include: - Compressing and optimizing images - Creating zip files from local folders - Building a FastAPI Microservice - Implementing Rate Limiting with Upstash Redis - Creating a Proxy Service for your custom fine-tuned Flux AI Model - Generating new images with your face via text prompts - Watch the first few seconds to see 100% fully generated images from the model I build in this course. - and more 🚀 Thanks to Upstash for sponsoring this course! Sign up right now on https://www.upstash.com/?utm_source=cfe! 🖥️ Code: https://github.com/codingforentrepreneurs/super-me-photo-ai-api 🤖 AI Service: Replicate.com 🦾 Model used to fine-tune: https://replicate.com/ostris/flux-dev-lora-trainer/train Chapters 00:00:00 Welcome 00:02:39 Demo 00:05:14 Setup Environment 00:07:28 Image Dataset to Zip File Basics 00:17:11 Validate Images to Dataset Zip File 00:22:55 Optimize Images to Dataset Zip File 00:30:08 Train and Customize Flux for our Image Dataset 00:35:51 Generate Images from Custom Model 00:47:25 Generate Images with a Reference Photo 00:50:35 Background Trigger for Async Replicate Generation 00:57:44 Hello FastAPI Miroservice 01:02:16 Helper Functions for FastAPI & Replicate 01:08:52 FastAPI Generate Function Endpoint 01:13:09 Call Our Proxy Generate Function 01:16:57 Rate Limit API Requests with Upstash Redis 01:27:09 Customize the FastAPI Rate Limiter 01:31:10 Require Custom API Key for FastAPI Requests 01:37:13 Rate Limit Helper Module 01:39:29 List Prediction Results from Image Generation 01:55:12 Prediction Result Detail View 02:02:36 Output Index Pattern 02:12:23 Prediction Detail Output with Pydantic Models 02:24:38 Stream Generated Images Endpoint 02:32:17 Store Streaming Images 02:42:19 Schema-First Responses for Replicate API 02:51:07 Thank you

You May Also Like

AI Photo Gen Master Kit

AI-recommended products based on this video

Loading...
Freenove Ultimate Starter Kit for BBC micro bit (V2 Included), 316-Page Detailed Tutorial, 225 Items, 44 Projects, Blocks and Python Code

Freenove Ultimate Starter Kit for BBC micro bit (V2 Included), 316-Page Detailed Tutorial, 225 Items, 44 Projects, Blocks and Python Code

(382)
$94.95
PrimeFREE delivery Sat, Jun 14
Loading...
GEEKOM GT1 Mega AI Mini PC,14th Gen Intel Core Ultra U9-185H Processor (16C/22T,up to 5.1 GHz),32GB DDR5 2TB M.2 2280 NVMe Gen4*4 SSD, Mini Desktop Windows 11 Pro, WiFi7/BT 5.4/Dual 2.5G LAN/USB4.0/8K

GEEKOM GT1 Mega AI Mini PC,14th Gen Intel Core Ultra U9-185H Processor (16C/22T,up to 5.1 GHz),32GB DDR5 2TB M.2 2280 NVMe Gen4*4 SSD, Mini Desktop Windows 11 Pro, WiFi7/BT 5.4/Dual 2.5G LAN/USB4.0/8K

(128)
$1,499.00
PrimeFREE delivery Sat, Jun 14
Loading...
GEEKOM GT1 Mega AI Mini PC,14th Gen Intel Core Ultra U9-185H Processor (16C/22T,up to 5.1 GHz),32GB DDR5 2TB M.2 2280 NVMe Gen4*4 SSD, Mini Desktop Windows 11 Pro, WiFi7/BT 5.4/Dual 2.5G LAN/USB4.0/8K

GEEKOM GT1 Mega AI Mini PC,14th Gen Intel Core Ultra U9-185H Processor (16C/22T,up to 5.1 GHz),32GB DDR5 2TB M.2 2280 NVMe Gen4*4 SSD, Mini Desktop Windows 11 Pro, WiFi7/BT 5.4/Dual 2.5G LAN/USB4.0/8K

(128)
$1,499.00
PrimeFREE delivery Sat, Jun 14
Loading...
Lenovo ThinkPad E16 Business Laptop (16" FHD+ Touchscreen, Intel 13th Gen 10-Core i7-1355U, 40GB RAM, 2TB SSD) Backlit, Fingerprint, FHD Webcam, Ethernet, Thunderbolt 4, Win 11 Pro w/ AI Copilot

Lenovo ThinkPad E16 Business Laptop (16" FHD+ Touchscreen, Intel 13th Gen 10-Core i7-1355U, 40GB RAM, 2TB SSD) Backlit, Fingerprint, FHD Webcam, Ethernet, Thunderbolt 4, Win 11 Pro w/ AI Copilot

(0)
$5,116.61
FREE delivery Jun 23 - Jul 3Only 3 left in stock.
Loading...
GEEKOM GT1 Mega AI Mini PC,14th Gen Intel Core Ultra U9-185H Processor (16C/22T,up to 5.1 GHz),32GB DDR5 2TB M.2 2280 NVMe Gen4*4 SSD, Mini Desktop Windows 11 Pro, WiFi7/BT 5.4/Dual 2.5G LAN/USB4.0/8K

GEEKOM GT1 Mega AI Mini PC,14th Gen Intel Core Ultra U9-185H Processor (16C/22T,up to 5.1 GHz),32GB DDR5 2TB M.2 2280 NVMe Gen4*4 SSD, Mini Desktop Windows 11 Pro, WiFi7/BT 5.4/Dual 2.5G LAN/USB4.0/8K

(128)
$1,499.00
PrimeFREE delivery Sat, Jun 14
Loading...
Lenovo ThinkPad E16 Business Laptop (16" FHD+ Touchscreen, Intel 13th Gen 10-Core i7-1355U, 40GB RAM, 2TB SSD) Backlit, Fingerprint, FHD Webcam, Ethernet, Thunderbolt 4, Win 11 Pro w/ AI Copilot

Lenovo ThinkPad E16 Business Laptop (16" FHD+ Touchscreen, Intel 13th Gen 10-Core i7-1355U, 40GB RAM, 2TB SSD) Backlit, Fingerprint, FHD Webcam, Ethernet, Thunderbolt 4, Win 11 Pro w/ AI Copilot

(0)
$5,116.61
FREE delivery Jun 23 - Jul 3Only 3 left in stock.
Loading...
GEEKOM GT1 Mega AI Mini PC,14th Gen Intel Core Ultra U9-185H Processor (16C/22T,up to 5.1 GHz),32GB DDR5 2TB M.2 2280 NVMe Gen4*4 SSD, Mini Desktop Windows 11 Pro, WiFi7/BT 5.4/Dual 2.5G LAN/USB4.0/8K

GEEKOM GT1 Mega AI Mini PC,14th Gen Intel Core Ultra U9-185H Processor (16C/22T,up to 5.1 GHz),32GB DDR5 2TB M.2 2280 NVMe Gen4*4 SSD, Mini Desktop Windows 11 Pro, WiFi7/BT 5.4/Dual 2.5G LAN/USB4.0/8K

(128)
$1,499.00
PrimeFREE delivery Sat, Jun 14
Loading...
Lenovo ThinkPad E16 Business Laptop (16" FHD+ Touchscreen, Intel 13th Gen 10-Core i7-1355U, 40GB RAM, 2TB SSD) Backlit, Fingerprint, FHD Webcam, Ethernet, Thunderbolt 4, Win 11 Pro w/ AI Copilot

Lenovo ThinkPad E16 Business Laptop (16" FHD+ Touchscreen, Intel 13th Gen 10-Core i7-1355U, 40GB RAM, 2TB SSD) Backlit, Fingerprint, FHD Webcam, Ethernet, Thunderbolt 4, Win 11 Pro w/ AI Copilot

(0)
$5,116.61
FREE delivery Jun 23 - Jul 3Only 3 left in stock.
Loading...
GEEKOM GT1 Mega AI Mini PC,14th Gen Intel Core Ultra U9-185H Processor (16C/22T,up to 5.1 GHz),32GB DDR5 2TB M.2 2280 NVMe Gen4*4 SSD, Mini Desktop Windows 11 Pro, WiFi7/BT 5.4/Dual 2.5G LAN/USB4.0/8K

GEEKOM GT1 Mega AI Mini PC,14th Gen Intel Core Ultra U9-185H Processor (16C/22T,up to 5.1 GHz),32GB DDR5 2TB M.2 2280 NVMe Gen4*4 SSD, Mini Desktop Windows 11 Pro, WiFi7/BT 5.4/Dual 2.5G LAN/USB4.0/8K

(128)
$1,499.00
PrimeFREE delivery Sat, Jun 14
Loading...
Lenovo ThinkPad E16 Business Laptop (16" FHD+ Touchscreen, Intel 13th Gen 10-Core i7-1355U, 40GB RAM, 2TB SSD) Backlit, Fingerprint, FHD Webcam, Ethernet, Thunderbolt 4, Win 11 Pro w/ AI Copilot

Lenovo ThinkPad E16 Business Laptop (16" FHD+ Touchscreen, Intel 13th Gen 10-Core i7-1355U, 40GB RAM, 2TB SSD) Backlit, Fingerprint, FHD Webcam, Ethernet, Thunderbolt 4, Win 11 Pro w/ AI Copilot

(0)
$5,116.61
FREE delivery Jun 23 - Jul 3Only 3 left in stock.