diff --git a/README.md b/README.md index 65899ef..f849a2d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ ![PyPI version](https://img.shields.io/pypi/v/xinfer.svg?style=for-the-badge&logo=pypi&logoColor=white&label=PyPI&color=blue) +![Downloads](https://img.shields.io/pypi/dm/xinfer.svg?style=for-the-badge&logo=pypi&logoColor=white&label=Downloads&color=purple) ![License](https://img.shields.io/badge/License-Apache%202.0-green.svg?style=for-the-badge&logo=apache&logoColor=white) diff --git a/docs/index.md b/docs/index.md index 046558f..291e502 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,10 +1,12 @@ # Welcome to xinfer -[![image](https://img.shields.io/pypi/v/xinfer.svg)](https://pypi.python.org/pypi/xinfer) +![PyPI version](https://img.shields.io/pypi/v/xinfer.svg?style=for-the-badge&logo=pypi&logoColor=white&label=PyPI&color=blue) +![Downloads](https://img.shields.io/pypi/dm/xinfer.svg?style=for-the-badge&logo=pypi&logoColor=white&label=Downloads&color=purple) +![License](https://img.shields.io/badge/License-Apache%202.0-green.svg?style=for-the-badge&logo=apache&logoColor=white) -**A unified interface to run inference on machine learning libraries.** +**A unified interface to run inference on computer vision libraries.** - Free software: Apache Software License 2.0 diff --git a/docs/usage.md b/docs/usage.md index b205701..337a252 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -2,6 +2,69 @@ To use xinfer in a project: -``` +```python import xinfer ``` + +## Listing Available Models + +You can list the available models using the `list_models()` function: + +```python +from xinfer import list_models +list_models() +``` + +This will display a table of available models and their implementations. + +``` + Available Models +┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ +┃ Implementation ┃ Model Type ┃ +┡━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ +│ transformers │ Salesforce/blip2-opt-2.7b │ +│ transformers │ sashakunitsyn/vlrm-blip2-opt-2.7b │ +└────────────────┴───────────────────────────────────┘ +``` + +## Loading and Using a Model + +### BLIP2 Model + +Here's an example of how to load and use the BLIP2 model: + +```python +from xinfer import get_model + +# Instantiate a Transformers model +model = get_model("Salesforce/blip2-opt-2.7b", implementation="transformers") + +# Input data +image = "https://example.com/path/to/image.jpg" +prompt = "What's in this image? Answer:" + +# Run inference +processed_input = model.preprocess(image, prompt) +prediction = model.predict(processed_input) +output = model.postprocess(prediction) + +print(output) +``` + +You can also customize the generation parameters: + +```python +prediction = model.predict(processed_input, max_new_tokens=200) +``` + +### VLRM-finetuned BLIP2 Model + +Similarly, you can use the VLRM-finetuned BLIP2 model: + +```python +model = get_model("sashakunitsyn/vlrm-blip2-opt-2.7b", implementation="transformers") + +# Use the model in the same way as the BLIP2 model +``` + +Both models can be used for tasks like image description and visual question answering. diff --git a/docs/xinfer.md b/docs/xinfer.md index 0896551..8deb7cc 100644 --- a/docs/xinfer.md +++ b/docs/xinfer.md @@ -1,41 +1,7 @@ + # xinfer module -The `xinfer` module provides a flexible and extensible framework for working with various AI models, particularly focusing on vision-language models like BLIP2. - -## Main Functions - -### list_models - ::: xinfer.list_models -This function displays a table of all available models in the ModelRegistry. It uses the Rich library to create a formatted table with two columns: "Implementation" and "Model Type". - -### get_model - ::: xinfer.get_model -This function retrieves a model instance based on the specified model type and implementation. It returns an instance of a class that inherits from `BaseModel`. - -Parameters: -- `model_type` (str): The type of the model to retrieve. -- `implementation` (str): The implementation of the model. -- `**kwargs`: Additional keyword arguments to pass to the model constructor. - -Returns: -- An instance of the requested model. - -Raises: -- `ValueError`: If the specified implementation or model type is not supported. - -## Model Registry - -The `ModelRegistry` class manages the registration and retrieval of models. It provides the following class methods: - -### register - -::: xinfer.ModelRegistry.register - -This method registers a model class with the ModelRegistry. - - - diff --git a/mkdocs.yml b/mkdocs.yml index e6f00f6..ca24c32 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -75,12 +75,12 @@ nav: - Home: index.md - Installation: installation.md - Usage: usage.md - - Contributing: contributing.md - - FAQ: faq.md - - Changelog: changelog.md - - Report Issues: https://github.com/dnth/xinfer/issues - - Examples: - - examples/intro.ipynb - - API Reference: - - xinfer module: xinfer.md + # - Contributing: contributing.md + # - FAQ: faq.md + # - Changelog: changelog.md + # - Report Issues: https://github.com/dnth/xinfer/issues + # - Examples: + # - examples/intro.ipynb + # - API Reference: + # - xinfer module: xinfer.md # - common module: common.md