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

Direct users who downloaded source to download release #134

Merged
merged 9 commits into from
Sep 26, 2022
59 changes: 35 additions & 24 deletions generator_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,30 +113,6 @@ def queue_exception(fatal, err):
return

def main():
from absolute_path import absolute_path
# Support Apple Silicon GPUs as much as possible.
os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"
sys.path.append(absolute_path("stable_diffusion/"))
sys.path.append(absolute_path("stable_diffusion/src/clip"))
sys.path.append(absolute_path("stable_diffusion/src/k-diffusion"))
sys.path.append(absolute_path("stable_diffusion/src/taming-transformers"))

site.addsitedir(absolute_path(".python_dependencies"))
import pkg_resources
pkg_resources._initialize_master_working_set()

from stable_diffusion.ldm.generate import Generate
from omegaconf import OmegaConf
from PIL import ImageOps
from io import StringIO

models_config = absolute_path('stable_diffusion/configs/models.yaml')
model = 'stable-diffusion-1.4'

models = OmegaConf.load(models_config)
config = absolute_path('stable_diffusion/' + models[model].config)
weights = absolute_path('stable_diffusion/' + models[model].weights)

stdin = sys.stdin.buffer
stdout = sys.stdout.buffer
sys.stdout = open(os.devnull, 'w') # prevent stable diffusion logs from breaking ipc
Expand All @@ -161,6 +137,41 @@ def writeException(fatal, e):
writeStr(e)
stdout.flush()

try:
from absolute_path import absolute_path
# Support Apple Silicon GPUs as much as possible.
os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"
sys.path.append(absolute_path("stable_diffusion/"))
sys.path.append(absolute_path("stable_diffusion/src/clip"))
sys.path.append(absolute_path("stable_diffusion/src/k-diffusion"))
sys.path.append(absolute_path("stable_diffusion/src/taming-transformers"))

site.addsitedir(absolute_path(".python_dependencies"))
import pkg_resources
pkg_resources._initialize_master_working_set()

from stable_diffusion.ldm.generate import Generate
from omegaconf import OmegaConf
from PIL import ImageOps
from io import StringIO
except ModuleNotFoundError as e:
min_files = 10 # bump this up if more files get added to .python_dependencies in source
# don't set too high so it can still pass info on individual missing modules
if not os.path.exists(".python_dependencies") or len(os.listdir()) < min_files:
e = "Python dependencies are missing. Click update to download full addon."
NullSenseStudio marked this conversation as resolved.
Show resolved Hide resolved
writeException(True, e)
return
except Exception as e:
NullSenseStudio marked this conversation as resolved.
Show resolved Hide resolved
writeException(True, e)
NullSenseStudio marked this conversation as resolved.
Show resolved Hide resolved
return

models_config = absolute_path('stable_diffusion/configs/models.yaml')
model = 'stable-diffusion-1.4'

models = OmegaConf.load(models_config)
config = absolute_path('stable_diffusion/' + models[model].config)
weights = absolute_path('stable_diffusion/' + models[model].weights)

byte_to_normalized = 1.0 / 255.0
def write_pixels(image):
writeUInt(4,image.width)
Expand Down
3 changes: 3 additions & 0 deletions operators/dream_texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ def handle_exception(fatal, err):
if fatal:
kill_generator()
self.report({'ERROR'},err)
if err == "Python dependencies are missing. Click update to download full addon.":
from .open_latest_version import force_show_update
force_show_update()


def step_progress_update(self, context):
Expand Down
3 changes: 3 additions & 0 deletions operators/open_latest_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def check_for_updates():

def new_version_available():
return not latest_version == VERSION
def force_show_update():
NullSenseStudio marked this conversation as resolved.
Show resolved Hide resolved
global VERSION
VERSION = (0,0,0)

class OpenLatestVersion(bpy.types.Operator):
bl_idname = "stable_diffusion.open_latest_version"
Expand Down