Add basic backend infrastructure
Signed-off-by: Felipe Cardoso <felipe.cardoso@hotmail.it>
This commit is contained in:
0
backend/app/api/routes/__init__.py
Normal file
0
backend/app/api/routes/__init__.py
Normal file
34
backend/app/api/routes/samples.py
Normal file
34
backend/app/api/routes/samples.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from typing import List
|
||||
|
||||
from fastapi import APIRouter, HTTPException, Query
|
||||
|
||||
from app.models.sample import Sample
|
||||
from app.services.sample_manager import SampleManager
|
||||
|
||||
router = APIRouter()
|
||||
sample_manager = SampleManager()
|
||||
|
||||
|
||||
@router.get("/list", response_model=List[Sample])
|
||||
async def list_samples(
|
||||
limit: int = Query(20, ge=1, le=100),
|
||||
offset: int = Query(0, ge=0)
|
||||
):
|
||||
"""
|
||||
List sample images with pagination
|
||||
"""
|
||||
try:
|
||||
return await sample_manager.list_samples(limit, offset)
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
|
||||
@router.get("/latest", response_model=List[Sample])
|
||||
async def get_latest_samples(count: int = Query(5, ge=1, le=20)):
|
||||
"""
|
||||
Get the most recent sample images
|
||||
"""
|
||||
try:
|
||||
return await sample_manager.get_latest_samples(count)
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
29
backend/app/api/routes/training.py
Normal file
29
backend/app/api/routes/training.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
from app.models.training import TrainingStatus
|
||||
from app.services.training_monitor import TrainingMonitor
|
||||
|
||||
router = APIRouter()
|
||||
monitor = TrainingMonitor()
|
||||
|
||||
|
||||
@router.get("/status", response_model=TrainingStatus)
|
||||
async def get_training_status():
|
||||
"""
|
||||
Get current training status including progress, loss, and learning rate
|
||||
"""
|
||||
try:
|
||||
return await monitor.get_status()
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
|
||||
@router.get("/log")
|
||||
async def get_training_log():
|
||||
"""
|
||||
Get recent training log entries
|
||||
"""
|
||||
try:
|
||||
return await monitor.get_log()
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
Reference in New Issue
Block a user