From a56102252d32ae11334f97a0491a15e3d8ef4e36 Mon Sep 17 00:00:00 2001 From: Andy Xu Date: Sun, 15 Oct 2023 12:09:03 -0700 Subject: [PATCH] Add stable diffusion integration (#1240) Reopen the #1111. --------- Co-authored-by: sudoboi Co-authored-by: Abhijith S Raj <63101280+sudoboi@users.noreply.github.com> --- docs/_toc.yml | 9 ++++++++ evadb/evadb.yml | 4 ++++ evadb/functions/dalle.py | 4 ++++ evadb/functions/function_bootstrap_queries.py | 13 +++++++++++ evadb/functions/stable_diffusion.py | 4 ++++ evadb/utils/generic_utils.py | 11 +++++++++ script/test/test.sh | 18 +++++++++++++++ setup.py | 23 +++++++++++++++++++ test/markers.py | 14 +++++++++++ 9 files changed, 100 insertions(+) diff --git a/docs/_toc.yml b/docs/_toc.yml index 04466d6326..5aedd7e97b 100644 --- a/docs/_toc.yml +++ b/docs/_toc.yml @@ -1042,12 +1042,15 @@ parts: <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= >>>>>>> b87af508 (feat: sync master staging (#1050)) ======= >>>>>>> 03a6c555 (feat: sync master staging (#1050)) ======= >>>>>>> 32e513d7 (docs: updates) +======= +>>>>>>> 8a8a90aa (Add stable diffusion integration (#1240)) - file: source/reference/ai/stablediffusion title: Stable Diffusion @@ -1065,10 +1068,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 diff --git a/evadb/evadb.yml b/evadb/evadb.yml index 11a2380baa..f60fb2eb98 100644 --- a/evadb/evadb.yml +++ b/evadb/evadb.yml @@ -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)) diff --git a/evadb/functions/dalle.py b/evadb/functions/dalle.py index d55397cc1c..70f6593df4 100644 --- a/evadb/functions/dalle.py +++ b/evadb/functions/dalle.py @@ -82,7 +82,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 diff --git a/evadb/functions/function_bootstrap_queries.py b/evadb/functions/function_bootstrap_queries.py index 024e16c3da..25fc4ae12a 100644 --- a/evadb/functions/function_bootstrap_queries.py +++ b/evadb/functions/function_bootstrap_queries.py @@ -396,6 +396,9 @@ ) <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 2b924b76 (Add stable diffusion integration (#1240)) dalle_function_query = """CREATE FUNCTION IF NOT EXISTS DallE IMPL '{}/functions/dalle.py'; """.format( @@ -619,6 +622,7 @@ def init_builtin_functions(db: EvaDBDatabase, mode: str = "debug") -> None: <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD <<<<<<< HEAD stablediffusion_function_query, dalle_function_query, @@ -632,10 +636,13 @@ def init_builtin_functions(db: EvaDBDatabase, mode: str = "debug") -> None: dalle_function_query, >>>>>>> 2b924b76 (Add stable diffusion integration (#1240)) ======= +======= +>>>>>>> 8a8a90aa (Add stable diffusion integration (#1240)) stablediffusion_function_query, dalle_function_query, ======= >>>>>>> 2dacff69 (feat: sync master staging (#1050)) +<<<<<<< HEAD >>>>>>> 9fe75f29 (feat: sync master staging (#1050)) ======= stablediffusion_function_query, @@ -643,6 +650,12 @@ def init_builtin_functions(db: EvaDBDatabase, mode: str = "debug") -> None: ======= >>>>>>> 2dacff69 (feat: sync master staging (#1050)) >>>>>>> b87af508 (feat: sync master staging (#1050)) +======= +======= + stablediffusion_function_query, + dalle_function_query, +>>>>>>> 2b924b76 (Add stable diffusion integration (#1240)) +>>>>>>> 8a8a90aa (Add stable diffusion integration (#1240)) ] # if mode is 'debug', add debug functions diff --git a/evadb/functions/stable_diffusion.py b/evadb/functions/stable_diffusion.py index 742456f832..110cfb1a64 100644 --- a/evadb/functions/stable_diffusion.py +++ b/evadb/functions/stable_diffusion.py @@ -86,7 +86,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 diff --git a/evadb/utils/generic_utils.py b/evadb/utils/generic_utils.py index a347f8544e..cc6171e0ab 100644 --- a/evadb/utils/generic_utils.py +++ b/evadb/utils/generic_utils.py @@ -1018,12 +1018,17 @@ def string_comparison_case_insensitive(string_1, string_2) -> bool: <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= >>>>>>> 2b924b76 (Add stable diffusion integration (#1240)) ======= >>>>>>> 2170a7a9 (Bump v0.3.4+ dev) ======= >>>>>>> c5f43c65 (Bump v0.3.4+ dev) +======= +======= +>>>>>>> 2b924b76 (Add stable diffusion integration (#1240)) +>>>>>>> 8a8a90aa (Add stable diffusion integration (#1240)) def try_to_import_replicate(): @@ -1045,10 +1050,14 @@ def is_replicate_available(): <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 8a8a90aa (Add stable diffusion integration (#1240)) ======= >>>>>>> 40a10ce1 (Bump v0.3.4+ dev) ======= >>>>>>> 2b924b76 (Add stable diffusion integration (#1240)) +<<<<<<< HEAD ======= ======= >>>>>>> 40a10ce1 (Bump v0.3.4+ dev) @@ -1057,3 +1066,5 @@ def is_replicate_available(): ======= >>>>>>> 40a10ce1 (Bump v0.3.4+ dev) >>>>>>> c5f43c65 (Bump v0.3.4+ dev) +======= +>>>>>>> 8a8a90aa (Add stable diffusion integration (#1240)) diff --git a/script/test/test.sh b/script/test/test.sh index 25cfdcaf4d..4c15a14a85 100644 --- a/script/test/test.sh +++ b/script/test/test.sh @@ -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 <<<<<<< HEAD @@ -147,6 +153,7 @@ notebook_test() { <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= ======= >>>>>>> 6d6a14c8 (Bump v0.3.4+ dev) @@ -207,6 +214,8 @@ notebook_test() { ======= ======= ======= +>>>>>>> 8a8a90aa (Add stable diffusion integration (#1240)) +======= ======= >>>>>>> 6d6a14c8 (Bump v0.3.4+ dev) 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" @@ -226,6 +235,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) >>>>>>> 6d6a14c8 (Bump v0.3.4+ dev) +<<<<<<< HEAD >>>>>>> 8da6decc (Bump v0.3.4+ dev) >>>>>>> 22e78346 (Bump v0.3.4+ dev) ======= @@ -244,6 +254,14 @@ notebook_test() { >>>>>>> 30d7834d (release: merge staging into master (#1032)) ======= >>>>>>> ae08f806 (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)) +>>>>>>> 8a8a90aa (Add stable diffusion integration (#1240)) code=$? print_error_code $code "NOTEBOOK TEST" } diff --git a/setup.py b/setup.py index 654ec8d3a9..679b84e563 100644 --- a/setup.py +++ b/setup.py @@ -303,6 +303,10 @@ def read(path, encoding="utf-8"): ] >>>>>>> 03a6c555 (feat: sync master staging (#1050)) +imagegen_libs = [ + "replicate" +] + ### NEEDED FOR DEVELOPER TESTING ONLY dev_libs = [ @@ -390,6 +394,7 @@ def read(path, encoding="utf-8"): "forecasting": forecasting_libs, # everything except ray, qdrant, ludwig and postgres. The first three fail on pyhton 3.11. <<<<<<< HEAD +<<<<<<< HEAD <<<<<<< HEAD "dev": dev_libs + vision_libs + document_libs + function_libs + notebook_libs + forecasting_libs + sklearn_libs + imagegen_libs + xgboost_libs ======= @@ -397,13 +402,21 @@ def read(path, encoding="utf-8"): ======= >>>>>>> 4771bdec (Starting the change for XGBoost integration into EVADb. (#1232)) <<<<<<< HEAD +======= + "dev": dev_libs + vision_libs + document_libs + function_libs + notebook_libs + forecasting_libs + sklearn_libs + imagegen_libs + xgboost_libs +======= +<<<<<<< HEAD +>>>>>>> 8a8a90aa (Add stable diffusion integration (#1240)) "dev": dev_libs + vision_libs + document_libs + function_libs + notebook_libs + forecasting_libs + sklearn_libs, <<<<<<< HEAD ======= >>>>>>> 2b924b76 (Add stable diffusion integration (#1240)) ======= +<<<<<<< HEAD ======= >>>>>>> b87af508 (feat: sync master staging (#1050)) +======= +>>>>>>> 8a8a90aa (Add stable diffusion integration (#1240)) "forecasting": forecasting_libs, # everything except ray, qdrant, ludwig and postgres. The first three fail on pyhton 3.11. "dev": dev_libs + vision_libs + document_libs + function_libs + notebook_libs + forecasting_libs, @@ -430,6 +443,7 @@ def read(path, encoding="utf-8"): <<<<<<< HEAD <<<<<<< HEAD >>>>>>> 40a10ce1 (Bump v0.3.4+ dev) +<<<<<<< HEAD ======= ======= "forecasting": forecasting_libs, @@ -519,6 +533,7 @@ def read(path, encoding="utf-8"): ======= >>>>>>> 40a10ce1 (Bump v0.3.4+ dev) >>>>>>> 6d6a14c8 (Bump v0.3.4+ dev) +<<<<<<< HEAD >>>>>>> 8da6decc (Bump v0.3.4+ dev) >>>>>>> 22e78346 (Bump v0.3.4+ dev) ======= @@ -533,6 +548,14 @@ def read(path, encoding="utf-8"): >>>>>>> 40a10ce1 (Bump v0.3.4+ dev) >>>>>>> 6d6a14c8 (Bump v0.3.4+ dev) >>>>>>> ae08f806 (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)) +>>>>>>> 8a8a90aa (Add stable diffusion integration (#1240)) } setup( diff --git a/test/markers.py b/test/markers.py index b8cfcb564e..336d97f6c8 100644 --- a/test/markers.py +++ b/test/markers.py @@ -143,6 +143,9 @@ is_pinecone_available, is_qdrant_available, <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 2b924b76 (Add stable diffusion integration (#1240)) is_replicate_available, is_sklearn_available, <<<<<<< HEAD @@ -260,12 +263,17 @@ <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD ======= >>>>>>> 2b924b76 (Add stable diffusion integration (#1240)) ======= >>>>>>> 9fe75f29 (feat: sync master staging (#1050)) ======= >>>>>>> b87af508 (feat: sync master staging (#1050)) +======= +======= +>>>>>>> 2b924b76 (Add stable diffusion integration (#1240)) +>>>>>>> 8a8a90aa (Add stable diffusion integration (#1240)) stable_diffusion_skip_marker = pytest.mark.skipif( is_replicate_available() is False, reason="requires replicate" @@ -273,10 +281,14 @@ <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 8a8a90aa (Add stable diffusion integration (#1240)) ======= >>>>>>> 2dacff69 (feat: sync master staging (#1050)) ======= >>>>>>> 2b924b76 (Add stable diffusion integration (#1240)) +<<<<<<< HEAD ======= ======= >>>>>>> 2dacff69 (feat: sync master staging (#1050)) @@ -285,3 +297,5 @@ ======= >>>>>>> 2dacff69 (feat: sync master staging (#1050)) >>>>>>> b87af508 (feat: sync master staging (#1050)) +======= +>>>>>>> 8a8a90aa (Add stable diffusion integration (#1240))