""" LISA Model Deployment Script Developed in Kenya, Africa by the LISA Team """ from fastapi import FastAPI, File, UploadFile, HTTPException from fastapi.responses import JSONResponse import torch import uvicorn import argparse from pathlib import Path import logging app = FastAPI( title="LISA AI API", description="Learning Intelligence with Sensory Awareness - Developed in Kenya, Africa", version="3.5" ) # Global model instance lisa_model = None @app.on_startup async def startup_event(): """Load LISA model on startup""" global lisa_model try: from lisa import LISAModel lisa_model = LISAModel.from_pretrained("./") print("[SUCESS] LISA model loaded successfully") print(" Proudly developed in Kenya, Africa by the LISA Team") except Exception as e: print(f" Failed to load LISA model: {e}") @app.get("/") async def root(): """API health check""" return { "message": "LISA AI API is running", "version": "3.5", "developed_in": "Kenya, Africa", "team": "LISA Team", "status": "operational" } @app.get("/info") async def model_info(): """Get model information""" return { "model_name": "LISA v3.5", "description": "Learning Intelligence with Sensory Awareness", "developed_by": "LISA Team", "development_location": "Kenya, East Africa", "architecture": "Lisa Multimodal Transformer", "capabilities": [ "Computer Vision", "Audio Processing", "Speech Recognition", "Object Detection", "Emotion Detection", "Real-time Processing" ], "cultural_context": "African AI Innovation" } @app.post("/process/text") async def process_text(data: dict): """Process text input""" try: if not lisa_model: raise HTTPException(status_code=503, detail="Model not loaded") text = data.get("text", "") result = lisa_model.process_text(text) return { "input": text, "response": result.response, "processed_by": "LISA v3.5 (Kenya, Africa)" } except Exception as e: raise HTTPException(status_code=500, detail=str(e)) @app.post("/process/image") async def process_image(file: UploadFile = File(...)): """Process image input""" try: if not lisa_model: raise HTTPException(status_code=503, detail="Model not loaded") # Process uploaded image image_bytes = await file.read() result = lisa_model.process_image(image_bytes) return { "filename": file.filename, "detections": result.detections, "description": result.description, "processed_by": "LISA v3.5 (Kenya, Africa)" } except Exception as e: raise HTTPException(status_code=500, detail=str(e)) @app.post("/process/audio") async def process_audio(file: UploadFile = File(...)): """Process audio input""" try: if not lisa_model: raise HTTPException(status_code=503, detail="Model not loaded") # Process uploaded audio audio_bytes = await file.read() result = lisa_model.process_audio(audio_bytes) return { "filename": file.filename, "transcript": result.transcript, "emotion": result.predicted_emotion, "sounds": result.sound_classes, "processed_by": "LISA v3.5 (Kenya, Africa)" } except Exception as e: raise HTTPException(status_code=500, detail=str(e)) if __name__ == "__main__": parser = argparse.ArgumentParser(description="LISA API Server") parser.add_argument("--host", default="0.0.0.0", help="Host address") parser.add_argument("--port", type=int, default=8000, help="Port number") parser.add_argument("--workers", type=int, default=1, help="Number of workers") args = parser.parse_args() print(" Starting LISA API Server...") print(f" Proudly developed in Kenya, Africa") print(f" Created by the LISA Team") uvicorn.run( "deploy:app", host=args.host, port=args.port, workers=args.workers, reload=False )