Home of Omega, a napari-aware autonomous LLM-based agent specialized in image processing and analysis.
![](https://private-user-images.githubusercontent.com/1870994/305878079-c85185d2-6d16-472d-a2c8-5680ea869bf2.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ4MDI4NjQsIm5iZiI6MTcyNDgwMjU2NCwicGF0aCI6Ii8xODcwOTk0LzMwNTg3ODA3OS1jODUxODVkMi02ZDE2LTQ3MmQtYTJjOC01NjgwZWE4NjliZjIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjdUMjM0OTI0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9M2UxNjhkMmYxZDFhYTliNzZlZTUzOTM0NzQ5MTNkMzJkZDllOWJkZDZhOTdkYjIyMzQyZTk1OWE4OTBiZjRkOSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.expM3vfjv-iHWf9a_dvr1m8gwrBp74D5E9daQXh4bx4)
![image](https://private-user-images.githubusercontent.com/1870994/305881325-f3ea245e-dd86-4ff2-802e-48c2073cb6f9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ4MDI4NjQsIm5iZiI6MTcyNDgwMjU2NCwicGF0aCI6Ii8xODcwOTk0LzMwNTg4MTMyNS1mM2VhMjQ1ZS1kZDg2LTRmZjItODAyZS00OGMyMDczY2I2ZjkucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjdUMjM0OTI0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YzFkZjc2Nzc5YTIxZDc2NWE3ODEzZGNiYzgyZmJkZmQ3OTRhMmU5NzI1NDhkNGM4YjAyNDA2ZTNmZDA1MjgwMyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.JjSlzmGCSv8YopR98Apzf3eFROdyz1_nJU3aV5V8aqc)
A napari plugin that leverages OpenAI's Large Language Model ChatGPT to implement Omega a napari-aware agent capable of performing image processing and analysis tasks in a conversational manner.
This repository started as a 'week-end project' by Loic A. Royer who leads a research group at the Chan Zuckerberg Biohub. It leverages OpenAI's ChatGPT API via the LangChain Python library, as well as napari, a fast, interactive, multi-dimensional image viewer for Python, another week-end project, initially started by Loic and Juan Nunez-Iglesias.
Omega is an LLM-based and tool-armed autonomous agent that demonstrates the potential for Large Language Models (LLMs) to be applied to image processing, analysis and visualization. Can LLM-based agents write image processing code and napari widgets, correct its coding mistakes, performing follow-up analysis, and controlling the napari viewer? The answer appears to be yes.
The preprint can be downloaded here: 10.5281/zenodo.10828225
In this video, I ask Omega to segment an image using the SLIC algorithm. It makes a first attempt using the implementation in scikit-image but fails because of an inexistent 'multichannel' parameter. Realizing that, Omega tries again, and this time succeeds:
1_RGBImageSlicSegmentationSyntaxErrorCorrection_evenfaster.mp4
After loading a sample 3D image of cell nuclei in napari, I asked Omega to segment the nuclei using the Otsu method. My first request was vague, so it just segmented foreground versus background. I then ask to segment the foreground into distinct segments for each connected component. Omega does a rookie mistake by forgetting to 'import np'. No problem; it notices, tries again, and succeeds:
2_Cells3DOtsuThenLabelsRecoversFromError_evenfaster.mp4
In this video, one of my favorites, I ask Omega to make a 'Max color projection widget.' It is not a trivial task, but it manages!
ColorProjection.mp4
As LLMs improve, Omega will become even more adept at handling complex image processing and analysis tasks. GPT 4.0 has been a significant upgrade compared to GPT 3.5, and many of the videos (see below and here) are highly reproducible, with a typically 90% success rate (see preprint for a reproducibility analysis). While open-source models are promising and rapidly improving, they must get better to run Omega reliably. More recent models by OpenAI's competitors, such as Google and Anthropic, are great news, but Omega still needs to support these newer models fully -- it seems every week comes with a new batch of models.
Omega could eventually help non-experts process and analyze images, especially in the bioimage domain. It is also potentially valuable for educative purposes as it could assist in teaching image processing and analysis, making it more accessible. Although ChatGPT, which powers Omega, may still need to be on par with an expert image analyst or computer vision expert, it is just a matter of time...
Omega holds a conversation with the user and uses different tools to answer questions, download and operate on images, write widgets for napari, and more.
The Omega AI-Augmented Code Editor is a new feature within Omega, designed to enhance the Omega's user experience. This editor is not just a text editor; it's a powerful interface that interacts with the Omega dialogue agent to generate, optimize, and manage code for advanced image analysis tasks.
![](https://private-user-images.githubusercontent.com/1870994/307566523-cf9b1c15-f11a-4e25-a73d-d96915c46c6a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ4MDI4NjQsIm5iZiI6MTcyNDgwMjU2NCwicGF0aCI6Ii8xODcwOTk0LzMwNzU2NjUyMy1jZjliMWMxNS1mMTFhLTRlMjUtYTczZC1kOTY5MTVjNDZjNmEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyNyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjdUMjM0OTI0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NWFmZWIwYjNmMTkwMTIwYzJmMDA2YzNiYjkwZjA2NmJhOTAxYWMxMmExMTA4MDZhNmY0NGFhY2VlNjk0OGY5ZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.KOO0_K6OE24GjXOupcE7jpaX_L258wDO9s9rtY18qX4)
- Code Highlighting and Completion: For ease of reading and writing, the code editor comes with built-in syntax highlighting and intelligent code completion features.
- LLM-Augmented Tools: The editor is equipped with AI tools that assist in commenting, cleaning up, fixing, modifying, and performing safety checks on the code.
- Persistent Code Snippets: Users can save and manage snippets of code, preserving their work across multiple Napari sessions.
- Network Code Sharing (Code-Drop): Facilitates the sharing of code snippets across the local network, empowering collaborative work and knowledge sharing.
- Widget Creation: Expert users can create widgets using the Omega dialogue agent and retain them for future use.
- Collaboration: Share custom widgets with colleagues or the community, even if they don't have access to an API key.
- Learning: New users can learn from the AI-augmented suggestions, improving their coding skills in Python and image analysis workflows.
You can find more information in the corresponding wiki page.
Assuming you have a Python environment with a working napari installation, you can simply:
pip install napari-chatgpt
Or install the plugin from napari's plugin installer.
For detailed instructions and variations, check this page of our wiki.
You need an OpenAI key; there is no way around this, I have been experimenting with other models, including open-source models, but right now, the best results, by far, are obtained with ChatGPT 4 (and to a lesser extent 3.5). Check here for details on how to get your OpenAI key. In particular, check this for how to gain access to GPT-4 models.
Check this page of our wiki for details on how to start Omega.
Check our guide on how to prompt Omega and some examples here.
You can check the original release videos here. You can also find the latest preprint videos on Vimeo.
Check our preprint here: 10.5281/zenodo.8240289 and our wiki page on Omega's design and architecture.
Developing the initial version of Omega cost me $13.97, hardly a fortune. OpenAI pricing on ChatGPT 4 is very reasonable at 0.01 dollars per 1K tokens, which means $1 per 750000 words.
Note: you can limit the burn rate to a certain amount of dollars per month, just in case you let Omega think over the weekend and forget to stop it (don't worry, this is actually not possible).
Do not use this software lightly; it will download libraries of its own volition
and write any code it deems necessary; it might do what you ask, even
if it is a very bad idea. Also, beware that it might misunderstand what you ask and
then do something bad in ways that elude you. For example, it is unwise to use Omega to delete
'some' files from your system; it might end up deleting more than that if you are unclear in
your request.
Omega is generally safe as long as you do not make dangerous requests. To be 100% safe, and
if your experiments with Omega could be potentially problematic, I recommend using this
software from within a sandboxed virtual machine.
API keys are only as safe as the overall machine is, see the section below on API key hygiene.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Best Practices for Managing Your API Keys:
- Host Computer Hygiene: Ensure that the machine you’re installing napari-chagot/Onega on is secure, free of malware and viruses, and otherwise not compromised. Make sure to install antivirus software on Windows.
- Security: Treat your API key like a password. Do not share it with others or expose it in public repositories or forums.
- Cost Control: Set spending limits on your OpenAI account (see here).
- Regenerate Keys: If you believe your API key has been compromised, cancel and regenerate it from the OpenAI API dashboard immediately.
- Key Storage: Omega has a built-in 'API Key Vault' that encrypts keys using a password, this is the preferred approach. You can also store the key in an environment variable, but that is not encrypted and could compromise the key.
Contributions are extremely welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.
Distributed under the terms of the BSD-3 license, "napari-chatgpt" is free and open-source software
If you encounter any problems, please file an issue along with a detailed description.