fix: add package
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -70,4 +70,4 @@ htmlcov/
|
|||||||
# uv
|
# uv
|
||||||
uv.lock
|
uv.lock
|
||||||
|
|
||||||
model/*
|
model/
|
||||||
|
|||||||
@@ -34,4 +34,3 @@ async def convert_markdown_to_docx(
|
|||||||
media_type="application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
media_type="application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||||
headers={"Content-Disposition": f'attachment; filename="{filename}"'},
|
headers={"Content-Disposition": f'attachment; filename="{filename}"'},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from functools import lru_cache
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||||
|
import torch
|
||||||
|
|
||||||
|
|
||||||
class Settings(BaseSettings):
|
class Settings(BaseSettings):
|
||||||
@@ -23,13 +24,15 @@ class Settings(BaseSettings):
|
|||||||
paddleocr_vl_url: str = "http://localhost:8080/v1"
|
paddleocr_vl_url: str = "http://localhost:8080/v1"
|
||||||
|
|
||||||
# Model Paths
|
# Model Paths
|
||||||
doclayout_model_path: str = "app/model/DocLayout"
|
doclayout_model_path: str = "app/model/DocLayout/best.pt"
|
||||||
pp_doclayout_model_dir: str = "app/model/PP-DocLayout"
|
pp_doclayout_model_dir: str = "app/model/PP-DocLayout/PP-DocLayoutV2"
|
||||||
|
|
||||||
# Image Processing
|
# Image Processing
|
||||||
max_image_size_mb: int = 10
|
max_image_size_mb: int = 10
|
||||||
image_padding_ratio: float = 0.15 # 15% on each side = 30% total expansion
|
image_padding_ratio: float = 0.15 # 15% on each side = 30% total expansion
|
||||||
|
|
||||||
|
device: torch.device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") # cuda:0 or cpu
|
||||||
|
|
||||||
# Server Settings
|
# Server Settings
|
||||||
host: str = "0.0.0.0"
|
host: str = "0.0.0.0"
|
||||||
port: int = 8053
|
port: int = 8053
|
||||||
@@ -49,4 +52,3 @@ class Settings(BaseSettings):
|
|||||||
def get_settings() -> Settings:
|
def get_settings() -> Settings:
|
||||||
"""Get cached settings instance."""
|
"""Get cached settings instance."""
|
||||||
return Settings()
|
return Settings()
|
||||||
|
|
||||||
|
|||||||
@@ -136,4 +136,3 @@ class ImageProcessor:
|
|||||||
buffer.seek(0)
|
buffer.seek(0)
|
||||||
|
|
||||||
return base64.b64encode(buffer.getvalue()).decode("utf-8")
|
return base64.b64encode(buffer.getvalue()).decode("utf-8")
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from app.schemas.image import LayoutInfo, LayoutRegion
|
from app.schemas.image import LayoutInfo, LayoutRegion
|
||||||
|
from app.core.config import get_settings
|
||||||
|
|
||||||
|
settings = get_settings()
|
||||||
|
|
||||||
|
|
||||||
class LayoutDetector:
|
class LayoutDetector:
|
||||||
@@ -73,7 +76,7 @@ class LayoutDetector:
|
|||||||
image,
|
image,
|
||||||
imgsz=image_size,
|
imgsz=image_size,
|
||||||
conf=self.confidence_threshold,
|
conf=self.confidence_threshold,
|
||||||
device="cuda:0",
|
device=settings.device,
|
||||||
)
|
)
|
||||||
|
|
||||||
regions: list[LayoutRegion] = []
|
regions: list[LayoutRegion] = []
|
||||||
|
|||||||
Reference in New Issue
Block a user