FastAPI for Machine Learning: Live coding an ML web application
FastAPI for Machine Learning: Live coding an ML web application
https://www.bilibili.com/video/BV1kC411b7Se/?spm_id_from=333.788.videopod.sections&vd_source=57e261300f39bf692de396b55bf8c41b
翻译:FastAPI用于机器学习:现场编码一个ML Web应用程序。欢迎!加入我们的现场研讨会,您可以跟随FastAPI的创建者Sebastián Ramírez一起构建自己的AI图像生成Web应用程序!他将概述FastAPI Web框架的核心组件,并且他的应用程序将利用新发布的Stable Diffusion文本到图像深度学习模型。
https://www.linkedin.com/events/fastapiformachinelearning-livec7006333565051293696/comments/
Join us for a live workshop where you can follow along with the creator of FastAPI Sebastián Ramírez to build your very own AI image generation web application! He will outline the core components of the FastAPI web framework, and his application will leverage the newly-released Stable Diffusion text-to-image deep learning model.
Who should attend the event?
- Learners who want to build AI applications with FastAPI
- Learners who want to understand FastAPI’s architecture
- Learners who are interested in Python API web frameworks
Why should you attend the event?
- To learn how to build ML web applications in Python
- To see an example of a Stable Diffusion application
- To learn about FastAPI directly from the creator!
https://github.com/FourthBrain/FastAPI-for-Machine-Learning-Live-Demo/blob/main/main.py
This repository contains the files to build your very own AI image generation web application! Outlined are the core components of the FastAPI web framework, and application leverage the newly-released Stable Diffusion text-to-image deep learning model.
📺 You can checkout the full video here!
流式内存响应图片给客户端
import io from fastapi import FastAPI from fastapi.responses import FileResponse, StreamingResponse from pydantic import BaseModel from ml import obtain_image app = FastAPI() @app.get("/") def read_root(): return {"Hello": "World"} @app.get("/items/{item_id}") def read_item(item_id: int): return {"item_id": item_id} class Item(BaseModel): name: str price: float tags: list[str] = [] @app.post("/items/") def create_item(item: Item): return item @app.get("/generate") def generate_image( prompt: str, *, seed: int | None = None, num_inference_steps: int = 50, guidance_scale: float = 7.5 ): image = obtain_image( prompt, num_inference_steps=num_inference_steps, seed=seed, guidance_scale=guidance_scale, ) image.save("image.png") return FileResponse("image.png") @app.get("/generate-memory") def generate_image_memory( prompt: str, *, seed: int | None = None, num_inference_steps: int = 50, guidance_scale: float = 7.5 ): image = obtain_image( prompt, num_inference_steps=num_inference_steps, seed=seed, guidance_scale=guidance_scale, ) memory_stream = io.BytesIO() image.save(memory_stream, format="PNG") memory_stream.seek(0) return StreamingResponse(memory_stream, media_type="image/png")
Building a Machine Learning Microservice with FastAPI
https://developer.nvidia.com/blog/building-a-machine-learning-microservice-with-fastapi/
https://developer.nvidia.com/zh-cn/blog/how-to-build-an-instant-machine-learning-web-application-with-streamlit-and-fastapi/
https://github.com/kurtispykes/car-evaluation-project/blob/Main/packages/car_evaluation_model/car_evaluation_model/predict.py
The purpose behind this project was to demonstrate how to build an instant machine learning application with Streamlit - this is great for rapid prototyping. To achieve this I created a simple classification model on the Car Evaluation Dataset from the UCI Machine Learning Repository. By following along with the articles below, you will learn how to: create a machine learning microservice, create a front end for your machine learning model, and how to wire the two applications together using Docker and Docker-compose. The GIF below is a demonstration of how the application works.
These instructions assume that you already have Docker and Docker-compose installed on your machine - if not, please follow the instructions here.
- Clone this repository to your computer
- Navigate to the root of the project:
cd car-evaluation-project- Build the docker images using
docker-compose up -d --build
- This may take a minute
- Open your browser and navigate to http://localhost:8501 to use the application.
- Conduct analysis of the data to build a better classification model
- Set up monitoring for the machine learning model
- Deploy on the cloud




浙公网安备 33010602011771号