mirror of
https://github.com/StefBuwalda/ProjectIOT.git
synced 2026-02-04 17:14:49 +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
|
{"DetectionModel": DetectionModel} # type: ignore
|
||||||
)
|
)
|
||||||
|
|
||||||
|
anpr = ANPR()
|
||||||
|
|
||||||
# Saving images locally
|
# Saving images locally
|
||||||
UPLOAD_FOLDER = "uploads"
|
UPLOAD_FOLDER = "uploads"
|
||||||
@@ -32,7 +33,7 @@ def data():
|
|||||||
with open("image.jpg", "wb") as f:
|
with open("image.jpg", "wb") as f:
|
||||||
f.write(data)
|
f.write(data)
|
||||||
|
|
||||||
status = asyncio.run(process_image("image.jpg"))
|
status = asyncio.run(process_image(file="image.jpg", anpr=anpr))
|
||||||
return jsonify(
|
return jsonify(
|
||||||
{
|
{
|
||||||
"message": "Image sent succesfully",
|
"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")
|
print("Processing image")
|
||||||
anpr = ANPR()
|
|
||||||
anpr_info = await anpr.detect(file) # type: ignore
|
anpr_info = await anpr.detect(file) # type: ignore
|
||||||
number_plate = anpr_info["plate_number"]
|
number_plate = anpr_info["plate_number"]
|
||||||
if number_plate:
|
if number_plate:
|
||||||
|
|||||||
Reference in New Issue
Block a user