Pk_yolo / app.py
Overreactingwallflower's picture
Create app.py
a028823 verified
# app.py - TEST VERSION (Model loading disabled for debugging)
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
import os
app = FastAPI(title="Pokemon YOLO API - TEST", version="1.0")
# TEMPORARILY DISABLE MODEL LOADING FOR TESTING
MODEL_PATH = "yolo_pokemon.pt"
model = None
@app.on_event("startup")
async def load_model():
"""Startup - Model loading temporarily disabled for testing"""
global model
print("[TEST] Skipping model load for testing")
print(f"[TEST] Model file exists: {os.path.exists(MODEL_PATH)}")
if os.path.exists(MODEL_PATH):
file_size = os.path.getsize(MODEL_PATH) / (1024 * 1024)
print(f"[TEST] Model file size: {file_size:.2f} MB")
model = "TEST_MODE" # Fake model for testing
class PredictRequest(BaseModel):
image_url: str
confidence_threshold: float = 0.25
@app.post("/predict")
async def predict(request: PredictRequest):
"""Test endpoint - returns fake data"""
return {
"pokemon_name": "pikachu",
"confidence": 0.99,
"inference_time_ms": 100,
"note": "TEST MODE - Not using real model yet"
}
@app.get("/health")
async def health():
"""Health check endpoint"""
return {
"status": "healthy",
"model": MODEL_PATH,
"model_loaded": model is not None,
"mode": "TEST MODE",
"model_exists": os.path.exists(MODEL_PATH)
}
@app.get("/")
async def root():
"""API information"""
return {
"name": "Pokemon YOLO API - TEST VERSION",
"version": "1.0",
"mode": "TEST MODE",
"endpoints": {
"POST /predict": "Returns fake prediction",
"GET /health": "Health check",
"GET /": "This information"
}
}