GithubHelp home page GithubHelp logo

torrinworx / cozy-auto-texture Goto Github PK

View Code? Open in Web Editor NEW
106.0 8.0 6.0 72 KB

A Blender add-on for generating free textures using the Stable Diffusion AI text to image model.

License: GNU General Public License v3.0

Python 100.00%
ai blender blender-addon blender-python dall-e diffusion-models machine-learning stable-diffusion 3d-art 3d-models

cozy-auto-texture's Introduction

Cozy Auto Texture

Created by Torrin Leonard License Donate stars

Description

This addon bridges the complexity of the Stable Diffusion AI with the simple GUI of Blender. It is the simplest and most straight forward way to start creating AI textures in Blender.

Features

  • Easy setup, no need for admin privileges, no need to even glance at code
  • Open source
  • Simple download process, weights hosted for free by This Cozy Studio Inc.
  • Weights are independent of Blender version, meaning you can update Blender without needing to reinstall your weights!
  • Simple and intuitive user interface
  • Responsible and ethical use of Stable Diffusion weights

The Cozy Auto Texture Blender add-on can automatically generate textures withing Blender for whatever project you are working on. All dependencies are automatically downloaded, including the Stable Diffusion weights which This Cozy Studio Inc. hosts free of charge.

Instillation Guide

  1. Download the add-on zip file by clicking the above button:

image

  1. Open Blender and navigate to Edit --> Preferences --> Add-Ons:

image

  1. Click Install and select the zip file downloaded in step #1:

image

  1. Search for Cozy Auto Texture in the Add-Ons tab and check the checkbox to enable it:

image

  1. Set the Environment Path on a drive with more that 10GB of free storage:

image

  1. Read and accept the Stable Diffusion and Cozy Auto Texture license agreements, then click Install Dependencies:

Note: Blender will go into "Not Responding Mode" while the dependency and weights install, in order to visualize progress you can enable the Blender System Console by going to Window --> Toggle System Console before you click Install Dependencies in step #5. This window will display installation progress. Do not shutdown Blender until you see "Dependencies installed successfully" appear. This process will download approximetely 10GB of data.

image

cozy-auto-texture's People

Contributors

torrinworx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cozy-auto-texture's Issues

Use Venv instead of installing packages inside Blender's Python

  • Functinality to install Venv on a system path so that other versions of Blender can access the same SD repository.
  • Allow user to specify Venv download path with a string field in the add-on preferences. If path not specified, download path to default system path on a drive with more than 8 GB of space available.
  • Allow user to delete Venv and reinstall dependencies
  • Allow user to update Venv without completely re-installing it
  • Make .bat files compatible with Linux and Darwin OS': https://stackoverflow.com/questions/589905/equivalent-of-double-clickable-sh-and-bat-on-mac

Create user agreement checkbox for Stable Diffusion license.

The Stable Diffusion license provided by Hugging Face should be displayed or a link provided to the user before they download the Stable Diffusion model. It should be a checkbox located in the download dependencies section of the add-on preferences.

Improvements and new features

Other:

  • Functionality to install Venv on a system path so that other versions of Blender can access the same SD repository.
  • Allow user to specify Venv download path with a string field in the add-on preferences. If path not specified, download path to default system path on a drive with more than 8 GB of space available.
  • Allow user to delete Venv and reinstall dependencies
  • Allow user to update Venv without completely re-installing it
  • Make .bat files compatible with Linux and Darwin OS': https://stackoverflow.com/questions/589905/equivalent-of-double-clickable-sh-and-bat-on-mac

Diffusers issue with importing transformers, numpy, etc

Various error messages occur after the user attempts to generate a texture:

Read prefs: C:\Users\torri\AppData\Roaming\Blender Foundation\Blender\3.2\config\userpref.blend
D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\torch\_utils.py:133: UserWarning: Failed to initialize NumPy: module compiled against API version 0x10 but this version of numpy is 0xf (Triggered internally at  ..\torch\csrc\utils\tensor_numpy.cpp:68.)
  t = torch.tensor([], dtype=storage.dtype, device=storage._untyped().device)
ftfy or spacy is not installed using BERT BasicTokenizer instead of ftfy.
Traceback (most recent call last):
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\scripts\addons\Cozy-Auto-Texture\__init__.py", line 233, in execute
    text2img(UserInput)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\scripts\addons\Cozy-Auto-Texture\src\main.py", line 47, in text2img
    pipe = StableDiffusionPipeline.from_pretrained(model_path)  # Specify model path
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\diffusers\pipeline_utils.py", line 247, in from_pretrained
    loaded_sub_model = load_method(os.path.join(cached_folder, name), **loading_kwargs)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\diffusers\configuration_utils.py", line 97, in from_config
    model = cls(**init_dict)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\diffusers\configuration_utils.py", line 312, in inner_init
    init(self, *args, **init_kwargs)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\diffusers\schedulers\scheduling_pndm.py", line 98, in __init__
    self.set_format(tensor_format=tensor_format)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\diffusers\schedulers\scheduling_utils.py", line 33, in set_format
    setattr(self, key, torch.from_numpy(value))
RuntimeError: Numpy is not available
Error: Python: Traceback (most recent call last):
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\scripts\addons\Cozy-Auto-Texture\__init__.py", line 233, in execute
    text2img(UserInput)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\scripts\addons\Cozy-Auto-Texture\src\main.py", line 47, in text2img
    pipe = StableDiffusionPipeline.from_pretrained(model_path)  # Specify model path
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\diffusers\pipeline_utils.py", line 247, in from_pretrained
    loaded_sub_model = load_method(os.path.join(cached_folder, name), **loading_kwargs)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\diffusers\configuration_utils.py", line 97, in from_config
    model = cls(**init_dict)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\diffusers\configuration_utils.py", line 312, in inner_init
    init(self, *args, **init_kwargs)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\diffusers\schedulers\scheduling_pndm.py", line 98, in __init__
    self.set_format(tensor_format=tensor_format)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\diffusers\schedulers\scheduling_utils.py", line 33, in set_format
    setattr(self, key, torch.from_numpy(value))
RuntimeError: Numpy is not available

Reloading: <module 'bl_operators' from 'D:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\scripts\\startup\\bl_operators\\__init__.py'>
Reloading: <module 'bl_ui' from 'D:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\scripts\\startup\\bl_ui\\__init__.py'>
Reloading: <module 'keyingsets_builtins' from 'D:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\scripts\\startup\\keyingsets_builtins.py'>
Reloading: <module 'nodeitems_builtins' from 'D:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\scripts\\startup\\nodeitems_builtins.py'>
Exception in module register(): D:\Program Files\Blender Foundation\Blender 3.2\3.2\scripts\addons\Cozy-Auto-Texture\__init__.py
Traceback (most recent call last):
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\scripts\modules\addon_utils.py", line 371, in enable
    mod.register()
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\scripts\addons\Cozy-Auto-Texture\__init__.py", line 447, in register
    import_module(module_name=dependency.module, global_name=dependency.name)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\scripts\addons\Cozy-Auto-Texture\__init__.py", line 112, in import_module
    importlib.reload(globals()[global_name])
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\importlib\__init__.py", line 169, in reload
    _bootstrap._exec(spec, module)
  File "<frozen importlib._bootstrap>", line 619, in _exec
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\torch\__init__.py", line 74, in <module>
    if all([not os.path.exists(os.path.join(p, 'nvToolsExt64_1.dll')) for p in dll_paths]):
TypeError: all(): argument 'input' (position 1) must be Tensor, not list
gc.collect() -> 37358
addon_utils.disable: Cozy-Auto-Texture not disabled
Reloading: <module 'bl_operators' from 'D:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\scripts\\startup\\bl_operators\\__init__.py'>
Reloading: <module 'bl_ui' from 'D:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\scripts\\startup\\bl_ui\\__init__.py'>
Reloading: <module 'keyingsets_builtins' from 'D:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\scripts\\startup\\keyingsets_builtins.py'>
Reloading: <module 'nodeitems_builtins' from 'D:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\scripts\\startup\\nodeitems_builtins.py'>
gc.collect() -> 36144
ftfy or spacy is not installed using BERT BasicTokenizer instead of ftfy.
Traceback (most recent call last):
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\scripts\addons\Cozy-Auto-Texture\__init__.py", line 233, in execute
    text2img(UserInput)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\scripts\addons\Cozy-Auto-Texture\src\main.py", line 47, in text2img
    pipe = StableDiffusionPipeline.from_pretrained(model_path)  # Specify model path
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\diffusers\pipeline_utils.py", line 247, in from_pretrained
    loaded_sub_model = load_method(os.path.join(cached_folder, name), **loading_kwargs)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\diffusers\configuration_utils.py", line 97, in from_config
    model = cls(**init_dict)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\diffusers\configuration_utils.py", line 312, in inner_init
    init(self, *args, **init_kwargs)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\diffusers\schedulers\scheduling_pndm.py", line 98, in __init__
    self.set_format(tensor_format=tensor_format)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\diffusers\schedulers\scheduling_utils.py", line 33, in set_format
    setattr(self, key, torch.from_numpy(value))
RuntimeError: Numpy is not available
Error: Python: Traceback (most recent call last):
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\scripts\addons\Cozy-Auto-Texture\__init__.py", line 233, in execute
    text2img(UserInput)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\scripts\addons\Cozy-Auto-Texture\src\main.py", line 47, in text2img
    pipe = StableDiffusionPipeline.from_pretrained(model_path)  # Specify model path
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\diffusers\pipeline_utils.py", line 247, in from_pretrained
    loaded_sub_model = load_method(os.path.join(cached_folder, name), **loading_kwargs)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\diffusers\configuration_utils.py", line 97, in from_config
    model = cls(**init_dict)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\diffusers\configuration_utils.py", line 312, in inner_init
    init(self, *args, **init_kwargs)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\diffusers\schedulers\scheduling_pndm.py", line 98, in __init__
    self.set_format(tensor_format=tensor_format)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\diffusers\schedulers\scheduling_utils.py", line 33, in set_format
    setattr(self, key, torch.from_numpy(value))
RuntimeError: Numpy is not available

The majority of this is to do with Numpy or Transformers, I believe it's an issue with the Stable Diffusion download not knowing what Python version to use as it's installed within Blenders add-on system and might be using the users Python version. However I have not determined if this is the root cause, it's just my suspicion.

Cozy-Auto-Texture can not use

Python: Traceback (most recent call last):
File "C:\Program Files\Blender Foundation\Blender 4.0\4.0\python\lib\subprocess.py", line 526, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'C:\Tools\Blender\CozyAutoTexture\Cozy-Auto-Texture-Files\venv\Scripts\activate.bat' returned non-zero exit status 1.

Add-on fails when restarted (CTRL+R) due to Tensor flow import issue.

After installing the add-on successfully, and installing the dependencies, if the user (or developer) restarts the add-on with CTRL+R, Cozy Auto Texture reverts back to it's pre-dependency state:
image

This error message also appears in the Blender System Console:

Reloading: <module 'bl_operators' from 'D:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\scripts\\startup\\bl_operators\\__init__.py'>
Reloading: <module 'bl_ui' from 'D:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\scripts\\startup\\bl_ui\\__init__.py'>
Reloading: <module 'keyingsets_builtins' from 'D:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\scripts\\startup\\keyingsets_builtins.py'>
Reloading: <module 'nodeitems_builtins' from 'D:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\scripts\\startup\\nodeitems_builtins.py'>
reloading addon: Cozy-Auto-Texture 1662345437.949952 1662345676.4157345 'D:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\scripts\\addons\\Cozy-Auto-Texture\\__init__.py'
module changed on disk: 'D:\\Program Files\\Blender Foundation\\Blender 3.2\\3.2\\scripts\\addons\\Cozy-Auto-Texture\\__init__.py' reloading...
Exception in module register(): D:\Program Files\Blender Foundation\Blender 3.2\3.2\scripts\addons\Cozy-Auto-Texture\__init__.py
Traceback (most recent call last):
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\scripts\modules\addon_utils.py", line 371, in enable
    mod.register()
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\scripts\addons\Cozy-Auto-Texture\__init__.py", line 418, in register
    import_module(module_name=dependency.module, global_name=dependency.name)
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\scripts\addons\Cozy-Auto-Texture\__init__.py", line 104, in import_module
    importlib.reload(globals()[global_name])
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\importlib\__init__.py", line 169, in reload
    _bootstrap._exec(spec, module)
  File "<frozen importlib._bootstrap>", line 619, in _exec
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "D:\Program Files\Blender Foundation\Blender 3.2\3.2\python\lib\site-packages\torch\__init__.py", line 74, in <module>
    if all([not os.path.exists(os.path.join(p, 'nvToolsExt64_1.dll')) for p in dll_paths]):
TypeError: all(): argument 'input' (position 1) must be Tensor, not list
gc.collect() -> 10367

The down side to this is that you need to delete all the dependencies, restart Blender, and fresh install the dependencies in order for Cozy Auto Texture to function with the new changes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.