Coconut AI
Project description
coconut-ai
About
Coconut AI is a Python library that allows you to use AUTOMATIC1111/Stable Diffusion Web API and LLama 2, to generate images from text, images to images or text to text.
The library is available on PyPy: https://pypi.org/project/coconut-ai/.
Getting Started
Prerequisites
- Python v3.10
- Pipenv
- AUTOMATIC1111/Stable Diffusion Web UI v1.6.0
Installation
pipenv install coconut-ai
Stable Diffusion Guide
For a complete example, see the coconut-ai-example repository.
Install Stable Diffusion Web UI
AUTOMATIC1111/Stable Diffusion Web UI installation guide
# Clone the AUTOMATIC1111/Stable Diffusion Web UI repository
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
# Go to AUTOMATIC1111/Stable Diffusion Web UI source code
cd stable-diffusion-webui
# For Windows users, run the following command for starting the server
./webui-user.bat --api --nowebui
# For Linux/MacOS users, run the following command for starting the server
./webui.sh --api --nowebui
Stable Diffusion Usage
Note: Before using the library, you must start the Stable Diffusion Web UI server.
# Go to your Python project/source code
cd ../python-project
pipenv install coconut-ai
Create a file named main.py
with the following content (minimal example):
import os
import coconut_ai
if __name__ == '__main__':
print("Coconut AI")
output_path = os.path.abspath("output.png")
os.makedirs(os.path.dirname(output_path), exist_ok=True)
coconut_ai.text_to_image({
"input_text": "Coconut",
"output_path": output_path,
"steps": 5
})
Run the script:
pipenv run python main.py
LLama 2 Guide
Install LLama 2 Model
For a complete example, see the coconut-ai-example repository.
Download the model llama-2-7b.Q5_K_M.gguf
manually.
All available models can be found on the Hugging Face website.
LLama 2 Usage
# Go to your Python project/source code
cd ../python-project
pipenv install coconut-ai
Create a file named main.py
with the following content (minimal example):
import os
import coconut_ai
if __name__ == '__main__':
print("Coconut AI")
# Replace with the model path for the llama-2-7b.Q5_K_M.gguf model downloaded manually
model_path = os.path.abspath("data/llama-2-7b.Q5_K_M.gguf")
print(coconut_ai.text_to_text({
'input_text': "Generate a list of 5 funny dog names.",
'max_tokens': 1000,
'model_path': model_path
}))
Run the script:
pipenv run python main.py
💡 Contributing
Anyone can help to improve the project, submit a Feature Request, a bug report or even correct a simple spelling mistake.
The steps to contribute can be found in the CONTRIBUTING.md file.
📄 License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file coconut-ai-1.0.0.tar.gz
.
File metadata
- Download URL: coconut-ai-1.0.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 726f23d7a58a7bc5fec806374a31676810dd2edd087e30a8451f51faa224c249 |
|
MD5 | ec39f95553a3ecc107d1102a4c1b10ae |
|
BLAKE2b-256 | 85051dcccd1c44c0471935fbad827a949b8bbf8c0d90e5fbf74f418a54dbc114 |