dcorcoran commited on
Commit
7c54e82
·
1 Parent(s): 48a587a

Reverted image input type

Browse files
Files changed (2) hide show
  1. app/main.py +3 -3
  2. app/schemas.py +1 -10
app/main.py CHANGED
@@ -1,4 +1,4 @@
1
- from fastapi import FastAPI
2
  from fastapi.middleware.cors import CORSMiddleware
3
  from fastapi.responses import JSONResponse
4
 
@@ -50,9 +50,9 @@ def health():
50
 
51
 
52
  @app.post("/predict", response_model=CardResponse)
53
- async def predict(payload: ImagePayload):
54
  try:
55
- image_bytes = base64.b64decode(payload.image_b64) # <-- decode base64
56
  image = Image.open(io.BytesIO(image_bytes)).convert("RGB")
57
 
58
  embedding = app.state.embedding_service.embed(image)
 
1
+ from fastapi import FastAPI, File, UploadFile
2
  from fastapi.middleware.cors import CORSMiddleware
3
  from fastapi.responses import JSONResponse
4
 
 
50
 
51
 
52
  @app.post("/predict", response_model=CardResponse)
53
+ async def predict(file: UploadFile = File(...)):
54
  try:
55
+ image_bytes = await file.read()
56
  image = Image.open(io.BytesIO(image_bytes)).convert("RGB")
57
 
58
  embedding = app.state.embedding_service.embed(image)
app/schemas.py CHANGED
@@ -36,13 +36,4 @@ class CardResponse(BaseModel):
36
  hp: Optional[str] = None
37
  types: Optional[list[str]] = None
38
  moves: Optional[list[Move]] = None
39
- similar_cards: list[SimilarCard] = []
40
-
41
-
42
- # --------------------------------
43
- # ----- IMAGE PAYLOAD ------------
44
- # --------------------------------
45
-
46
- class ImagePayload(BaseModel):
47
- image_b64: str
48
- filename: str
 
36
  hp: Optional[str] = None
37
  types: Optional[list[str]] = None
38
  moves: Optional[list[Move]] = None
39
+ similar_cards: list[SimilarCard] = []