refactor backend for minor improvements
Browse files
Backend/agents/vision/agent.py
CHANGED
|
@@ -168,7 +168,7 @@ class VisionAgent(BaseAgent):
|
|
| 168 |
gemini_category = None
|
| 169 |
gemini_confidence = 0.0
|
| 170 |
gemini_reasoning = None
|
| 171 |
-
if self.gemini_model and
|
| 172 |
gemini_category, gemini_confidence, gemini_reasoning = await self.gemini_classify_image(
|
| 173 |
image_data=image_data,
|
| 174 |
description=description
|
|
|
|
| 168 |
gemini_category = None
|
| 169 |
gemini_confidence = 0.0
|
| 170 |
gemini_reasoning = None
|
| 171 |
+
if self.gemini_model and detections and max(d.confidence for d in detections) < 0.5:
|
| 172 |
gemini_category, gemini_confidence, gemini_reasoning = await self.gemini_classify_image(
|
| 173 |
image_data=image_data,
|
| 174 |
description=description
|
Backend/agents/vision/model.pt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b3ec8d59f0db26383a08fb3e132261495ea069a7a32546b1ff142ba375f28edc
|
| 3 |
+
size 22538026
|
Backend/core/config.py
CHANGED
|
@@ -38,6 +38,13 @@ class Settings(BaseSettings):
|
|
| 38 |
api_host: str = "0.0.0.0"
|
| 39 |
api_port: int = 8000
|
| 40 |
api_workers: int = 4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
max_upload_size_mb: int = 10
|
| 43 |
allowed_extensions: set[str] = {"jpg", "jpeg", "png", "webp"}
|
|
|
|
| 38 |
api_host: str = "0.0.0.0"
|
| 39 |
api_port: int = 8000
|
| 40 |
api_workers: int = 4
|
| 41 |
+
|
| 42 |
+
db_pool_size: int = 5
|
| 43 |
+
db_max_overflow: int = 5
|
| 44 |
+
db_pool_timeout: int = 30
|
| 45 |
+
db_pool_recycle: int = 1800
|
| 46 |
+
db_statement_cache_size: int = 0
|
| 47 |
+
db_prepared_statement_cache_size: int = 0
|
| 48 |
|
| 49 |
max_upload_size_mb: int = 10
|
| 50 |
allowed_extensions: set[str] = {"jpg", "jpeg", "png", "webp"}
|
Backend/database/connection.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
from contextlib import asynccontextmanager
|
| 2 |
from typing import AsyncGenerator
|
| 3 |
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
|
| 4 |
-
from sqlalchemy.pool import NullPool
|
| 5 |
|
| 6 |
from Backend.core.config import settings
|
| 7 |
|
|
@@ -9,11 +8,15 @@ database_url = settings.database_url.replace("postgresql://", "postgresql+asyncp
|
|
| 9 |
|
| 10 |
engine = create_async_engine(
|
| 11 |
database_url,
|
| 12 |
-
poolclass=NullPool,
|
| 13 |
echo=False,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
connect_args={
|
| 15 |
-
"statement_cache_size":
|
| 16 |
-
"prepared_statement_cache_size":
|
| 17 |
},
|
| 18 |
)
|
| 19 |
|
|
|
|
| 1 |
from contextlib import asynccontextmanager
|
| 2 |
from typing import AsyncGenerator
|
| 3 |
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
|
|
|
|
| 4 |
|
| 5 |
from Backend.core.config import settings
|
| 6 |
|
|
|
|
| 8 |
|
| 9 |
engine = create_async_engine(
|
| 10 |
database_url,
|
|
|
|
| 11 |
echo=False,
|
| 12 |
+
pool_size=settings.db_pool_size,
|
| 13 |
+
max_overflow=settings.db_max_overflow,
|
| 14 |
+
pool_timeout=settings.db_pool_timeout,
|
| 15 |
+
pool_recycle=settings.db_pool_recycle,
|
| 16 |
+
pool_pre_ping=True,
|
| 17 |
connect_args={
|
| 18 |
+
"statement_cache_size": settings.db_statement_cache_size,
|
| 19 |
+
"prepared_statement_cache_size": settings.db_prepared_statement_cache_size,
|
| 20 |
},
|
| 21 |
)
|
| 22 |
|
Backend/utils/fuzzy_match.py
CHANGED
|
@@ -28,7 +28,7 @@ CATEGORY_KEYWORDS: dict[str, list[str]] = {
|
|
| 28 |
],
|
| 29 |
"Vandalism Issues": [
|
| 30 |
"vandal", "graffiti", "spray", "paint", "defaced",
|
| 31 |
-
"smashed", "destroyed", "
|
| 32 |
],
|
| 33 |
"Dead Animal Pollution": [
|
| 34 |
"dead", "animal", "carcass", "body", "corpse", "rotting", "smell",
|
|
@@ -36,7 +36,7 @@ CATEGORY_KEYWORDS: dict[str, list[str]] = {
|
|
| 36 |
],
|
| 37 |
"Damaged Concrete Structures": [
|
| 38 |
"concrete", "structure", "wall", "pillar", "bridge", "flyover",
|
| 39 |
-
"footpath", "sidewalk", "curb", "crack", "broken"
|
| 40 |
],
|
| 41 |
"Damaged Electric Wires and Poles": [
|
| 42 |
"electric", "wire", "pole", "cable", "power", "electricity",
|
|
|
|
| 28 |
],
|
| 29 |
"Vandalism Issues": [
|
| 30 |
"vandal", "graffiti", "spray", "paint", "defaced",
|
| 31 |
+
"smashed", "destroyed", "torn"
|
| 32 |
],
|
| 33 |
"Dead Animal Pollution": [
|
| 34 |
"dead", "animal", "carcass", "body", "corpse", "rotting", "smell",
|
|
|
|
| 36 |
],
|
| 37 |
"Damaged Concrete Structures": [
|
| 38 |
"concrete", "structure", "wall", "pillar", "bridge", "flyover",
|
| 39 |
+
"footpath", "sidewalk", "curb", "crack", "broken", "Damaged Concrete"
|
| 40 |
],
|
| 41 |
"Damaged Electric Wires and Poles": [
|
| 42 |
"electric", "wire", "pole", "cable", "power", "electricity",
|