Skip to content

Instantly share code, notes, and snippets.

@safa-dayo
safa-dayo / google-images-downloader.py
Last active October 10, 2020 23:34
Scrape Google images
# ■こちらのYouTube動画で作成したコードです
# https://www.youtube.com/watch?v=qBQ7MNPDq7I
#
# ■下記のコードを写経しながら、スクレイピングについて学習した際のコードとなります
# https://gist.github.com/genekogan/ebd77196e4bf0705db51f86431099e57#gistcomment-3465381
#
# コードの実行には下記のインストールが必要です
# Selenium, chromedriver-binary
from selenium import webdriver
import json
import requests
from datetime import datetime, timedelta
import time
WP_URL = "<WordPressのURL>"
WP_USER = "<投稿ユーザのユーザ名>"
WP_PASS = "<WP REST APIで設定されたパスワード>"
for i in range(5):
@safa-dayo
safa-dayo / chatgpt-api-conversation-cli-app-sample.js
Created March 3, 2023 13:14
A CLI application for conducting conversations using the ChatGPT API.
const readline = require('readline');
const { Configuration, OpenAIApi } = require('openai');
(async () => {
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const rl = readline.createInterface({
@safa-dayo
safa-dayo / chatgpt-api-sample-with-nextjs.tsx
Created March 7, 2023 12:22
YouTube動画『ChatGPT APIを使ってWeb上でチャットできるようにしよう! (Next.js利用)』で作成したソースコードとなります。
import { ChangeEvent, useRef, useState } from 'react';
import Head from 'next/head'
import styles from '@/styles/Home.module.css'
// ChatGPT APIとのやり取りに利用
const messages: Array<any> = [];
export default function Home() {
// 入力用
const [inputValue, setInputValue] = useState('');
@safa-dayo
safa-dayo / start-sdwebui-v1.1.1-with-chilled_remix.sh
Last active May 23, 2023 12:59
Stable Diffusion web UIのv1.1.1をGoogle Colabで起動するためのコマンドです。chilled_remixが利用できるように、起動時にモデルファイルをダウンロードします。
# Stable Diffusion web UIのリポジトリをクローンして、クローンしたフォルダに移動
!git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
%cd /content/stable-diffusion-webui
# v1.1.1を利用する
!git checkout tags/v1.1.1
# pytorch関連のライブラリをv1.1.1向けにバージョンを固定してインストール
!pip3 install torchvision==0.15.1 torch==2.0.0 torchtext==0.15.1 torchdata==0.6.0 torchaudio==2.0.1
@safa-dayo
safa-dayo / setup-sdwebui-controlnet-1.1.sh
Last active May 11, 2023 21:55
ControlNet 1.1の環境をGoogle Colab上で構築するためのスクリプト
# ControlNetをインストールした状態でweb UIを実行すると"ERROR: Failed building wheel for pycairo"というエラーが出るため、以下のコマンドをまずは実施
!apt -y install -qq aria2 libcairo2-dev pkg-config python3-dev
# ControlNet 1.1のダウンロード
!git clone https://github.com/Mikubill/sd-webui-controlnet /content/stable-diffusion-webui/extensions/sd-webui-controlnet
# modelファイルのダウンロード
!curl -Lo /content/stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_v11e_sd15_ip2p.pth https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11e_sd15_ip2p.pth
!curl -Lo /content/stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_v11e_sd15_shuffle.pth https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11e_sd15_shuffle.pth
!curl -Lo /content/stable-diffusion-webui/extensions/sd-webui-controlnet/models/control_v11f1e_sd15_tile.pth https://huggingface.co/lllyasviel/ControlNet-v1-1/resolve/main/control_v11f1e_sd15_tile.pth
@safa-dayo
safa-dayo / easynegative-and-lora-download-at-google-colab.sh
Created May 9, 2023 22:32
EasyNegativeとLoRAダウンロード用コマンド(Google Colab前提)
# EasyNegativeのダウンロード
!wget https://huggingface.co/datasets/gsdf/EasyNegative/resolve/main/EasyNegative.safetensors --directory-prefix=/content/stable-diffusion-webui/embeddings/
# LoRAのダウンロード(注意:ダウンロード先がCivitai前提のコードになっています)
!wget {ここにダウンロードしたいLoRAのダウンロードURLを入れてください} --content-disposition --directory-prefix=/content/stable-diffusion-webui/models/Lora/
@safa-dayo
safa-dayo / easynegative-download-at-google-colab.sh
Created May 10, 2023 22:11
EasyNegativeダウンロード用コマンド(Google Colab前提)
# EasyNegativeのダウンロード
!wget https://huggingface.co/datasets/gsdf/EasyNegative/resolve/main/EasyNegative.safetensors --directory-prefix=/content/stable-diffusion-webui/embeddings/
@safa-dayo
safa-dayo / lora-download-at-google-colab.sh
Created May 10, 2023 22:14
LoRAダウンロード用コマンド(Google Colab前提)
# LoRAのダウンロード(ダウンロード先:Hugging Face)
!wget {ここにダウンロードしたいLoRAのダウンロードURLを入れてください} --directory-prefix=/content/stable-diffusion-webui/models/Lora/
# LoRAのダウンロード(ダウンロード先:Civitai)
!wget {ここにダウンロードしたいLoRAのダウンロードURLを入れてください} --content-disposition --directory-prefix=/content/stable-diffusion-webui/models/Lora/
@safa-dayo
safa-dayo / model-download-at-google-colab.sh
Created May 10, 2023 22:18
モデルファイルダウンロード用コマンド(Google Colab前提)
# モデルファイルのダウンロード(ダウンロード先:Hugging Face)
!wget {ここにダウンロードしたいモデルのダウンロードURLを入れてください} --directory-prefix=/content/stable-diffusion-webui/models/Stable-diffusion/
# モデルファイルのダウンロード(ダウンロード先:Civitai)
!wget {ここにダウンロードしたいモデルのダウンロードURLを入れてください} --content-disposition --directory-prefix=/content/stable-diffusion-webui/models/Stable-diffusion/