Reverted image input type
Browse files- app/main.py +3 -3
- 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(
|
| 54 |
try:
|
| 55 |
-
image_bytes =
|
| 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] = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|