File size: 944 Bytes
e484a46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# from fastapi import FastAPI, HTTPException
from fastapi import FastAPI
from pydantic import BaseModel
# import torch

# from backend.inference_utils import load_model, run_inference

# -- FastAPI app --
app = FastAPI()

# -- Input Schema --
class InferenceRequest(BaseModel):
    model_name: str
    spectrum: list[float]

@app.get("/")
def root():
    return {"message": "Polymer Aging Inference API is online"}

@app.post("/infer")
def infer(request: InferenceRequest):
    return{
        "prediction": "Stubbed Output",
        "class_index": 0,
        "logits": [0.0, 1.0],
        "class_labels": ["Stub", "Output"],
    }
# def infer(request: InferenceRequest):
#     try:
#         model = load_model(request.model_name)
#         result = run_inference(model, request.spectrum)
#         return result
#     except Exception as e:
#         raise HTTPException(status_code=500, detail=str(e)) from e