Added evolution detection
Browse files- app/main.py +1 -0
- app/schemas.py +1 -0
- app/services/ocr_service.py +3 -0
app/main.py
CHANGED
|
@@ -74,6 +74,7 @@ async def predict(file: UploadFile = File(...)):
|
|
| 74 |
moves=ocr_data.get("moves"),
|
| 75 |
length=ocr_data.get("length"),
|
| 76 |
weight=ocr_data.get("weight"),
|
|
|
|
| 77 |
similar_cards=similar_cards
|
| 78 |
)
|
| 79 |
except Exception as e:
|
|
|
|
| 74 |
moves=ocr_data.get("moves"),
|
| 75 |
length=ocr_data.get("length"),
|
| 76 |
weight=ocr_data.get("weight"),
|
| 77 |
+
is_evolved=ocr_data.get("is_evolved"),
|
| 78 |
similar_cards=similar_cards
|
| 79 |
)
|
| 80 |
except Exception as e:
|
app/schemas.py
CHANGED
|
@@ -38,4 +38,5 @@ class CardResponse(BaseModel):
|
|
| 38 |
moves: Optional[list[Move]] = None
|
| 39 |
length: Optional[str] = None
|
| 40 |
weight: Optional[str] = None
|
|
|
|
| 41 |
similar_cards: list[SimilarCard] = []
|
|
|
|
| 38 |
moves: Optional[list[Move]] = None
|
| 39 |
length: Optional[str] = None
|
| 40 |
weight: Optional[str] = None
|
| 41 |
+
is_evolved: Optional[bool] = None
|
| 42 |
similar_cards: list[SimilarCard] = []
|
app/services/ocr_service.py
CHANGED
|
@@ -90,6 +90,7 @@ class OCRService:
|
|
| 90 |
"moves": self._extract_moves(moves_region),
|
| 91 |
"length": self._extract_length(length_weight_region),
|
| 92 |
"weight": self._extract_weight(length_weight_region),
|
|
|
|
| 93 |
}
|
| 94 |
|
| 95 |
|
|
@@ -240,12 +241,14 @@ class OCRService:
|
|
| 240 |
"HP": (0.55 * w, 0.04 * h, 0.97 * w, 0.13 * h),
|
| 241 |
"Length/Weight": (0.05 * w, 0.52 * h, 0.95 * w, 0.58 * h),
|
| 242 |
"Moves": (0.02 * w, 0.57 * h, 0.98 * w, 0.88 * h),
|
|
|
|
| 243 |
}
|
| 244 |
colors = {
|
| 245 |
"Name": "red",
|
| 246 |
"HP": "blue",
|
| 247 |
"Length/Weight": "orange",
|
| 248 |
"Moves": "green",
|
|
|
|
| 249 |
}
|
| 250 |
|
| 251 |
for label, box in regions.items():
|
|
|
|
| 90 |
"moves": self._extract_moves(moves_region),
|
| 91 |
"length": self._extract_length(length_weight_region),
|
| 92 |
"weight": self._extract_weight(length_weight_region),
|
| 93 |
+
"is_evolved": self._is_evolved(image)
|
| 94 |
}
|
| 95 |
|
| 96 |
|
|
|
|
| 241 |
"HP": (0.55 * w, 0.04 * h, 0.97 * w, 0.13 * h),
|
| 242 |
"Length/Weight": (0.05 * w, 0.52 * h, 0.95 * w, 0.58 * h),
|
| 243 |
"Moves": (0.02 * w, 0.57 * h, 0.98 * w, 0.88 * h),
|
| 244 |
+
"is_evolved": (0, 0, 0.35 * w, 0.12 * h)
|
| 245 |
}
|
| 246 |
colors = {
|
| 247 |
"Name": "red",
|
| 248 |
"HP": "blue",
|
| 249 |
"Length/Weight": "orange",
|
| 250 |
"Moves": "green",
|
| 251 |
+
"Is Evolved": "black"
|
| 252 |
}
|
| 253 |
|
| 254 |
for label, box in regions.items():
|