Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init release commit #10

Merged
merged 25 commits into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python application

on:
push:
tags:
- requires_test
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
lfs: 'true'
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- uses: actions/cache@v3
id: cache
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.*') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install pytest-timeout
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test with pytest
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
pip install '.[streamlit]'
pytest tests --timeout=400
2 changes: 1 addition & 1 deletion .github/workflows/test_and_deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"
python-version: "3.9"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,8 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST


*.pyc
__pycache__/
*~
9 changes: 9 additions & 0 deletions .streamlit/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[browser]
gatherUsageStats = true

[theme]
primaryColor="#ea4461"
backgroundColor="#000000"
secondaryBackgroundColor="#5a165a"
textColor="#ffffff"
font="monospace"
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export streamlit_app=True
app:

streamlit run app.py --server.fileWatcherType none
53 changes: 36 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
<p align="center">
<img src="https://images.squarespace-cdn.com/content/v1/57f6d51c9f74566f55ecf271/733ec9c2-52bc-4fcb-aefb-1516d0a50c19/amadeuslogo.png?format=1500w" width="95%">
<img src="https://images.squarespace-cdn.com/content/v1/57f6d51c9f74566f55ecf271/8555eac6-6af0-4538-bda4-c1a8a2c7bed8/amadeusgpt_logo.png?format=1500w" width="95%">
</p>

🪄 **We turn natural language descriptions of behaviors into machine-executable code.**

- We use large language models (LLMs) to bridge natural language and behavior analysis.
- This work is accepted to **NeuRIPS2023!**
- For more details, check out our arXiv preprint version **[AmadeusGPT: a natural language interface for interactive animal behavioral analysis](https://arxiv.org/abs/2307.04858)** by [Shaokai Ye](https://github.com/yeshaokai), [Jessy Lauer](https://github.com/jeylau), [Mu Zhou](https://github.com/zhoumu53), [Alexander Mathis](https://github.com/AlexEMG) & [Mackenzie W. Mathis](https://github.com/MMathisLab).

- This work is accepted to **NeuRIPS2023!** Read the paper, [AmadeusGPT: a natural language interface for interactive animal behavioral analysis](https://www.google.com/search?q=amadeusgpt+openreview&sca_esv=590699485&rlz=1C5CHFA_enCH1059CH1060&ei=K1N6ZaHdKvmrur8PosOOkAo&ved=0ahUKEwjhnta83I2DAxX5le4BHaKhA6IQ4dUDCBE&uact=5&oq=amadeusgpt+openreview&gs_lp=Egxnd3Mtd2l6LXNlcnAiFWFtYWRldXNncHQgb3BlbnJldmlldzIHECEYoAEYCjIHECEYoAEYCki2HVDfAliOHHACeACQAQGYAYMDoAHaGaoBCDEuMTEuMS40uAEDyAEA-AEBwgIFECEYqwLCAggQABiABBiiBMICCBAAGIkFGKIE4gMEGAEgQYgGAQ&sclient=gws-wiz-serp#:~:text=AmadeusGPT%3A%20a%20natural,net%20%E2%80%BA%20pdf)
- Like this project? Please consider giving us a star ⭐️!

## Demo AmadeusGPT🎻

- 🔮 App: [https://amadeusgpt.kinematik.ai/](https://amadeusgpt.kinematik.ai/)

- We thank [Kinematik AI](https://kinematik.ai/) for partnering with us on hosting the demo. This is an academic research project demo 💕

https://github.com/AdaptiveMotorControlLab/AmadeusGPT/assets/28102185/61bc447c-29d4-4295-91be-23e5a7f10386

- Please note that you need an [openAI API key](https://platform.openai.com/account/api-keys), which you can easily create [here](https://platform.openai.com/account/api-keys).
## Install & Run AmadeusGPT🎻

## License

AmadeusGPT is license under the Apache-2.0 license.
- Please note several key dependencies have their own licensing. Please carefully check the license information for [DeepLabCut](https://github.com/DeepLabCut/DeepLabCut) (LGPL-3.0 license), [SAM](https://github.com/facebookresearch/segment-anything) (Apache-2.0 license), [CEBRA](https://github.com/AdaptiveMotorControlLab/CEBRA) (Non-Commercial), etc...
- AmadeusGPT is a Python package hosted on pypi. You can create a virtual env (conda, etc, see below*) or Docker and run:
```python
pip install amadeusgpt[streamlit]
```
- If you want the demo, you will also need demo files that are supplied in our repo (see below**), so please git clone the repo. Then, to launch the Demo App execute:
```python
make app
```

## Citation

Expand All @@ -37,8 +31,33 @@ https://github.com/AdaptiveMotorControlLab/AmadeusGPT/assets/28102185/61bc447c-2
year={2023},
url={https://openreview.net/forum?id=9AcG3Tsyoq},
```
- arXiv preprint version **[AmadeusGPT: a natural language interface for interactive animal behavioral analysis](https://arxiv.org/abs/2307.04858)** by [Shaokai Ye](https://github.com/yeshaokai), [Jessy Lauer](https://github.com/jeylau), [Mu Zhou](https://github.com/zhoumu53), [Alexander Mathis](https://github.com/AlexEMG) & [Mackenzie W. Mathis](https://github.com/MMathisLab).

### Install tips
- *Make a new conda env: `conda create --name amadeusGPT` then run `conda activate amadeusGPT` or you can also use our supplied conda if you git cloned the repo: `conda env create -f amadesuGPT.yml` then pip install amadeusGPT once created/lauched.
- **Git clone this repo: so please open a terminal, we recommend to download into Documents (so type `cd Documents`) and run `git clone https://github.com/AdaptiveMotorControlLab/AmadeusGPT.git` Then go into the dir (`cd AmadeusGPT`)
- If you want to use SAM, you need to download the weights. Otherwise you will see the following message in the app: `Cannot find SAM checkpoints. Skipping SAM`. Download them and add to "static" directory: wget https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth

### Install trouble shooting:
- If you hit an error during installing on an M1/M2 Macbook with installing HDF5, run `conda install h5py` in your conda env.
- If you launch the app and get an ffmpeg error, `RuntimeError: No ffmpeg exe could be found. Install ffmpeg on your system, or set the IMAGEIO_FFMPEG_EXE environment variable.` try running `conda install ffmpeg`.
- If you have an M1/M2 chip and use CEBRA within AmadeusGPT, and you get this error: `RuntimeError: Device type MPS is not supported for torch.Generator() api` run `pip install --update torch`

## Hosted Demo:

- 🔮 App: [https://amadeusgpt.kinematik.ai/](https://amadeusgpt.kinematik.ai/)
- Please note that you need an [openAI API key](https://platform.openai.com/account/api-keys), which you can easily create [here](https://platform.openai.com/account/api-keys).

https://github.com/AdaptiveMotorControlLab/AmadeusGPT/assets/28102185/61bc447c-29d4-4295-91be-23e5a7f10386

## License

AmadeusGPT is license under the Apache-2.0 license.
- 🚨 Please note several key dependencies have their own licensing. Please carefully check the license information for [DeepLabCut](https://github.com/DeepLabCut/DeepLabCut) (LGPL-3.0 license), [SAM](https://github.com/facebookresearch/segment-anything) (Apache-2.0 license), [CEBRA](https://github.com/AdaptiveMotorControlLab/CEBRA) (Non-Commercial), etc...


## News
- 🤩 Dec 2023, code released!
- 🔥 Our work was accepted to NeuRIPS2023
- 🧙‍♀️ Open-source code coming in the fall of 2023
- 🔮 arXiv paper and demo released July 2023
Expand Down
1 change: 1 addition & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

3 changes: 2 additions & 1 deletion amadeusgpt/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@

from amadeusgpt.implementation import AnimalBehaviorAnalysis
from amadeusgpt.main import AMADEUS
26 changes: 26 additions & 0 deletions amadeusgpt/amadeus_security.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import ast


class IllegaActionError(Exception):
def __init__(self, message):
super().__init__(message)


class LoopChecker(ast.NodeVisitor):
def visit_While(self, node):
raise IllegaActionError("Dangerous! Infinite or long loop detected: while loop")

def visit_Call(self, node):
if isinstance(node.func, ast.Name) and node.func.id == "range":
if len(node.args) > 0 and isinstance(node.args[0], ast.Num):
loop_count = node.args[0].n
if loop_count > 1000:
raise IllegaActionError(
"Dangerous! Infinite or long loop detected: range() loop"
)
self.generic_visit(node)


def check_code(code):
tree = ast.parse(code)
LoopChecker().visit(tree)
6 changes: 6 additions & 0 deletions amadeusgpt/brains/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from .base import BaseBrain
from .diagnosis import DiagnosisBrain
from .explainer import ExplainerBrain
from .code_generator import CodeGenerationBrain
from .self_debug import SelfDebugBrain
from .rephraser import RephraserBrain
Loading
Loading