Skip to content

Instantly share code, notes, and snippets.

@recoilme
recoilme / joy-caption-pre-alpha.py
Created August 15, 2024 13:06
joy-caption-pre-alpha
#import spaces
#import gradio as gr
from huggingface_hub import InferenceClient
from torch import nn
from transformers import AutoModel, AutoProcessor, AutoTokenizer, PreTrainedTokenizer, PreTrainedTokenizerFast, AutoModelForCausalLM
from pathlib import Path
import torch
import torch.amp.autocast_mode
from PIL import Image
import os, time
from diffusers import StableDiffusionXLPipeline
from sd_embed.embedding_funcs import get_weighted_text_embeddings_sdxl
from sd_embed.embedding_funcs import get_weighted_text_embeddings_sdxl_2p
from sd_embed.embedding_funcs import group_tokens_and_weights
from sd_embed.prompt_parser import parse_prompt_attention
from diffusers import DiffusionPipeline,EulerAncestralDiscreteScheduler
from transformers import CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer
from diffusers.utils import make_image_grid
import torch, gc
azureuser@aiartlab-1:~$ python3 -m pip freeze
absl-py==2.1.0
accelerate==0.25.0
aiohttp==3.9.5
aiosignal==1.3.1
altair==4.2.2
async-timeout==4.0.3
attrs==21.2.0
Automat==20.2.0
Babel==2.8.0
from diffusers import DiffusionPipeline,EulerAncestralDiscreteScheduler
from transformers import CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer
import torch
MODEL_PATH = "models/colorfulxl"
pipe = DiffusionPipeline.from_pretrained(
MODEL_PATH,
text_encoder=None, tokenizer=None,
text_encoder_2=None, tokenizer_2=None,
torch_dtype=torch.float16,
from diffusers import StableDiffusionXLPipeline
from sd_embed.embedding_funcs import get_weighted_text_embeddings_sdxl
from sd_embed.embedding_funcs import get_weighted_text_embeddings_sdxl_2p
from sd_embed.prompt_parser import parse_prompt_attention
from diffusers import DiffusionPipeline,EulerAncestralDiscreteScheduler
from transformers import CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer
from diffusers.utils import make_image_grid
import torch
MODEL_PATH = "models/colorfulxl"
from diffusers import DiffusionPipeline,EulerAncestralDiscreteScheduler
from transformers import CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer
import torch
MODEL_PATH = "models/colorfulxl"
pipe = DiffusionPipeline.from_pretrained(
MODEL_PATH,
text_encoder=None, tokenizer=None,
text_encoder_2=None, tokenizer_2=None,
torch_dtype=torch.float16,
@recoilme
recoilme / mp32mp4.ipynb
Last active March 11, 2024 10:10
Convert audio to movement
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@recoilme
recoilme / dataset.json
Created January 30, 2024 17:45
Example train GPT2 for prompts generation
[{"prompt":"An ancient man is riding in a carriage along a mountain road.","txt":"Venerable man journeys in ancient mountains. Carriage creaks, revealing deep wisdom. Twilight paints dreamlike tableau.","_id":"65b7ba0cfb9aff6d419a368e"},
{"prompt":"Great Wall of China","txt":"Ancient wall, setting sun, breathtaking beauty.","_id":"65b7b89ffb9aff6d419a3688"},
{"prompt":"A resident of the mountains is riding in a carriage along a rocky road","txt":"Mountaineer finds solace in antique carriage, rugged path of rocks, rustic charm, creaking wheels, calm resolve, beautiful mountains, untamed road, orange sunset, approaching night.","_id":"65b7b71ffb9aff6d419a3684"},
{"prompt":"A person in primitive clothing traveling on Earth. Their hands hold simple tools reflecting their primitive wisdom. They stand under a breathtaking sunset, painting the sky in beautiful shades. Mountains in the background and a winding river complete the lush landscape. Ancient creatures can be seen in the distance, seemingly unaware of these
@recoilme
recoilme / SSD-1B.ipynb
Last active October 26, 2023 20:11
SSD-1B 1st look
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@recoilme
recoilme / videomaskbyface.py
Last active October 6, 2023 15:00
videomaskbyface.py
import cv2
import os
import time
import mediapipe as mp
import numpy as np
def extract_faces(image):
center_faces = []
BaseOptions = mp.tasks.BaseOptions
FaceDetector = mp.tasks.vision.FaceDetector