Skip to content

Instantly share code, notes, and snippets.

from turtle import forward
from pyparsing import Forward
import torch
from PIL import Image
import numpy as np
from transformers import CLIPTextModel, CLIPTokenizer
from diffusers import AutoencoderKL, UNet2DConditionModel, EulerDiscreteScheduler
# from diffusers import UNet2DModel
import torch
from PIL import Image
import numpy as np
from transformers import CLIPTextModel, CLIPTokenizer
from diffusers import AutoencoderKL, UNet2DConditionModel, EulerDiscreteScheduler
# from diffusers import UNet2DModel
repo_id = "/Volumes/Acasis1TB/machine_learning/stable-diffusion-xl-base-1.0"
torch_device = "mps"
large_weights: ['time_embedding_linear_1_weight_to_fp16', 'time_embedding_linear_2_weight_to_fp16', 'add_embedding_linear_1_weight_to_fp16', 'add_embedding_linear_2_weight_to_fp16', 'down_blocks_0_resnets_0_conv1_weight_to_fp16', 'down_blocks_0_resnets_0_time_emb_proj_weight_to_fp16', 'down_blocks_0_resnets_0_conv2_weight_to_fp16', 'down_blocks_0_resnets_1_conv1_weight_to_fp16', 'down_blocks_0_resnets_1_time_emb_proj_weight_to_fp16', 'down_blocks_0_resnets_1_conv2_weight_to_fp16', 'down_blocks_0_downsamplers_0_conv_weight_to_fp16', 'down_blocks_1_resnets_0_conv1_weight_to_fp16', 'down_blocks_1_resnets_0_time_emb_proj_weight_to_fp16', 'down_blocks_1_resnets_0_conv2_weight_to_fp16', 'down_blocks_1_resnets_0_conv_shortcut_weight_to_fp16', 'down_blocks_1_attentions_0_proj_in_weight_to_fp16', 'down_blocks_1_attentions_0_transformer_blocks_0_attn1_to_q_weight_to_fp16', 'down_blocks_1_attentions_0_transformer_blocks_0_attn1_to_k_weight_to_fp16', 'down_blocks_1_attentions_0_transformer_blocks_0_attn1_to_v_weight_to_f
@rovo79
rovo79 / Blocks.md
Created March 22, 2023 01:06 — forked from davidjguru/Blocks.md
Drupal 8 programmatic solutions

Render custom blocks

$bid = 'myblock';
$block = \Drupal\block_content\Entity\BlockContent::load($bid);
$render = \Drupal::entityTypeManager()->getViewBuilder('block_content')->view($block);

Render plugin blocks

$block_manager = \Drupal::service('plugin.manager.block');
@rovo79
rovo79 / Base64FileManagerService.php
Created September 20, 2022 17:54 — forked from philipnorton42/Base64FileManagerService.php
A Drupal service class that can extract base64 encoded files from HTML content.
<?php
namespace Drupal\mymodule;
use Drupal\Core\File\Exception\FileNotExistsException;
use Drupal\Core\File\FileSystemInterface;
use Drupal\file\FileRepositoryInterface;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\Core\Logger\LoggerChannelInterface;
Notice: Undefined offset: 1 in Drupal\search_api_solr_devel\Logging\SolariumRequestLogger->preExecuteRequest() (line 66 of /srv/bindings/dde01fcca81240a6be41faa7e83cbefb/code/modules/contrib/search_api_solr/search_api_solr_devel/src/Logging/SolariumRequestLogger.php) #0 /srv/bindings/dde01fcca81240a6be41faa7e83cbefb/code/core/includes/bootstrap.inc(582): _drupal_error_handler_real(8, 'Undefined offse...', '/srv/bindings/d...', 66, Array) #1 /srv/bindings/dde01fcca81240a6be41faa7e83cbefb/code/modules/contrib/search_api_solr/search_api_solr_devel/src/Logging/SolariumRequestLogger.php(66): _drupal_error_handler(8, 'Undefined offse...', '/srv/bindings/d...', 66, Array) #2 [internal function]: Drupal\search_api_solr_devel\Logging\SolariumRequestLogger->preExecuteRequest(Object(Solarium\Core\Event\PreExecuteRequest), 'solarium.core.p...', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher)) #3 /srv/bindings/dde01fcca81240a6be41faa7e83cbefb/code/core/lib/Drupal/Component/EventDispatcher/ContainerA
/sbin/init: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=c394677bccc720a3bb4f4c42a48e008ff33e39b1, stripped