Skip to content

Instantly share code, notes, and snippets.

@IzumiSatoshi
IzumiSatoshi / fspbt_org.ipynb
Created October 31, 2022 09:34
FSPBT_org.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@IzumiSatoshi
IzumiSatoshi / video_frames_comparison.py
Created November 4, 2022 07:16
Output horizontally merged mp4 from two directories containing video frames.
# !!!IMPORTANT!!! The output must be encoded once, e.g. with a video editor, as it may contain errors that make it unplayable as it is.
import cv2
import glob
#### change here
left_frames_dir_path ="C:/Users/81809/Desktop/Projects/nicolai_fewshot/Few-Shot-Patch-Based-Training/logs/1_gen/res__P_disco1010/0020000"
right_frames_dir_path = "C:/Users/81809/Desktop/Projects/nicolai_fewshot/Few-Shot-Patch-Based-Training/logs/1_gen/input_filtered"
fps = 24
output_video_path = "woman_dance_greg2.mp4" #mp4 only
input_frames_height = 512
@IzumiSatoshi
IzumiSatoshi / main.md
Last active December 10, 2022 08:35
AtCoder 280にChatGPTで参加してみた。B問題の例。

問題ページ: https://atcoder.jp/contests/abc280/tasks/abc280_b

問題文を適切に整形して入力する。下付け文字を"_"で表すのと、例を入れるのが重要だったりする。  

Solve following AtCoder problem with python.   

Problem Statement
You are given an integer N and a sequence S=(S_1,…,S_N) of length N.

Find a sequence A=(A_1,…,A_N) of length N that satisfies the following condition for all k=1,…,N:

import matplotlib.pyplot as plt
def xy_plot(images, x_params, y_params, title, x_label, y_label):
height, width = len(y_params), len(x_params)
fig, axs = plt.subplots(height, width, constrained_layout=False)
fig.subplots_adjust(wspace=0, hspace=0)
n = 0
for idx_y in range(height):

code

unet = UNet2DConditionModel.from_pretrained("CompVis/stable-diffusion-v1-4", subfolder="unet")

print("unet down blocks num = ", len(unet.down_blocks))
for idx, down_block in enumerate(unet.down_blocks, 1):
  print('------', idx)
  print(down_block)

output

# Copyright 2022 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@IzumiSatoshi
IzumiSatoshi / main.py
Created January 28, 2023 16:37
diffusers形式のInstructPix2Pixを通常モデルとマージ
# 動作未確認
import torch
from diffusers import StableDiffusionInstructPix2PixPipeline, EulerAncestralDiscreteScheduler, StableDiffusionPipeline
import gc
# load models
ip2p_pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained("/content/drive/MyDrive/models/diffusers/ip2p", torch_dtype=torch.float16)
base_pipe = StableDiffusionPipeline.from_pretrained("/content/drive/MyDrive/models/diffusers/sd15_fp16", torch_dtype=torch.float16)
target_pipe = StableDiffusionPipeline.from_pretrained("/content/drive/MyDrive/models/diffusers/dedede_fp16", torch_dtype=torch.float16)
@IzumiSatoshi
IzumiSatoshi / chatgpt_on_blender.py
Last active March 26, 2023 03:25
ChatGPT on Blender
import sys
packages_path = (
"C:\\Users\\81809\\AppData\\Roaming\\Python\\Python310\\Scripts"
+ "\\..\\site-packages"
)
sys.path.insert(0, packages_path)
import openai
import threading
import subprocess
import openai
import re
from collections import defaultdict
import textwrap
import time
import shlex
openai.api_key = open("./openai_key.txt", "r").read().strip("\n")
import os
import openai
import threading
import time
import textwrap
import random
import re
import copy
import requests, simpleaudio, tempfile, json
import pyaudio