INNER CODE UNIT · Python
set_dataset_directory
virajmavani/semi-auto-image-annotation-tool · web/backend/main.py:436
async def set_dataset_directory(directory_path: str = Form(...)):
"""Set the working directory containing images to annotate"""
global current_dataset_dir
try:
dataset_path = Path(directory_path).expanduser().resolve()
# Validate directory exists
if not dataset_path.exists():
raise HTTPException(status_code=404, detail=f"Directory not found: {directory_path}")
if not dataset_path.is_dir():
raise HTTPException(status_code=400, detail=f"Path is not a directory: {directory_path}")
# Scan for images
image_extensions = {'.jpg', '.jpeg', '.png', '.bmp', '.gif', '.tiff'}
images = []