This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| filename = "output.txt" | |
| with open(filename, 'w') as fout: | |
| x = 0 | |
| for x in range(5): | |
| fout.write(""" def function_number{}(): \n | |
| """.format(x)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function addCompressor(el) { | |
| var AudioContext = window.AudioContext || window.webkitAudioContext; | |
| var context = new AudioContext(); | |
| var source = context.createMediaElementSource(el); | |
| var compressor = context.createDynamicsCompressor(); | |
| var makeupGain = context.createGain(); | |
| // Set compressor params here | |
| compressor.threshold.value = -40; | |
| compressor.knee.value = 40; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # PyTorch <=2.0 doesn't support bfloat16 F.interpolate natively. | |
| # so, we have to do things the old fashioned way. | |
| import torch | |
| import torch.nn as nn | |
| # functional implementation | |
| def nearest_neighbor_upsample(x: torch.Tensor, scale_factor: int): | |
| """Upsample {x} (NCHW) by scale factor {scale_factor} using nearest neighbor interpolation.""" | |
| s = scale_factor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| from pathlib import Path | |
| from safetensors.torch import load_file | |
| def summarize_tensor(x): | |
| if x is None: | |
| return "None" | |
| x = x.float() | |
| return f"({x.min().item():.3f}, {x.mean().item():.3f}, {x.max().item():.3f})" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ------------------------------------------------------------------ | |
| # EDIT: I eventually found a faster way to run SD on macOS, via MPSGraph (~0.8s / step on M1 Pro): | |
| # https://github.com/madebyollin/maple-diffusion | |
| # The original CoreML-related code & discussion is preserved below :) | |
| # ------------------------------------------------------------------ | |
| # you too can run stable diffusion on the apple silicon GPU (no ANE sadly) | |
| # | |
| # quick test portraits (each took 50 steps x 2s / step ~= 100s on my M1 Pro): | |
| # * https://i.imgur.com/5ywISvm.png |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import numpy as np | |
| import cv2 | |
| from scipy.signal import convolve2d | |
| from skimage import color, data, restoration | |
| import console | |
| # read input | |
| frame = cv2.imread("input.jpg").astype(np.float32) / 255.0 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import gradio as gr | |
| import numpy as np | |
| import random | |
| import torch | |
| from diffusers import ( | |
| StableDiffusion3Pipeline, | |
| SD3Transformer2DModel, | |
| FlowMatchEulerDiscreteScheduler, | |
| AutoencoderTiny, |
OlderNewer