# FastAPI Inference 服务

## 概述
这是一个 FastAPI 应用，实现了 `/inference` 接口，模拟返回 3 张用 Pillow 生成的纯色占位图。

## 文件位置
- 应用代码: `/home/ubuntu/fastapi_inference/app.py`
- 服务器 PID: `/home/ubuntu/fastapi_inference/server.pid`

## 接口说明

### 1. 根路径 `/`
返回服务基本信息
```bash
curl http://localhost:8001/
```

### 2. `/inference` (主接口)
返回 3 张纯色占位图中的第一张（红色）
```bash
curl -o image.png http://localhost:8001/inference
```

### 3. `/inference/{index}` 
根据索引返回特定图片 (1-3)
- 1: 红色图片 (RGB: 255, 100, 100)
- 2: 绿色图片 (RGB: 100, 255, 100)
- 3: 蓝色图片 (RGB: 100, 100, 255)

```bash
curl -o image1.png http://localhost:8001/inference/1  # 红色
curl -o image2.png http://localhost:8001/inference/2  # 绿色
curl -o image3.png http://localhost:8001/inference/3  # 蓝色
```

### 4. `/inference/all`
返回所有 3 张图片的信息（包含 base64 编码）
```bash
curl http://localhost:8001/inference/all
```

## 服务器管理

### 停止服务器
```bash
kill $(cat /home/ubuntu/fastapi_inference/server.pid)
```

### 重新启动服务器
```bash
cd /home/ubuntu/fastapi_inference
python3 app.py
```

## 依赖
- FastAPI
- Uvicorn
- Pillow (PIL)

## 图片规格
- 尺寸: 512x512 像素
- 格式: PNG
- 类型: 纯色占位图

## 测试
所有接口已测试通过，服务器运行在端口 8001。
