Creating APIs For Machine Learning Models with FastAPI

  Рет қаралды 15,854

NeuralNine

NeuralNine

Күн бұрын

Today we learn how to easily turn machine learning models into usable APIs using FastAPI in Python.
◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
📚 Programming Books & Merch 📚
🐍 The Python Bible Book: www.neuralnine.com/books/
💻 The Algorithm Bible Book: www.neuralnine.com/books/
👕 Programming Merch: www.neuralnine.com/shop
💼 Services 💼
💻 Freelancing & Tutoring: www.neuralnine.com/services
🌐 Social Media & Contact 🌐
📱 Website: www.neuralnine.com/
📷 Instagram: / neuralnine
🐦 Twitter: / neuralnine
🤵 LinkedIn: / neuralnine
📁 GitHub: github.com/NeuralNine
🎙 Discord: / discord

Пікірлер: 26
@khandoor7228
@khandoor7228 3 ай бұрын
This was excellent, the capabilities this opens up is really powerful. Good job as always.
@omegasigma4500
@omegasigma4500 3 ай бұрын
I'm glad you uploaded a video about FastAPI. We prefer it over Flask. There are 2 topics where we need some help. 1.) Hosting - How to deploy the app so that other can access it via web? And how to manage the cloud infrastructure? 2.) Frontend - There are now plenty of frameworks and libraries. The standard approach is probably JavaScript, HTML and CSS. But I'm wondering what you think about pure Python libraries like Taipy, FastUI and reflex. What do you think is the best approach here? We would highly appreciate your input. Thanks! Keep up the great work! 💪💪👍👍
@timothyelems1357
@timothyelems1357 3 ай бұрын
Exactly what I was looking for! Thanks man!
@dipeshsamrawat7957
@dipeshsamrawat7957 3 ай бұрын
You are making requested videos. Thank you 💯
@TheDigitalSight
@TheDigitalSight 3 ай бұрын
We use FastAPI more than django and flask, can you please create video on langchain and fastapi as well?
@user-lg6dl7gr9e
@user-lg6dl7gr9e 3 ай бұрын
+1
@cheukmingau983
@cheukmingau983 3 ай бұрын
In production the async endpoint should not be used. An async function (coroutine) will be executed in the main thread event loop, and like the event loop in JS inside the browser, it can only execute one coroutine at a time. Running the synchronous, cpu intensive `model.predict` inside the async endpoint will make your prediction endpoint frozen and wait for the underlying cpu predicting the images, so the QPS of your handler is at most one. Better options could be: 1) Using a synchronous function as the inference endpoint, 2) create a threadpoolexecutor outside of the async function, and use `loop.run_in_executor()` with the threadpoolexecutor declared as it will run the model inside the thread, or 3) use poolexecutor similar to option 2. The problem for option 3 is that multiprocesses requires pickling and you might have to tweak your model case by case. Also, pickling the model and deserialize in the application api server doesn't reveal the identity and method signatures of that model. If you are the only one who train and deploy that might not be a big problem, but in production you might want to use some inferencing frameworks like Onnxruntime which you just serialize your trained model to the preferred format first (onnxruntime has a very small package size compared to other DL libraries which makes the deployment dependency smaller). Lastly, running scikit-learn model in python doesn't utilize the all the cores in your cpu, whereas other packages usually have higher utilization proportion. I understand that the model in this video is small in size and is a POC, so with the small size running async and pickling is fine. However, for just some even better CV and NLP models (e.g. BERT) it is nearly impossible to adopt the same approach as in this tutorial.
@alexandrosmaragkakis737
@alexandrosmaragkakis737 3 ай бұрын
@cheukmingau983 hello, I'm currently facing a problem very similar to what you described, is there somewhere I can message you to get more info on this?
@cheukmingau983
@cheukmingau983 3 ай бұрын
@@alexandrosmaragkakis737 perhaps here? You can state your situation just with the minimal details
@NomadicBrian
@NomadicBrian 22 күн бұрын
I've been using fastAPI for a couple of years now. Just starting with AI models. I had planned on calling models with fastAPI. See if I can do that with a ViT model I've been working with.
@smstudio1035
@smstudio1035 3 ай бұрын
Can we see a hosting video off the same
@zedcodes
@zedcodes 3 ай бұрын
Why do I have this error: 'module 'PIL.Image' has no attribute 'ANTIALIAS''? @10:41
@bobfreeman7349
@bobfreeman7349 3 ай бұрын
ANTIALIAS was removed in Pillow 10.0.0 (after being deprecated through many previous versions). Now you need to use PIL.Image.LANCZOS or PIL.Image.Resampling.LANCZOS. (This is the exact same algorithm that ANTIALIAS referred to, you just can no longer access it through the name ANTIALIAS.)
@zedcodes
@zedcodes 3 ай бұрын
@@bobfreeman7349 That worked, thank you. I used this and it worked: pil_image = pil_image.resize((28, 28), PIL.Image.LANCZOS)
@thelifehackerpro9943
@thelifehackerpro9943 3 ай бұрын
why not use model directly instead of pickle?
@tthcan8038
@tthcan8038 3 ай бұрын
Pickle makes your model remember the weights, so you need to fit only once
@Hardy_21
@Hardy_21 3 ай бұрын
For me it correctly guesses only numbers 4, 6. For the rest it says they're 7 or 5.
@ebenezervictor7297
@ebenezervictor7297 Ай бұрын
I like this guy
@DougSteinberg7410
@DougSteinberg7410 Ай бұрын
Great video! I'm a web developer and new to ML. Do you have the source code for this project in a Github repo? I would really love to try this out locally.
@Lyphnet
@Lyphnet 3 ай бұрын
Please ensure that your Discord server remains joinable. Thanks!
@tcgvsocg1458
@tcgvsocg1458 3 ай бұрын
i am not entire sur i understand how that worst but thx a lot for the video
@systembreaker4651
@systembreaker4651 3 ай бұрын
What is your daily Linux distro ❤
@Wanhatoman
@Wanhatoman 3 ай бұрын
popOs
@samstar1290
@samstar1290 3 ай бұрын
Arch linux hyprland
@kmano2915
@kmano2915 3 ай бұрын
He is using Linux mint . I am using ubuntu
How to Use FastAPI: A Detailed Python Tutorial
20:38
ArjanCodes
Рет қаралды 221 М.
ML Was Hard Until I Learned These 5 Secrets!
13:11
Boris Meinardus
Рет қаралды 245 М.
🤔Какой Орган самый длинный ? #shorts
00:42
НРАВИТСЯ ЭТОТ ФОРМАТ??
00:37
МЯТНАЯ ФАНТА
Рет қаралды 1,5 МЛН
تجربة أغرب توصيلة شحن ضد القطع تماما
00:56
صدام العزي
Рет қаралды 58 МЛН
How To Create a Python API With FastAPI - Full Tutorial
25:39
Tech With Tim
Рет қаралды 35 М.
Deploy ML model in 10 minutes. Explained
12:41
Danil Zherebtsov
Рет қаралды 12 М.
FINALLY Some Success!!! - Coding Challenges
51:32
NeuralNine
Рет қаралды 2,7 М.
Building A Simple REST API with FastAPI in Python
37:12
NeuralNine
Рет қаралды 45 М.
Python FastAPI Tutorial: Build a REST API in 15 Minutes
15:16
Deploy ML models with FastAPI, Docker, and Heroku | Tutorial
18:45
Fine-Tuning GPT Models with Python
23:14
NeuralNine
Рет қаралды 9 М.
All Learning Algorithms Explained in 14 Minutes
14:10
CinemaGuess
Рет қаралды 200 М.
Movie Recommender System in Python with LLMs
25:01
NeuralNine
Рет қаралды 6 М.
Schedule Automatic Tasks in Flask with APScheduler
10:57
NeuralNine
Рет қаралды 4,3 М.
Самые крутые школьные гаджеты
0:49
ГОСЗАКУПОЧНЫЙ ПК за 10 тысяч рублей
36:28
Ремонтяш
Рет қаралды 537 М.
Как правильно выключать звук на телефоне?
0:17
Люди.Идеи, общественная организация
Рет қаралды 1,8 МЛН
Копия iPhone с WildBerries
1:00
Wylsacom
Рет қаралды 2,4 МЛН