Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Intro to FastAPI: Tips and Tricks for ML
Search
Sebastián Ramírez
April 13, 2023
Technology
1
250
Intro to FastAPI: Tips and Tricks for ML
Sebastián Ramírez
April 13, 2023
Tweet
Share
More Decks by Sebastián Ramírez
See All by Sebastián Ramírez
Modern Python through FastAPI and friends - PyCon Sweden
tiangolo
0
29
Await for it: mixing async and blocking code - PyCon MEA - Dubai
tiangolo
0
12
Modern Python through FastAPI and friends - PyCon MEA - Dubai
tiangolo
0
860
CLI apps with Typer - Python type annotations and shell completion
tiangolo
0
300
Software de Colombia para el mundo
tiangolo
1
1.6k
Modern Python through FastAPI and friends - PyCon Indonesia
tiangolo
0
470
Modern Python through FastAPI and friends - Dubai - AI Everything - Gitex
tiangolo
0
83
Modern Python through FastAPI and friends - PyCon India
tiangolo
1
260
Haz un servicio de ML fácilmente con FastAPI
tiangolo
0
450
Other Decks in Technology
See All in Technology
地理空間データ可視化・解析・活用ソリューション Pacific Spatial Solutions (PSS)
pacificspatialsolutions
0
330
Babylon.jsと色々なものを組み合わせる:ブラウザのAPIやガジェットや2D描画ライブラリなど / Babylon.js 勉強会 vol.3
you
PRO
0
160
一生覚えておきたい「システム開発=コミュニケーション」〜初めての実務案件振り返りLT〜
maimyyym
2
250
ゼロから始めるVue.jsコミュニティ貢献 / first-vuejs-community-contribution-link-and-motivation
lmi
1
150
今日からできる!簡単 .NET 高速化 Tips -2024 edition-
xin9le
7
3.6k
開発パフォーマンスを最大化するための開発体制
ham0215
7
1.1k
On Your Data を超えていく!
hirotomotaguchi
2
750
リテール金融(キャッシュレス・ネット銀行・ネット証券)の競争環境と経済圏
8maki
0
1.5k
生産性向上チームの紹介
cybozuinsideout
PRO
1
910
プロンプトエンジニアリングでがんばらない-Agentic Workflow へ-近藤憲児
kenjikondobai
6
1.2k
Android Target SDK 35 (Android 15) 対応の概要
akkie76
0
150
Python と Snowflake はズッ友だょ!~ Snowflake の Python 関連機能をふりかえる ~
__allllllllez__
2
140
Featured
See All Featured
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
20
1.7k
Large-scale JavaScript Application Architecture
addyosmani
504
110k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
245
20k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3.1k
How GitHub (no longer) Works
holman
305
140k
Web Components: a chance to create the future
zenorocha
306
41k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
12
1.5k
Visualization
eitanlees
137
14k
Navigating Team Friction
lara
179
13k
Happy Clients
brianwarren
92
6.4k
Intergalactic Javascript Robots from Outer Space
tanoku
266
26k
A Tale of Four Properties
chriscoyier
152
22k
Transcript
Intro to High performance, easy to learn, fast to code,
ready for production Tips and Tricks for ML
Who am I? Sebastián Ramírez github.com/tiangolo linkedin.com/in/tiangolo twitter.com/tiangolo tiangolo.com Berlin,
Germany I created:
• Python Web API framework • 50K+ GitHub stars (about
1K+ per month) • Used by Microsoft, Uber, Netflix, etc. • Performance in the top rank for Python • 3rd most used (Python Developers Survey) • Fastest growth (Python Developers Survey) • 3rd most loved (StackOverflow Developer Survey) @tiangolo
• OpenAPI • JSON Schema • OAuth2 🔄 Automatic data
conversion ✨ ✅ Automatic data validation ✨ FastAPI is based on standards 📝 Automatic API docs ✨ • Standard type annotations @tiangolo
Based on standards - for free @tiangolo
Based on Python type hints • Autocompletion everywhere • Type
checks and type errors @tiangolo
Types provide autocompletion @tiangolo
Easy and short @tiangolo
Less API code @tiangolo
Basic FastAPI app @tiangolo https://somedomain.com/items/5?q=some+query
Basic FastAPI app - docs @tiangolo https://somedomain.com/docs
Automatic docs @tiangolo
Basic FastAPI app with body @tiangolo
Basic FastAPI app with body - docs @tiangolo
Basic FastAPI app with body - docs @tiangolo
Basic FastAPI app with body @tiangolo
Basic FastAPI app with body and query @tiangolo
Basic FastAPI app with body and query - docs @tiangolo
https://somedomain.com/food/?delivery=true
Basic FastAPI app with body and query @tiangolo
JSON array of objects in body @tiangolo
JSON array of objects in body - docs @tiangolo
JSON array of objects in body @tiangolo
JSON array of objects in body - invalid data @tiangolo
JSON array of objects in body - validation @tiangolo
Data validation @tiangolo
FastAPI auto-completion @tiangolo
Type checks @tiangolo
All based on standard Python types @tiangolo
FastAPI - Performance @tiangolo
FastAPI - Performance @tiangolo
FastAPI - Other features @tiangolo • Dependency Injection • Security
- OAuth2 • WebSockets • Files • Background Tasks • Easy GraphQL integration • Templates • More...
Simple ML model and usage 🤖 @tiangolo
Load ML models - slow disk reads 🤖 @tiangolo ✨
Read from disk as few times as possible ✨
Load ML models - slow disk reads 🤖 @tiangolo
Simple ML model - only load 🤖 @tiangolo
ML model in FastAPI - simple - good ✅ @tiangolo
ML model in FastAPI - bad 🚨 @tiangolo
ML model in FastAPI - very bad 🚨 @tiangolo
ML model in FastAPI - very bad 🚨 @tiangolo
Load model and cache 😎 @tiangolo
FastAPI with cached model ⚡ @tiangolo
FastAPI with cached model ⚡ @tiangolo
FastAPI - preload cached model in healthcheck ⚡ @tiangolo
FastAPI - preload ⚡ @tiangolo
FastAPI - async and models - bad 🚨 @tiangolo
FastAPI - async and models - bad 🚨 @tiangolo
Blocking code in async blocks the event loop 😱 @tiangolo
✨ Don’t put blocking code directly in async functions ✨
FastAPI - non async and models - simple - good
✅ @tiangolo
FastAPI - non async and models - simple - good
✅ @tiangolo
FastAPI - async and models - good ✅ @tiangolo
FastAPI - async and models - good ✅ @tiangolo
FastAPI - model in dependency ✨ @tiangolo
FastAPI - model in dependency - testing ✅ @tiangolo
FastAPI - model in dependency - testing ✅ @tiangolo
FastAPI - squeeze performance 🚤 @tiangolo
FastAPI - squeeze performance 🚤 @tiangolo
None
Thank you! Sebastián Ramírez tiangolo.com fastapi.tiangolo.com github.com/tiangolo linkedin.com/in/tiangolo twitter.com/tiangolo