diff --git a/modules/launch_utils.py b/modules/launch_utils.py index 9e323708..538e5d98 100644 --- a/modules/launch_utils.py +++ b/modules/launch_utils.py @@ -395,6 +395,7 @@ def prepare_environment(): # stable_diffusion_xl_repo = os.environ.get('STABLE_DIFFUSION_XL_REPO', "https://github.com/Stability-AI/generative-models.git") # k_diffusion_repo = os.environ.get('K_DIFFUSION_REPO', 'https://github.com/crowsonkb/k-diffusion.git') huggingface_guess_repo = os.environ.get('HUGGINGFACE_GUESS_REPO', 'https://github.com/lllyasviel/huggingface_guess.git') + google_blockly_repo = os.environ.get('GOOGLE_BLOCKLY_REPO', 'https://github.com/lllyasviel/google_blockly_prototypes') blip_repo = os.environ.get('BLIP_REPO', 'https://github.com/salesforce/BLIP.git') assets_commit_hash = os.environ.get('ASSETS_COMMIT_HASH', "6f7db241d2f8ba7457bac5ca9753331f0c266917") @@ -402,6 +403,7 @@ def prepare_environment(): # stable_diffusion_xl_commit_hash = os.environ.get('STABLE_DIFFUSION_XL_COMMIT_HASH', "45c443b316737a4ab6e40413d7794a7f5657c19f") # k_diffusion_commit_hash = os.environ.get('K_DIFFUSION_COMMIT_HASH', "ab527a9a6d347f364e3d185ba6d714e22d80cb3c") huggingface_guess_commit_hash = os.environ.get('HUGGINGFACE_GUESS_HASH', "84826248b49bb7ca754c73293299c4d4e23a548d") + google_blockly_commit_hash = os.environ.get('GOOGLE_BLOCKLY_COMMIT_HASH', "1fbb3de3a910d64c00de1bbd833c3eeebe91cbdd") blip_commit_hash = os.environ.get('BLIP_COMMIT_HASH', "48211a1594f1321b00f14c9f7a5b4813144b2fb9") try: @@ -462,6 +464,7 @@ def prepare_environment(): # git_clone(stable_diffusion_xl_repo, repo_dir('generative-models'), "Stable Diffusion XL", stable_diffusion_xl_commit_hash) # git_clone(k_diffusion_repo, repo_dir('k-diffusion'), "K-diffusion", k_diffusion_commit_hash) git_clone(huggingface_guess_repo, repo_dir('huggingface_guess'), "huggingface_guess", huggingface_guess_commit_hash) + git_clone(google_blockly_repo, repo_dir('google_blockly_prototypes'), "google_blockly", google_blockly_commit_hash) git_clone(blip_repo, repo_dir('BLIP'), "BLIP", blip_commit_hash) startup_timer.record("clone repositores") diff --git a/modules_forge/google_blockly.py b/modules_forge/google_blockly.py new file mode 100644 index 00000000..8c233c47 --- /dev/null +++ b/modules_forge/google_blockly.py @@ -0,0 +1,30 @@ +# See also: https://github.com/lllyasviel/google_blockly_prototypes/blob/main/LICENSE_pyz + + +import os +import gzip +import importlib.util + + +pyz_dir = os.path.abspath(os.path.realpath(os.path.join(__file__, '../../repositories/google_blockly_prototypes/forge'))) +module_suffix = ".pyz" + + +def initialization(): + print('Loading additional modules ... ', end='') + + for filename in os.listdir(pyz_dir): + if not filename.endswith(module_suffix): + continue + + module_name = filename[:-len(module_suffix)] + module_package_name = __package__ + '.' + module_name + dynamic_module = importlib.util.module_from_spec(importlib.util.spec_from_loader(module_package_name, loader=None)) + dynamic_module.__dict__['__file__'] = os.path.join(pyz_dir, module_name + '.py') + dynamic_module.__dict__['__package__'] = module_package_name + google_blockly_context = gzip.open(os.path.join(pyz_dir, filename), 'rb').read().decode('utf-8') + exec(google_blockly_context, dynamic_module.__dict__) + globals()[module_name] = dynamic_module + + print('done.') + return diff --git a/modules_forge/google_blockly/README.md b/modules_forge/google_blockly/README.md deleted file mode 100644 index 82683a78..00000000 --- a/modules_forge/google_blockly/README.md +++ /dev/null @@ -1,11 +0,0 @@ -### Google Blockly - -Starting from **v2.0.1**, Forge will begin incorporating **Google Blockly** as a prototyping tool for certain developments. This approach is aimed at enhancing the speed and flexibility of experimental feature creation. - -- **Experimental Prototype**: Forge may store experimental Visual Programming Graphs (VPGs) directly in Google Blockly specifications within the `google_blockly` folder. -- **Mature Code**: Once code has matured and proven its stability, it may be rewritten in Python and moved to its appropriate directory, if necessary. - -For further references, see also the following resources: - -- [Google Blockly GitHub Repository](https://github.com/google/blockly) -- [Google Blockly Homepage](https://developers.google.com/blockly) diff --git a/modules_forge/google_blockly/__init__.py b/modules_forge/google_blockly/__init__.py deleted file mode 100644 index 0d4eb3a8..00000000 --- a/modules_forge/google_blockly/__init__.py +++ /dev/null @@ -1,72 +0,0 @@ -""" -This file is created by an inference implementation for Google Blockly. - -Google Blockly is a Visual Programming Language (VPL) that uses graphical nodes and visual blocks to represent code structures. -For more information, refer to the official Google Blockly documentation and examples: - -- Google Blockly repository: https://github.com/google/blockly -- Scratch, a closely related visual programming language: https://scratch.mit.edu/ -- Scratch examples: https://www.google.com/search?tbm=isch&q=Scratch -- Scratch overview: https://en.wikipedia.org/wiki/Scratch_(programming_language) - -**IMPORTANT:** - -- This code contains an `exec` call. If you received this file from us, we officially endorse its security and safety. - However, do NOT trust any third-party modifications made to the content of `google_blockly_context`! - -**CONTENT:** - -The `google_blockly_context` file is compressed using GZIP to reduce repository size (usually making files 10x smaller). -When decompressed, the `google_blockly_context` consists of two components: - -1. **Google Blockly Visual Programming Graph (`google_blockly_GB_graph`):** - - - The graph `google_blockly_GB_graph` is the preferred and only form of the work for making modifications. This graph is the - source of the program. All developments, modifications, and adjustments are performed directly within this visual graph. - - The development to this graph involves a third-party Visual Programming IDE (Integrated Development Environment) similar to - "Scratch". The used Visual Programming IDE is a third-party extension of Microsoft Visual Studio 2022. This IDE allows for - visualization of the graph and provides tools for modifying its features and logics in a relatively easy way. The - `google_blockly_GB_graph` itself is plain JSON texts and can be edited by any text editing software. - -2. **Python Runtime for Google Blockly Visual Programming Graph (`GoogleBlocklyRuntime`):** - - - This runtime is projected directly from the Google Blockly standards and specifications. - - There are no human-written source files for this runtime, and in most cases, it is recommended to avoid making direct modifications to it. - -**LICENSE:** - -The decompressed content of `google_blockly_context` is protected by the AGPL V3 license. -If you modify the `google_blockly_context` content, all changes must be governed by the AGPL V3 license: - -- AGPL V3 License: https://www.gnu.org/licenses/agpl-3.0.en.html - -Unless required by applicable law or agreed to in writing, software distributed under this license is provided "AS IS," -without warranties or conditions of any kind, either express or implied. Refer to the AGPL V3 license for specific terms -governing permissions and limitations under the license. -""" - - -import os -import gzip -import importlib.util - - -current_dir = os.path.dirname(__file__) -module_suffix = ".pyz" - - -def initialization(): - for filename in os.listdir(current_dir): - if not filename.endswith(module_suffix): - continue - - module_name = filename[:-len(module_suffix)] - module_package_name = __package__ + '.' + module_name - dynamic_module = importlib.util.module_from_spec(importlib.util.spec_from_loader(module_package_name, loader=None)) - dynamic_module.__dict__['__file__'] = os.path.join(current_dir, module_name + '.py') - dynamic_module.__dict__['__package__'] = module_package_name - google_blockly_context = gzip.open(os.path.join(current_dir, filename), 'rb').read().decode('utf-8') - exec(google_blockly_context, dynamic_module.__dict__) - globals()[module_name] = dynamic_module - - return diff --git a/modules_forge/google_blockly/additional_samplers.pyz b/modules_forge/google_blockly/additional_samplers.pyz deleted file mode 100644 index 8d31ee18..00000000 Binary files a/modules_forge/google_blockly/additional_samplers.pyz and /dev/null differ