Skip to content

Instantly share code, notes, and snippets.

import os
import time
import sys
import numpy as np
import pyaudio
import threading
import queue
import openai
【System】
## problem
テキストベースの人狼ゲームに参加しているプレイヤーとして振舞ってください。
あなたのプレイヤー名はラマです。
ゲーム進行を務めるのはGM(Game Master)です。
プレイヤーは全部で6人で、内訳は['村人', '狂人', '占い師', '騎士', '村人', '人狼']です。
各プレイヤーが順番に発言していき2周回ると投票に移ります。
以下は各役職の説明です。
import os
import openai
import threading
import time
import textwrap
import random
import re
import copy
import requests, simpleaudio, tempfile, json
import pyaudio
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")
@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
@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)
# 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,

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

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):
@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: