Skip to content

Instantly share code, notes, and snippets.

@nousr
nousr / DiM.py
Last active December 8, 2023 17:37
""""
Proof of concept "DiM" - nousr
general structure was "transpiled" from DiT by meta
bi-direction idea comes from DifuSSM (https://arxiv.org/abs/2311.18257)
"""
import torch
import math
from timm.models.vision_transformer import PatchEmbed
@nousr
nousr / comfy.py
Created August 23, 2023 17:51
Comfy Deforum WIP
import websocket
import uuid
import json
import urllib.request
import urllib.parse
from random import randint
import click
from PIL import Image
import io
import os
@nousr
nousr / api.py
Created July 20, 2023 18:29
A simple LLAVA(R) api and query example
from flask import Flask, request, jsonify
import torch
import base64
import io
from PIL import Image
import requests
from io import BytesIO
# Import the necessary modules from the llava directory
from transformers import AutoTokenizer
@nousr
nousr / example_script.sh
Last active July 29, 2023 23:16
How to compute clip embeddings easily with clip-retrieval & slurm
#!/bin/bash
clip-retrieval inference \
--input_dataset="<parent folder containing images>" \
--output_folder="<output s3 bucket or local folder>" \
--input_format="files" \
--enable_metadata=False \
--write_batch_size=500 \
--num_prepro_workers=2 \
--batch_size=64 \
--enable_wandb=True \
from langchain.llms.base import LLM
from typing import Optional, List
from revChatGPT.V1 import Chatbot
class revChatGPT(LLM):
chatbot: Chatbot = Chatbot(config={
"access_token": "<your token here>"
})
import torch
import webdataset as wds
from typing import Union, Sequence
from time import perf_counter
from accelerate import Accelerator
def process(src):
"""
Filter empty samples from the clap dataset.
@lru_cache(maxsize=None)
def load_safety_model(clip_model):
"""load the safety model"""
import torch # pylint: disable=import-outside-toplevel
import autokeras as ak # pylint: disable=import-outside-toplevel
from tensorflow.keras.models import load_model # pylint: disable=import-outside-toplevel
class H14_NSFW_Detector(nn.Module):
def __init__(self, input_size=1024):
super().__init__()
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 4.
name,prompt,negative_prompt
None,,
MDJ_style_base,"an extremely realistic digital painting of a (futuristic an alleyway) street in the style of cyberpunk, a photograph of a cyberpunk street alley at sunset, digital art trending on artstation, ((pixel art)), light rays shining","blurry, bad resolution, low quality, watermarked image, america, jpeg artifacts, background, words, font, text, boring, robot, human, full body, people in a street, purple"
MDJ_street_car,"an extremely realistic digital painting of a (cyberpunk volkswagen r32) on the street in the style of cyberpunk, a photograph of a cyberpunk street alley at night, digital art trending on artstation, ((pixel art)), light rays shining","bad resolution, low quality, watermarked image, human, ((simple)), [dark], blurry, bad resolution, low quality, ((watermarked image)), america, jpeg artifacts, words, font, text, boring, robot, human, full body, people in a street stock photo AND alamy, shutterstock, pixabay, flickr AND picture frame, bad perspective,
@nousr
nousr / indexer.sh
Last active November 18, 2022 23:30
#!/bin/bash
# step 1: get environment variables
# step 2: setup rank 0 to be the master and start the indexing python file (the last two operations happen in parallel)
# step 3: setup rank 1-N to be the workers and start the worker script (they then will listen for work from the master)
# get environment variables
GLOBAL_RANK=$SLURM_PROCID
CPUS=$SLURM_CPUS_PER_TASK
MEM=$SLURM_MEM_PER_NODE # seems to be in MB
import wandb
import torch
from dalle2_pytorch import (
T5OpenClipAdapter,
DiffusionPriorNetwork,
DiffusionPrior,
)
from dalle2_pytorch.trainer import DiffusionPriorTrainer
from transformers import T5Tokenizer
from accelerate import Accelerator