Skip to content

Instantly share code, notes, and snippets.

@diegocr
diegocr / convert_diffusers_lora_to_sd_webui.py
Created August 25, 2023 14:51 — forked from eavae/convert_diffusers_lora_to_sd_webui.py
A script help you convert diffusers lora to sd webui format
from pathlib import Path
from diffusers import StableDiffusionXLPipeline
import torch
from safetensors.torch import save_file
# text_encoder.text_model.encoder.layers.0.self_attn.k_proj.lora_linear_layer.down.weight
# lora_te_text_model_encoder_layers_0_self_attn_k_proj.lora_down.weight
# 1. text_encoder -> lora_te, text_encoder_2 -> lora_te2
# 2. map
# 3. .weight -> 2 .alpha -> 1 and replace . -> _
@diegocr
diegocr / js-exif-rotate.html
Created August 9, 2017 22:43 — forked from runeb/js-exif-rotate.html
Auto-rotate images locally in the browser by parsing exif data
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<input id="file" type="file" accept="image/*" />
<br/>
<h2>As read:</h2>
<img id="placeholder1" width=300/><br/>
<h2>Rotated by exif data:</h2>
<img id="placeholder2" width=300/>
<script>
NOTE: the functions that are followed by an asterisk (*) are part of the 16-bit C Run-time only. Functions that are unique to the 32-bit C Run-time are listed separately in the last section. All other functions are common to both C Run-times.
Buffer Manipulation
_memccpy none
memchr none
memcmp none
memcpy CopyMemory
_memicmp none
memmove MoveMemory
memset FillMemory, ZeroMemory
/*
* Calculate, intelligently, the CRC of a dataset incrementally given a
* buffer full at a time.
* Initialize crc to 0 for XMODEM, -1 for CCITT.
*
* Usage:
* newcrc = updcrc( oldcrc, bufadr, buflen )
* unsigned int oldcrc, buflen;
* char *bufadr;
*
/* CRCTABLE 1.0 Public Domain by Celso Minnitti, Jr Feb-06-94 */
/* This program will generate the crc16_table and CRC32_table */
/* that are used by CMCRC.ASM */
#include <stdio.h>
#define CRC32_POLYNOMIAL 0xEDB88320
#define CRC16_POLYNOMIAL 0xA001
void main()
{