model_os is your sentient OS.
- Load ONNX Models: Load models into memory on application startup or on demand.
- Process Inputs: Handle and process text and image inputs using loaded models.
- Asynchronous Support: Manage application lifecycle with asynchronous functions.
- Multi-GPU Support: Load models across multiple GPUs.
- Customizable Model Prompts: Generate custom prompts for model input.
-
Clone the Repository:
git clone https://github.com/zarev/model_os.git cd model_os -
Create a Virtual Environment (optional but recommended):
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install Dependencies: Install the required packages listed in
requirements.txt.pip install -r requirements.txt
To run the FastAPI application with Uvicorn, execute:
uvicorn model_os:app --reloadThe application will be accessible at http://127.0.0.1:8000.
Load a model into memory. This endpoint can be used to initialize models on application startup.
Request Body:
{
"num_gpus": 1,
"models_per_gpu": 1,
"model_id": "default-model-id"
}Process a text prompt (and optionally an image) using a specified model.
Request Body:
{
"model": 0,
"image": "optional-image-path",
"text": "Your text prompt here",
"model_id": "default-model-id"
}- Model Class: Represents an ONNX model, with methods to load the model and process inputs.
- FastAPI Application: Defines routes for loading models and processing prompts.
- Asynchronous Lifespan Manager: Manages the startup and shutdown processes for the FastAPI application.
model_os.py: The main module containing the FastAPI application, model loading logic, and input processing functions.
You can customize the following aspects of the application:
- Model Paths: Update model paths and IDs in the
LoadRequestandModelclasses. - Prompt Templates: Modify the
template_promptin therunmethod of theModelclass for custom input processing.
Feel free to fork the repository and submit pull requests. Contributions are welcome!
-
Install Development Dependencies:
pip install -r requirements-dev.txt
-
Run Linting and Tests:
pylint model_os.py pytest
This project is licensed under the MIT License.