Spaces:
Sleeping
Sleeping
| from src.models.model import ImageRequest | |
| from fastapi import FastAPI, HTTPException | |
| from typing import Optional | |
| import time | |
| import os | |
| from src.main import AIImageClassifier2 | |
| app = FastAPI() | |
| # Global detector instance | |
| detector = AIImageClassifier2() | |
| # Health check | |
| def root(): | |
| return {"status": "running", "provider":"image_classifier_2"} | |
| # Main processing endpoint | |
| def process_image(request: ImageRequest): | |
| start_time = time.time() | |
| try: | |
| result = detector.detect(request.path, request.type) | |
| end_time = time.time() | |
| return result | |
| except Exception as e: | |
| raise HTTPException(status_code=400, detail=str(e)) | |
| # python -m uvicorn app:app --reload --host 0.0.0.0 --port 8002 |