|
1 | 1 | from fastapi import FastAPI, File, UploadFile |
2 | 2 | from fire_classifier.predictor import ImagePredictor |
| 3 | +from fire_classifier.util.api import API |
3 | 4 |
|
4 | | -# A: define description for the API endpoints (shown on UI) |
5 | | -endpoint_metadata = [ |
6 | | - { |
7 | | - "name": "classify-image", |
8 | | - "description": "Predicts the possibility that a RBG image contains fire.", |
9 | | - }, |
10 | | -] |
11 | | -# B: init API |
12 | | -app = FastAPI( |
13 | | - title="DeepFire", |
14 | | - description="A REST API for detecting the presence of fire in an image.", |
15 | | - version="0.0.2", |
16 | | - openapi_tags=endpoint_metadata, |
17 | | -) |
| 5 | +# A: init API |
| 6 | +app = FastAPI(title=API["title"], description=API["description"], |
| 7 | + version=API["version"], openapi_tags=API["endpoints"]) |
18 | 8 |
|
19 | | -# C: init ML inference object |
20 | | -predictor_config_path = "./app/config.yaml" |
| 9 | +# B: init ML inference object, and the routes |
| 10 | +predictor_config_path = API["config_path"] |
21 | 11 | predictor = ImagePredictor.init_from_config_path(predictor_config_path) |
22 | 12 |
|
23 | 13 |
|
24 | | -@app.post("/classify-image/", tags=["classify-image"]) |
| 14 | +@app.post("/classify-image/", tags=["Detect Fire"]) |
25 | 15 | def create_upload_file(file: UploadFile = File(...)): |
26 | 16 | """Predicts the possibility that a RBG image contains fire.""" |
27 | 17 | return predictor.predict_from_file(file.file) |
0 commit comments