Skip to content

Commit

Permalink
Add stable diffusion integration (georgia-tech-db#1240)
Browse files Browse the repository at this point in the history
Reopen the georgia-tech-db#1111.

---------

Co-authored-by: sudoboi <[email protected]>
Co-authored-by: Abhijith S Raj <[email protected]>
  • Loading branch information
3 people authored and a0x8o committed Oct 30, 2023
1 parent a378db4 commit 8a8a90a
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ parts:
title: YOLO
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
- file: source/reference/ai/stablediffusion
title: Stable Diffusion
Expand All @@ -410,10 +411,16 @@ parts:
<<<<<<< HEAD
>>>>>>> 6d6a14c8 (Bump v0.3.4+ dev)
=======
=======
>>>>>>> 2b924b76 (Add stable diffusion integration (#1240))
- file: source/reference/ai/custom
title: Custom Model
<<<<<<< HEAD
=======
=======
- file: source/reference/ai/stablediffusion
title: Stable Diffusion
>>>>>>> bf022329 (Add stable diffusion integration (#1240))

- file: source/reference/ai/custom-ai-function
title: Bring Your Own AI Function
Expand Down
4 changes: 4 additions & 0 deletions evadb/evadb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ third_party:
OPENAI_KEY: ""
PINECONE_API_KEY: ""
PINECONE_ENV: ""
<<<<<<< HEAD
<<<<<<< HEAD
REPLICATE_API_TOKEN: ""
=======
>>>>>>> 40a10ce1 (Bump v0.3.4+ dev)
=======
REPLICATE_API_TOKEN: ""
>>>>>>> 2b924b76 (Add stable diffusion integration (#1240))
4 changes: 4 additions & 0 deletions evadb/functions/dalle.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ def forward(self, text_df):
# Register API key, try configuration manager first
openai.api_key = ConfigurationManager().get_value("third_party", "OPENAI_KEY")
# If not found, try OS Environment Variable
<<<<<<< HEAD
if openai.api_key is None or len(openai.api_key) == 0:
=======
if len(openai.api_key) == 0:
>>>>>>> 2b924b76 (Add stable diffusion integration (#1240))
openai.api_key = os.environ.get("OPENAI_KEY", "")
assert (
len(openai.api_key) != 0
Expand Down
8 changes: 8 additions & 0 deletions evadb/functions/function_bootstrap_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@
)

<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> 2b924b76 (Add stable diffusion integration (#1240))
dalle_function_query = """CREATE FUNCTION IF NOT EXISTS DallE
IMPL '{}/functions/dalle.py';
""".format(
Expand Down Expand Up @@ -316,11 +319,16 @@ def init_builtin_functions(db: EvaDBDatabase, mode: str = "debug") -> None:
# Mvit_function_query,
Sift_function_query,
Yolo_function_query,
<<<<<<< HEAD
<<<<<<< HEAD
stablediffusion_function_query,
dalle_function_query,
=======
>>>>>>> 2dacff69 (feat: sync master staging (#1050))
=======
stablediffusion_function_query,
dalle_function_query,
>>>>>>> 2b924b76 (Add stable diffusion integration (#1240))
]

# if mode is 'debug', add debug functions
Expand Down
4 changes: 4 additions & 0 deletions evadb/functions/stable_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ def forward(self, text_df):
"third_party", "REPLICATE_API_TOKEN"
)
# If not found, try OS Environment Variable
<<<<<<< HEAD
if replicate_api_key is None:
=======
if len(replicate_api_key) == 0:
>>>>>>> 2b924b76 (Add stable diffusion integration (#1240))
replicate_api_key = os.environ.get("REPLICATE_API_TOKEN", "")
assert (
len(replicate_api_key) != 0
Expand Down
6 changes: 6 additions & 0 deletions evadb/utils/generic_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,9 @@ def string_comparison_case_insensitive(string_1, string_2) -> bool:

return string_1.lower() == string_2.lower()
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> 2b924b76 (Add stable diffusion integration (#1240))


def try_to_import_replicate():
Expand All @@ -731,5 +734,8 @@ def is_replicate_available():
return True
except ValueError:
return False
<<<<<<< HEAD
=======
>>>>>>> 40a10ce1 (Bump v0.3.4+ dev)
=======
>>>>>>> 2b924b76 (Add stable diffusion integration (#1240))
13 changes: 13 additions & 0 deletions script/test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ long_integration_test() {
notebook_test() {
<<<<<<< HEAD
<<<<<<< HEAD
=======
<<<<<<< HEAD
PYTHONPATH=./ python -m pytest --durations=5 --nbmake --overwrite "./tutorials" --capture=sys --tb=short -v --log-level=WARNING --nbmake-timeout=3000 --ignore="tutorials/08-chatgpt.ipynb" --ignore="tutorials/14-food-review-tone-analysis-and-response.ipynb" --ignore="tutorials/15-AI-powered-join.ipynb" --ignore="tutorials/16-homesale-forecasting.ipynb" --ignore="tutorials/17-home-rental-prediction.ipynb"
=======
>>>>>>> 2b924b76 (Add stable diffusion integration (#1240))
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
PYTHONPATH=./ python -m pytest --durations=5 --nbmake --overwrite "./tutorials" --capture=sys --tb=short -v --log-level=WARNING --nbmake-timeout=3000 --ignore="tutorials/08-chatgpt.ipynb" --ignore="tutorials/14-food-review-tone-analysis-and-response.ipynb" --ignore="tutorials/15-AI-powered-join.ipynb" --ignore="tutorials/16-homesale-forecasting.ipynb" --ignore="tutorials/17-home-rental-prediction.ipynb" --ignore="tutorials/18-stable-diffusion.ipynb"
Expand All @@ -105,6 +111,7 @@ notebook_test() {
=======
PYTHONPATH=./ python -m pytest --durations=5 --nbmake --overwrite "./tutorials" --capture=sys --tb=short -v --log-level=WARNING --nbmake-timeout=3000 --ignore="tutorials/08-chatgpt.ipynb" --ignore="tutorials/14-food-review-tone-analysis-and-response.ipynb" --ignore="tutorials/15-AI-powered-join.ipynb" --ignore="tutorials/16-homesale-forecasting.ipynb" --ignore="tutorials/17-home-rental-prediction.ipynb"
>>>>>>> 40a10ce1 (Bump v0.3.4+ dev)
<<<<<<< HEAD
=======
=======
>>>>>>> 6d6a14c8 (Bump v0.3.4+ dev)
Expand All @@ -119,6 +126,12 @@ notebook_test() {
PYTHONPATH=./ python -m pytest --durations=5 --nbmake --overwrite "./tutorials" --capture=sys --tb=short -v --log-level=WARNING --nbmake-timeout=3000 --ignore="tutorials/08-chatgpt.ipynb" --ignore="tutorials/14-food-review-tone-analysis-and-response.ipynb" --ignore="tutorials/15-AI-powered-join.ipynb" --ignore="tutorials/16-homesale-forecasting.ipynb" --ignore="tutorials/17-home-rental-prediction.ipynb"
>>>>>>> 40a10ce1 (Bump v0.3.4+ dev)
>>>>>>> 6d6a14c8 (Bump v0.3.4+ dev)
=======
>>>>>>> eva-master
=======
PYTHONPATH=./ python -m pytest --durations=5 --nbmake --overwrite "./tutorials" --capture=sys --tb=short -v --log-level=WARNING --nbmake-timeout=3000 --ignore="tutorials/08-chatgpt.ipynb" --ignore="tutorials/14-food-review-tone-analysis-and-response.ipynb" --ignore="tutorials/15-AI-powered-join.ipynb" --ignore="tutorials/16-homesale-forecasting.ipynb" --ignore="tutorials/17-home-rental-prediction.ipynb" --ignore="tutorials/18-stable-diffusion.ipynb"
>>>>>>> bf022329 (Add stable diffusion integration (#1240))
>>>>>>> 2b924b76 (Add stable diffusion integration (#1240))
code=$?
print_error_code $code "NOTEBOOK TEST"
}
Expand Down
18 changes: 18 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ def read(path, encoding="utf-8"):
"neuralforecast" # MODEL TRAIN AND FINE TUNING
]

imagegen_libs = [
"replicate"
]

### NEEDED FOR DEVELOPER TESTING ONLY

dev_libs = [
Expand Down Expand Up @@ -221,7 +225,14 @@ def read(path, encoding="utf-8"):
"xgboost": xgboost_libs,
"forecasting": forecasting_libs,
# everything except ray, qdrant, ludwig and postgres. The first three fail on pyhton 3.11.
<<<<<<< HEAD
"dev": dev_libs + vision_libs + document_libs + function_libs + notebook_libs + forecasting_libs + sklearn_libs + imagegen_libs + xgboost_libs
=======
<<<<<<< HEAD
"dev": dev_libs + vision_libs + document_libs + function_libs + notebook_libs + forecasting_libs + sklearn_libs,
<<<<<<< HEAD
=======
>>>>>>> 2b924b76 (Add stable diffusion integration (#1240))
=======
"forecasting": forecasting_libs,
# everything except ray, qdrant, ludwig and postgres. The first three fail on pyhton 3.11.
Expand All @@ -240,6 +251,7 @@ def read(path, encoding="utf-8"):
<<<<<<< HEAD
<<<<<<< HEAD
>>>>>>> 40a10ce1 (Bump v0.3.4+ dev)
<<<<<<< HEAD
=======
=======
"forecasting": forecasting_libs,
Expand All @@ -250,6 +262,12 @@ def read(path, encoding="utf-8"):
=======
>>>>>>> 40a10ce1 (Bump v0.3.4+ dev)
>>>>>>> 6d6a14c8 (Bump v0.3.4+ dev)
=======
>>>>>>> eva-master
=======
"dev": dev_libs + vision_libs + document_libs + function_libs + notebook_libs + forecasting_libs + sklearn_libs + imagegen_libs,
>>>>>>> bf022329 (Add stable diffusion integration (#1240))
>>>>>>> 2b924b76 (Add stable diffusion integration (#1240))
}

setup(
Expand Down
9 changes: 9 additions & 0 deletions test/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
is_pinecone_available,
is_qdrant_available,
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> 2b924b76 (Add stable diffusion integration (#1240))
is_replicate_available,
is_sklearn_available,
is_xgboost_available,
Expand Down Expand Up @@ -129,9 +132,15 @@
reason="Run only if forecasting packages available",
)
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> 2b924b76 (Add stable diffusion integration (#1240))

stable_diffusion_skip_marker = pytest.mark.skipif(
is_replicate_available() is False, reason="requires replicate"
)
<<<<<<< HEAD
=======
>>>>>>> 2dacff69 (feat: sync master staging (#1050))
=======
>>>>>>> 2b924b76 (Add stable diffusion integration (#1240))

0 comments on commit 8a8a90a

Please sign in to comment.