Initial Real-ESRGAN API project setup

This commit is contained in:
Developer
2026-02-16 19:56:25 +01:00
commit 0e59652575
34 changed files with 3668 additions and 0 deletions

1
app/schemas/__init__.py Normal file
View File

@@ -0,0 +1 @@
"""Pydantic schemas for request/response validation."""

37
app/schemas/health.py Normal file
View File

@@ -0,0 +1,37 @@
"""Schemas for health check and system information."""
from typing import Optional
from pydantic import BaseModel
class HealthResponse(BaseModel):
"""API health check response."""
status: str
version: str
uptime_seconds: float
message: str
class SystemInfo(BaseModel):
"""System information."""
status: str
version: str
uptime_seconds: float
cpu_usage_percent: float
memory_usage_percent: float
disk_usage_percent: float
gpu_available: bool
gpu_memory_mb: Optional[int] = None
gpu_memory_used_mb: Optional[int] = None
execution_providers: list
models_dir_size_mb: float
jobs_queue_length: int
class RequestStats(BaseModel):
"""API request statistics."""
total_requests: int
successful_requests: int
failed_requests: int
average_processing_time_seconds: float
total_images_processed: int

31
app/schemas/models.py Normal file
View File

@@ -0,0 +1,31 @@
"""Schemas for model management operations."""
from typing import List
from pydantic import BaseModel, Field
class ModelDownloadRequest(BaseModel):
"""Request to download models."""
models: List[str] = Field(
description='List of model names to download'
)
provider: str = Field(
default='huggingface',
description='Repository provider (huggingface, gdrive, etc.)'
)
class ModelDownloadResponse(BaseModel):
"""Response from model download."""
success: bool
message: str
downloaded: List[str] = Field(default_factory=list)
failed: List[str] = Field(default_factory=list)
errors: dict = Field(default_factory=dict)
class ModelListResponse(BaseModel):
"""Response containing list of models."""
available_models: List[dict]
total_models: int
local_models: int

57
app/schemas/upscale.py Normal file
View File

@@ -0,0 +1,57 @@
"""Schemas for upscaling operations."""
from typing import Optional
from pydantic import BaseModel, Field
class UpscaleOptions(BaseModel):
"""Options for image upscaling."""
model: str = Field(
default='RealESRGAN_x4plus',
description='Model to use for upscaling (RealESRGAN_x2plus, RealESRGAN_x3plus, RealESRGAN_x4plus, etc.)'
)
tile_size: Optional[int] = Field(
default=None,
description='Tile size for processing large images to avoid OOM'
)
tile_pad: Optional[int] = Field(
default=None,
description='Padding between tiles'
)
outscale: Optional[float] = Field(
default=None,
description='Upsampling scale factor'
)
class JobStatus(BaseModel):
"""Job status information."""
job_id: str
status: str # queued, processing, completed, failed
model: str
progress: float = Field(default=0.0, description='Progress as percentage 0-100')
result_path: Optional[str] = None
error: Optional[str] = None
created_at: str
started_at: Optional[str] = None
completed_at: Optional[str] = None
processing_time_seconds: Optional[float] = None
class UpscaleResult(BaseModel):
"""Upscaling result."""
success: bool
message: str
processing_time_seconds: float
model: str
input_size: Optional[tuple] = None
output_size: Optional[tuple] = None
class ModelInfo(BaseModel):
"""Information about an available model."""
name: str
scale: int
path: str
size_mb: float
available: bool