File size: 4,490 Bytes
a0bd5e7 1bc5752 a0bd5e7 1bc5752 a0bd5e7 1bc5752 a0bd5e7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
"""
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
)
|