mirror of
https://github.com/StefBuwalda/ProjectIOT.git
synced 2025-10-29 18:59:57 +00:00
Sped up ANPR
Sped up ANPR by only creating one ANPR instance, rather than initializing a new one every function call.
This commit is contained in:
Binary file not shown.
@@ -12,6 +12,7 @@ torch.serialization.add_safe_globals( # type: ignore
|
||||
{"DetectionModel": DetectionModel} # type: ignore
|
||||
)
|
||||
|
||||
anpr = ANPR()
|
||||
|
||||
# Saving images locally
|
||||
UPLOAD_FOLDER = "uploads"
|
||||
@@ -32,7 +33,7 @@ def data():
|
||||
with open("image.jpg", "wb") as f:
|
||||
f.write(data)
|
||||
|
||||
status = asyncio.run(process_image("image.jpg"))
|
||||
status = asyncio.run(process_image(file="image.jpg", anpr=anpr))
|
||||
return jsonify(
|
||||
{
|
||||
"message": "Image sent succesfully",
|
||||
@@ -41,9 +42,8 @@ def data():
|
||||
)
|
||||
|
||||
|
||||
async def process_image(file: str) -> bool:
|
||||
async def process_image(file: str, anpr: ANPR) -> bool:
|
||||
print("Processing image")
|
||||
anpr = ANPR()
|
||||
anpr_info = await anpr.detect(file) # type: ignore
|
||||
number_plate = anpr_info["plate_number"]
|
||||
if number_plate:
|
||||
|
||||
Reference in New Issue
Block a user