¥µ¥¤¥Ð¡¼¥°¥Î¡¼¥·¥¹ - colab¤Ç¹½ÃÛ


¹â®²½¤Î»î¹Ôºø¸í

Google Drive¤«¤é¥â¥Ç¥ë¥Ç¡¼¥¿¤òÆɤ߹þ¤à¡Ê´°Î»¡Ë
Installing gfpgan
Installing clip
Installing requirements for CodeFormer
Installing requirements for Web UI
Exiting because of --exit argument

¡Öxformers¡×¤ÏC
deepdanbooru

Installing requirements for Web UI
Launching Web UI with arguments: --share --gradio-debug --gradio-auth a:b
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
making attention of type 'vanilla' with 512 in_channels
Working with z of shape (1, 4, 32, 32) = 4096 dimensions.
making attention of type 'vanilla' with 512 in_channels
Loading weights [1d4a34af] from /content/drive/MyDrive/SD-WEBUI/models/Stable-diffusion/animefull.ckpt
Applying cross attention optimization (Doggettx).
Model loaded.
Loaded a total of 1 textual inversion embeddings.
Embeddings: fischl

Web UI¤ËɬÍפÊÍ×·ï¤Î¥¤¥ó¥¹¥È¡¼¥ë
°ú¿ô¤ò»ØÄꤷ¤ÆWeb UI¤òµ¯Æ°¤¹¤ë --share --gradio-debug --gradio-auth a:b¤ò»ØÄꤹ¤ë¡£
LatentDiffusion¡£eps-prediction¥â¡¼¥É¤Ç¼Â¹ÔÃæ
DiffusionWrapper¤Î¥Ñ¥é¥á¡¼¥¿¤Ï859.52M¤Ç¤¹¡£
512 in_channels¤Ç'vanilla'¥¿¥¤¥×¤ÎÃí°Õ¤òºî¤ë¡£
·Á¾õ(1, 4, 32, 32) = 4096¼¡¸µ¤Îz¤Çºî¶È¤¹¤ë¡£
512¸Ä¤Î¥Á¥ã¥ó¥Í¥ë¤ò»ý¤Ä'vanilla'¥¿¥¤¥×¤Î¥¢¥Æ¥ó¥·¥ç¥ó¤òºîÀ®¤¹¤ë¡£
/content/drive/MyDrive/SD-WEBUI/models/Stable-diffusion/animefull.ckpt ¤«¤é¥¦¥§¥¤¥È [1d4a34af] ¤ò¥í¡¼¥É¤·¤Æ¤¤¤Þ¤¹
¥¯¥í¥¹¥¢¥Æ¥ó¥·¥ç¥óºÇŬ²½¤ÎŬÍÑ¡ÊDoggettx¡Ë¡£
¥â¥Ç¥ë¤ò¥í¡¼¥É¡£
¥Æ¥­¥¹¥Èȿž¤ÎËä¤á¹þ¤ß¤ò¹ç·×1¸Ä¥í¡¼¥É¡£
¥¨¥ó¥Ù¥Ã¥Ç¥£¥ó¥°: fischl
  • ºÆµ¯Æ°¤Î¾ì¹ç¡Ê1ʬ¡Ë
Installing requirements for Web UI
Launching Web UI with arguments: --share --gradio-debug --gradio-auth a:b
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
making attention of type 'vanilla' with 512 in_channels
Working with z of shape (1, 4, 32, 32) = 4096 dimensions.
making attention of type 'vanilla' with 512 in_channels
Loading weights [1d4a34af] from /content/drive/MyDrive/SD-WEBUI/models/Stable-diffusion/animefull.ckpt
Applying cross attention optimization (Doggettx).
Model loaded.

Web UI¤ËɬÍפÊÍ×·ï¤Î¥¤¥ó¥¹¥È¡¼¥ë
°ú¿ô¤ò»ØÄꤷ¤ÆWeb UI¤òµ¯Æ°¤¹¤ë --share --gradio-debug --gradio-auth a:b¤ò»ØÄꤹ¤ë¡£
LatentDiffusion¡£eps-prediction¥â¡¼¥É¤Ç¼Â¹ÔÃæ
DiffusionWrapper¤Î¥Ñ¥é¥á¡¼¥¿¤Ï859.52M¤Ç¤¹¡£
512 in_channels¤Ç'vanilla'¥¿¥¤¥×¤ÎÃí°Õ¤òºî¤ë¡£
·Á¾õ(1, 4, 32, 32) = 4096¼¡¸µ¤Îz¤Çºî¶È¤¹¤ë¡£
512¸Ä¤Î¥Á¥ã¥ó¥Í¥ë¤ò»ý¤Ä'vanilla'¥¿¥¤¥×¤Î¥¢¥Æ¥ó¥·¥ç¥ó¤òºîÀ®¤¹¤ë¡£
/content/drive/MyDrive/SD-WEBUI/models/Stable-diffusion/animefull.ckpt ¤«¤é¥¦¥§¥¤¥È [1d4a34af] ¤ò¥í¡¼¥É¤¹¤ë¡£
¸òº¹ÃíÌܺÇŬ²½(Doggettx)¤òŬÍѤ¹¤ë¡£
¥â¥Ç¥ë¤ò¥í¡¼¥É¡£
¥Æ¥­¥¹¥Èȿž¤Î¥¨¥ó¥Ù¥Ã¥Ç¥£¥ó¥°¤ò¹ç·×1¸Ä¥í¡¼¥É¡£
¥¨¥ó¥Ù¥Ã¥Ç¥£¥ó¥°: fischl
Loaded a total of 1 textual inversion embeddings.
Embeddings: fischl

Colab+Drive¤ÇSD-WebUI¤ò¹½ÃÛ¤¹¤ë

¥³¥Þ¥ó¥É¥é¥¤¥ó°ú¿ô¤ÎÀßÄê

»²¹Í¡§¥³¥Þ¥ó¥É ¥é¥¤¥ó¤Î°ú¿ô¤ÈÀßÄê
arg = "--share --gradio-debug --gradio-auth "+idpass
!COMMANDLINE_ARGS="$arg"
  • ¡Ö--share¡×¡×share¥ª¥×¥·¥ç¥ó¤ò»ÈÍѤ·¤Æ¥ª¥ó¥é¥¤¥ó¤Ç¼Â¹Ô¤·¤Þ¤¹¡×
  • ¡Ö--debug¡× debug¥ª¥×¥·¥ç¥ó¤ò»ØÄꤷ¤Æ¥°¥é¥Ç¥£¥ª¤òµ¯Æ°
  • [--gradio-auth]¡Öusername:password¡×¤Î¤è¤¦¤Ë¥°¥é¥Ç¡¼¥·¥ç¥óǧ¾Ú¤òÀßÄꤷ¤Þ¤¹¡£¤Þ¤¿¤Ï¡Öu1:p1,u2:p2,u3:p3¡×¤Î¤è¤¦¤Ë¥«¥ó¥Þ¶èÀÚ¤ê¤ÇÊ£¿ô»ØÄê
°Ê²¼¤ÎÍѤ˥³¥Þ¥ó¥É¥é¥¤¥ó¤Î°ú¿ô¤òÊѹ¹¤¹¤ë
arg = "--xformers --deepdanbooru --share --gradio-debug --gradio-auth "+idpass

Google Drive¤Ë´Ä¶­¹½ÃÛ

  • °Ê²¼¤Îºî¶È¤Ë¤ª¤±¤ë¥¤¥ó¥¹¥È¡¼¥ëÀè¤Î¥Õ¥©¥ë¥À̾¤Ï¡ÖSD-WEBUI¡×¤È¤¹¤ë
  • ¥«¥ì¥ó¥È¥Ç¥£¥ì¥¯¥È¥ê·Ï¤¬¤¦¤Þ¤¯¤¤¤«¤Ê¤¤¾ì¹ç¡¢GUI¤Î¥¢¥¤¥³¥ó¤Ç¤â¤¦°ìÅ٥ɥ饤¥Ö¤Ë¤Ä¤Ê¤®Ä¾¤¹¡©

1.Àܳ¡õGPU¥Á¥§¥Ã¥¯
!nvidia-smi

2.OSºÆµ¯Æ°¡£¥¯¥é¥Ã¥·¥å¤È¤«½Ð¤ë¤±¤Éµ¤¤Ë¤»¤º¼¡¤Ø
  • ÊÂÎó½èÍý¤ò´Þ¤à¥×¥í¥°¥é¥à¤ò¶¯À©½ªÎ»¤µ¤»¤ë¡©
import os
os.kill(os.getpid(), 9)

3.Google Drive¤ò¥Þ¥¦¥ó¥È¤¹¤ë
from google.colab import drive
drive.mount('/content/gdrive')

4.WebUI¤ÎGit¤ò¥¯¥í¡¼¥ó
  • Git Clone¤¹¤ë¥ê¥ó¥¯¤Ë¡¢¼«Ê¬¤ÎGit¥¢¥«¥¦¥ó¥È¤òGit¥Ñ¥¹¥ï¡¼¥É¤ò´Þ¤á¤ë
  • ¥í¡¼¥«¥ë¥ê¥Ý¥¸¥È¥ë¤òºî¤ë¥Ç¥£¥ì¥¯¥È¥ê¤ÏGoogle Colab¤Ë¥Þ¥¦¥ó¥È¤·¤¿Google Drive¤ò»ØÄê
  • <>¤Ï´Þ¤Þ¤Ê¤¤
!git clone https://<¼«Ê¬¤ÎGit¥¢¥«¥¦¥ó¥È>:<Git¥Ñ¥¹¥ï¡¼¥É>@github.com/<Git¥¢¥«¥¦¥ó¥È>/<¥ê¥Ý¥¸¥È¥ê>.git "gdrive/My Drive/<¥í¡¼¥«¥ë¥ê¥Ý¥¸¥È¥ê¤òºî¤ë¥Ç¥£¥ì¥¯¥È¥ê>"

5.¥¯¥í¡¼¥ó¤·¤¿¥Õ¥©¥ë¥À¤Ë¥«¥ì¥ó¥È¥Ç¥£¥ì¥¯¥È¥ê¤¹¤ë
%cd /content/drive/My Drive/SD-WEBUI

6.½é´ü²½¤È³Æ¼ï¥é¥¤¥Ö¥é¥ê¥¤¥ó¥¹¥È¡¼¥ë
!COMMANDLINE_ARGS="--exit" REQS_FILE="requirements.txt" python launch.py

7.¤Þ¤¿OSºÆµ¯Æ°¡£¥¯¥é¥Ã¥·¥å¤È¤«½Ð¤ë¤±¤Éµ¤¤Ë¤»¤º¼¡¤Ø

8.Google Drive ¤ò¥Þ¥¦¥ó¥È¤·Ä¾¤¹¡©
import os
MOUNT_PATH = "/content/googledrive"

# ³Æ¼ï¥é¥¤¥Ö¥é¥ê¤ÎÇÛÃ֥ѥ¹
SD_PATH = "/content/"

# Stable Diffusion model config path
MODEL_CONFIG_PATH = os.path.join(SD_PATH, "stable-diffusion", "configs", "stable-diffusion", "v1-inference.yaml")

from google.colab import drive
drive.mount(MOUNT_PATH)

9.WebUI¤òºÇ¿·ÈǤ˹¹¿·
  • ¥«¥ì¥ó¥È¥Ç¥£¥ì¥¯¥È¥ê¤·¤ÆGit¥×¥ë
%cd /content/drive/My Drive/SD-WEBUI
!git pull

10.¡Ömodels¡×¥Õ¥©¥ë¥À¤ËǤ°Õ¤Î¡Ö¥â¥Ç¥ë.ckpt¡×¥Õ¥¡¥¤¥ë¤òÇÛÃÖ¤¹¤ë

11.¥»¥ë¤ò¼Â¹Ô¤·¡¢¡ÖRunning on public URL¡×¤ò³«¤¯

ºÆµ¯Æ°¤Î¾ì¹ç

1.Àܳ¡õGPU¥Á¥§¥Ã¥¯
2.OSºÆµ¯Æ°¡£¥¯¥é¥Ã¥·¥å¤È¤«½Ð¤ë¤±¤Éµ¤¤Ë¤»¤º¼¡¤Ø
3. Google Drive ¤ò¥Þ¥¦¥ó¥È
¡Ê4.WebUI¤òºÇ¿·ÈǤ˹¹¿·¤¹¤ë¡Ë
5. ¼Â¹Ô¡ª¡ÖRunning on public URL¡×¤ò³«¤¯

Colab¤ÇSD WebUI + NAI ¤òÆ°¤«¤¹

»²¹Í¡§¡Ú¹â®²½¡ÛStable Diffusion web UI : AUTOMATIC1111¤òGoogle colab¤ÇÊØÍø¤Ë»È¤¦
¥Ç¥Õ¥©¥ë¥È¤Îweb UI¤Î¥æ¡¼¥¶¡¼Ì¾¡§me¡¢¥Ñ¥¹¥ï¡¼¥É¡§qwerty
  • ɬÍפʥâ¥Ç¥ë¤ò¥À¥ó¥í¡¼¥É¤¹¤ë

Google Colab¤ÇStable Diffusion¤òÆ°¤«¤¹

°ìÈÖ¥·¥ó¥×¥ë¤Ê¥â¡¼¥É¤ÇGoogle colab¤Ë¤Ê¤ì¤ë

»²¹Í¡§¡Ú´Êñ¡¦ÌµÎÁ¡ÛGoogle colab¤ÇStable Diffusion / Waifu Diffusion¤ò»È¤¦ÊýË¡
  • £´¤Ä¤ÎPython¥×¥í¥°¥é¥à¤ò¥»¥ë¤Ë¥³¥Ô¥Ú¤·¤Æ¤¤¤¯

­¡Stable Diffusion¥Ñ¥Ã¥±¡¼¥¸¤ò¥¤¥ó¥¹¥È¡¼¥ë
# ­¡Stable Diffusion¥Ñ¥Ã¥±¡¼¥¸¤ò¥¤¥ó¥¹¥È¡¼¥ë
!pip install diffusers==0.3.0 transformers scipy ftfy
­¢Hugging Face¤Ø¤Î¥¢¥¯¥»¥¹¥È¡¼¥¯¥ó¤ò¥È¡¼¥¯¥óÊÑ¿ô¤Ë³ÊǼ
# ­¢Hugging Face¤Ø¤Î¥¢¥¯¥»¥¹¥È¡¼¥¯¥ó¤ò¥È¡¼¥¯¥óÊÑ¿ô¤Ë³ÊǼ
MyTOKEN="<HugginFace Hub¤Î¥µ¥¤¥È¤Ç¥³¥Ô¡¼¤·¤¿Access Token¤ò¤³¤³¤ËÆþ¤ì¤ë>"
­£StableDiffusion¥Ñ¥¤¥×¥é¥¤¥ó¤ò½àÈ÷¤¹¤ë
# ­£StableDiffusion¥Ñ¥¤¥×¥é¥¤¥ó¤ò½àÈ÷¤¹¤ë
from diffusers import StableDiffusionPipeline

pipe = StableDiffusionPipeline.from_pretrained(
    "CompVis/stable-diffusion-v1-4", 
    use_auth_token=MyTOKEN
).to("cuda")
­¤¥×¥í¥ó¥×¥È¤òÍ¿¤¨¤Æ²èÁü¤òÀ¸À®¤¹¤ë
# ­¤¥×¥í¥ó¥×¥È¤òÍ¿¤¨¤Æ²èÁü¤òÀ¸À®¤¹¤ë
from torch import autocast

prompt = "japanese girl"
with autocast("cuda"):
    images = pipe(prompt, guidance_scale=7.5).images
images[0].save("output.png")
¥â¥Ç¥ë¤òÀÚ¤êÂؤ¨¤ë¾ì¹ç
# ¥â¥Ç¥ë¡§Waifu Diffusion ¤ò»ÈÍѤ¹¤ë¾ì¹ç

pipe = StableDiffusionPipeline.from_pretrained(
    "hakurei/waifu-diffusion",                        # Êѹ¹²Õ½ê¤Ï¤³¤Î¹Ô¤Î¤ß
    use_auth_token=MyTOKEN
).to("cuda")
API¥ê¥Õ¥¡¥ì¥ó¥¹
¡ÖStableDiffusion¥Ñ¥¤¥×¥é¥¤¥ó¡×¤Îpipe¤Î¥Ñ¥é¥á¡¼¥¿¾Ò²ð

prompt (str or List[str]) : ¥×¥í¥ó¥×¥È
height (int, optional, defaults to 512) : À¸À®¤¹¤ë²èÁü¤Î¹â¤µ
width (int, optional, defaults to 512) : À¸À®¤¹¤ë²èÁü¤ÎÉý
num_inference_steps (int, optional, defaults to 50) : ¥Î¥¤¥º½üµî¤Î¥¹¥Æ¥Ã¥×¿ô
guidance_scale (float, optional, defaults to 7.5) : ¥×¥í¥ó¥×¥È¤Ë½¾¤¦Åٹ礤 (7¡Á11ÄøÅÙ)
eta (float, optional, defaults to 0.0) : eta (eta=0.0 ¤Ï·èÄêÏÀŪ¥µ¥ó¥×¥ê¥ó¥°)
generator (torch.Generator, optional) : Íð¿ô¥¸¥§¥Í¥ì¡¼¥¿
latents (torch.FloatTensor, optional) : »öÁ°¤ËÀ¸À®¤µ¤ì¤¿¥Î¥¤¥¸¡¼¤ÊÀøºßÊÑ¿ô
output_type (str, optional, defaults to "pil") : ½ÐÎϼïÊÌ
return_dict (bool, optional, defaults to True) : tuple¤ÎÂå¤ï¤ê¤ËStableDiffusionPipelineOutput¤òÊÖ¤¹¤«¤É¤¦¤«
Ìá¤êÃÍ : tuple or StableDiffusionPipelineOutput
StableDiffusionPipelineOutput¤Î¥×¥í¥Ñ¥Æ¥£

images (List[PIL.Image.Image] or np.ndarray) : Ťµbatch_size¤ÎPIL²èÁü¤Î¥ê¥¹¥È ¤Þ¤¿¤Ï shape(batch_size,height,width,num_channels)¤ÎnumpyÇÛÎó¡£
nsfw_content_detected (List[bool]) : À¸À®²èÁü¤¬NSFW(not-safe-for-work)¤«¤É¤¦¤«¤Î¥ê¥¹¥È¡£

Stable Diffusion web UI(AUTOMATIC1111ÈÇ)¤Î¾ì¹ç

»²¹Í¡§²èÁüÀ¸À®AI¡ÖStable Diffusion¡×¤ò4GB¤ÎGPU¤Ç¤âÆ°ºîOK¡õ¼«Ê¬¤Î³¨ÊÁ¤ò³Ø½¬¤µ¤»¤ë¤Ê¤É¤¤¤í¤¤¤í¤Êµ¡Ç½¤ò´Êñ¤ËGoogle Colabo¤äWindows¤ÇÆ°¤«¤»¤ë·èÄêÈÇ¡ÖStable Diffusion web UI(AUTOMATIC1111ÈÇ)¡×¥¤¥ó¥¹¥È¡¼¥ëÊýË¡¤Þ¤È¤á
  • Google Colab¤Î°Ê²¼¤Î¥Ú¡¼¥¸¤ËÈô¤Ö
  • £±¥»¥ë¤ò¼Â¹Ô»þ¡ÖÉÔÌÀ¤ÊÍýͳ¤Ë¤è¤ê¡¢¥»¥Ã¥·¥ç¥ó¤¬¥¯¥é¥Ã¥·¥å¤·¤Þ¤·¤¿¡£¡×¤Èɽ¼¨¤µ¤ì¤ë¤¬¡¢¤½¤Î¤Þ¤Þ¿Ê¤ó¤ÇÎɤ¤
¡Öimport sys¡×¤Ç¥¨¥é¡¼¤¬½Ð¤¿¾ì¹ç
  • ¡Ömodel.ckpt¡×¤Ë¤Ä¤¤¤Æ¤Ï¡¢ËÜÍè¤Î¾ì½ê¤Ç¤¢¤ë¡Ö/content/stable-diffusion-webui/repositories/stable-diffusion/models/ldm/stable-diffusion-v1/¡×¤Ë¸«Åö¤¿¤é¤Ê¤¤
  • ²èÌ̺¸Â¦¤Î¥á¥Ë¥å¡¼¤Ë¤¢¤ë¥Õ¥©¥ë¥À¥¢¥¤¥³¥ó¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¹½À®¤ò³Îǧ¤·¤¿¤È¤³¤í¡¢¡Öldm¡×¥Õ¥©¥ë¥ÀÆâ¤Ë¡Östable-diffusion-v1¡×¥Õ¥©¥ë¥À¤¬¤Ê¤¯¡¢¤½¤â¤½¤â¡Ömodel.ckpt¡×¥Õ¥¡¥¤¥ë¤¬¡Öcontent¡×ľ²¼¤ËÃÖ¤«¤ì¤Æ¤¤¤ë
  • ¼êÆ°¤ÇÅö³º¥Õ¥©¥ë¥À¤òºîÀ®¤·¤Æ¡Ömodel.ckpt¡×¥Õ¥¡¥¤¥ë¤ò°ÜÆ°¤¹¤ë¤È¥¤¥ó¥¹¥È¡¼¥ë¤Ï¿Ê¤à
  • £±¤«¤é3¤Î¥»¥ë¤ò¼Â¹Ô¤·¤Æ¤¤¤¯¡Ê£´¤Ï¹âÀºÅÙÈǤΥª¥×¥·¥ç¥ó¡Ë
  • ¡ÖINFO: Application startup complete.¡×¤Ç½Ð¤¨¤ì¤ÐÀ®¸ù
  • £³ÈÖ¤á¤Î¾åÉô¤Ë¤¢¤ë¡ÖINF | Your quick Tunnel has been created! Visit it at (it may take some time to be reachable): |¡×¤Î¿¿²¼¤Ë¤¢¤ëURL¤ò¿·¤·¤¤¥¿¥Ö¤Ç³«¤¯
  • ¥¢¥¹¥«¥Æ¥¹¥È¤ò¹Ô¤¤³Îǧ¤¹¤ë

NAI¤Î¾ì¹ç



»²¹Í¡§novelai-colab-ver
  • ¾åµ­ZIP¤Î¡Ö4chan_ver¡×¢ª¡ÖNovelAILeaks_API_Backend-EN.ipynb¡×¤òGoogle colab¤Ç³«¤¯

colab¤Î´ðËÜ»ö¹à¥á¥â

VRAM¥á¥â

  • cudaÂбþ
  • 12GB°Ê¾å
  • ¥°¥é¥Ü2ËçÁÞ¤·¡¡µ¡³£³Ø½¬¡¡CUDA
    • ¥½¥Õ¥È¡¢¥Þ¥¶¡¼¥Ü¡¼¥É¤¬Âбþ¤·¤Æ¤¤¤ë¤«¡©
    • SLI¡×µ»½Ñ¡©

¥·¥§¥ë¥³¥Þ¥ó¥É¤Î¼Â¹Ô

  • ÀèƬ¤Ë ! ¤ò¤Ä¤±¤ë¤È¥·¥§¥ë¥³¥Þ¥ó¥É¤ò¼Â¹Ô¤Ç¤­¤ë
!rembg --version

90ʬ¥ë¡¼¥ëÂкö

Chromium¥Ö¥é¥¦¥¶¤Î¥¢¥É¥ª¥ó¤òÆþ¤ì¤ë

³ä¤êÅö¤Æ¤é¤ì¤Æ¤¤¤ëGPU¤òÄ´¤Ù¤ë¥³¥Þ¥ó¥É

!nvidia-smi

12»þ´Ö¥ë¡¼¥ë¤Ç¥ê¥»¥Ã¥È¤µ¤ì¤ë¤Þ¤Ç¤Î»þ´Ö¤òÄ´¤Ù¤ë¥³¥Þ¥ó¥É

!cat /proc/uptime | awk '{printf("»Ä¤ê»þ´Ö : %.2f", 12-$1/60/60)}'

Google Colab¤ÎÀ©¸Â

  • RAM¡§12GB¡¡
  • ¥Ç¥£¥¹¥¯¡§CPU/TPC:ºÇÂç107GB¡¢GPU:ºÇÂç68GB
  • 90ʬ¥ë¡¼¥ë : ²¿¤âÁàºî¤»¤º¤Ë90ʬ·Ð¤Ä¤È¥ê¥»¥Ã¥È
  • 12»þ´Ö¥ë¡¼¥ë : ¥¤¥ó¥¹¥¿¥ó¥¹¤¬µ¯Æ°¤·¤Æ¤«¤é12»þ´Ö·Ð¤Ä¤È¥ê¥»¥Ã¥È
  • GPU¤Î»ÈÍÑÀ©¸Â : GPU¤ò»È¤¤¤¹¤®¤ë¤È¥ê¥»¥Ã¥È¡Ê¾å¸Â̤¸ø³«¡Ë

Google¥É¥é¥¤¥Ö¤Îºî¶È¥Õ¥©¥ë¥À¤ÎºîÀ®¤¹¤ë

¡Öwork¡×¤È¤¤¤¦Ì¾Á°¤Îºî¶È¥Õ¥©¥ë¥À¤òºîÀ®¤¹¤ë¥³¥Þ¥ó¥É
# ºî¶ÈÍÑ¥Õ¥©¥ë¥À¤ÎºîÀ®
from google.colab import drive 
drive.mount('/content/drive')
!mkdir -p '/content/drive/My Drive/work/'
%cd '/content/drive/My Drive/work/'

®ÅÙÈæ³Ó

  • ¥í¡¼¥«¥ë
Japanese girl
Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 1829698466, Size: 512x512, Model hash: 925997e9, Batch size: 3, Batch pos: 0, Clip skip: 2, ENSD: 31337
Time taken: 2m 15.55sTorch active/reserved: 3226/4230 MiB, Sys VRAM: 5546/6144 MiB (90.27%)
  • Google colab
Japanese girl
Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 1362447817, Size: 512x512, Model hash: 7460a6fa, Batch size: 3, Batch pos: 0
Time taken: 41.70sTorch active/reserved: 5349/6880 MiB, Sys VRAM: 7966/15110 MiB (52.72%)

colab¤Ç¤è¤¯»È¤¦Markdown

  • ¡Ö#@markdown¡×+¥Þ¡¼¥¯¥À¥¦¥óµ­Ë¡
¸«½Ð¤·¡Ê#¡Ë
  • 1¸Ä¤«¤é6¸Ä¥·¥ã¡¼¥×¤Ç¸«½Ð¤·¤òµ­½Ò¤¹¤ë¡£
  • ¢¨¥·¥ã¡¼¥×¤È¸«½Ð¤·Ê¸»ú¤Î´Ö¤Ë¤ÏȾ³Ñ¥¹¥Ú¡¼¥¹¤ò1¤ÄÆþ¤ì¤ë¤³¤È
²Õ¾ò½ñ¤­¥ê¥¹¥È(-)
¥Ï¥¤¥Õ¥ó¡¢¥×¥é¥¹¡¢¥¢¥¹¥¿¥ê¥¹¥¯¤Î¤¤¤º¤ì¤«¤Ç²Õ¾ò½ñ¤­¥ê¥¹¥È¤òµ­½Ò²Äǽ¡£
¢¨¥Ï¥¤¥Õ¥ó¡¢¥×¥é¥¹¡¢¥¢¥¹¥¿¥ê¥¹¥¯¤È²Õ¾ò½ñ¤­¤Î¹àÌܤδ֤ˤÏȾ³Ñ¥¹¥Ú¡¼¥¹¤ò1¤ÄÆþ¤ì¤ë¤³¤È

Drive ¤Ë pip install¡¡¤¹¤ë

  • Google Drive¤ò¥Þ¥¦¥ó¥È¤·¤¿¾å¤Ç¡¢!pip install --target ¥Ñ¥¹Ì¾ ¥â¥¸¥å¡¼¥ë̾¤È¤¹¤ë¤È»ØÄꤷ¤¿¥Õ¥©¥ë¥À¤Ë¥â¥¸¥å¡¼¥ë¤¬¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤ë
!pip install ¥Ñ¥¹Ì¾ ¥â¥¸¥å¡¼¥ë̾
!pip install --targe /content/drive/MyDrive/Colab\ Notebooks/my-modules/rembg rembg
  • Colab¤È Notebooks ¤Î´Ö¤Ë space ¤¬Æþ¤Ã¤Æ¤¤¤ë¤Î¤Ç¡¢\ (backslash)¤Ç¥¨¥¹¥±¡¼¥×¤·¤Æ¤ª¤«¤Ê¤¤¤È¥¨¥é¡¼¤Ë¤Ê¤ë

Google Drive¤ò¥Þ¥¦¥ó¥È¤¹¤ëÊýË¡

»²¹Í¡§Google Colab¤Çpython6 ¡Á Google Drive¾å¤Ø¤Î¥Ç¡¼¥¿Êݸ¡¦Æɤ߹þ¤ß
»²¹Í¡§Google Colaboratory¤ÇGoogle Drive¾å¤Î.py¥Õ¥¡¥¤¥ë¤ò¥¤¥ó¥Ý¡¼¥È

ÊýË¡¡§AGUI¤Ç


ÊýË¡B¡§¥³¥Þ¥ó¥É¤Ç
from google.colab import drive
drive.mount('/content/drive')
  • ¥Ý¥Ã¥×¥¢¥Ã¥×ÄÌÃΤòǧ¾Ú¤¹¤ë¤È¡ÖMounted at /content/drive¡×¤È½ÐÎϤµ¤ì¤ë

Æ°ºî³Îǧ

  • ls ¥³¥Þ¥ó¥É¤Ç³Îǧ¤¹¤ë¤È¼«Ê¬¤ÎGoogle Drive¤Î¥Õ¥¡¥¤¥ë¤¬¸«¤é¤ì¤ë
! ls "/content/drive/My Drive/Colab Notebooks"
! ls
  • £ã£ä¤Ç¡ÖColab Notebooks¡×¥Õ¥©¥ë¥À¤Þ¤Ç°ÜÆ°¤¹¤ë
%cd /content/drive/My Drive/Colab Notebooks
  • ¼ÂºÝ¤Ë¥Ç¡¼¥¿¤¬Êݸ¤Ç¤­¤ë¤«½ñ¤­¹þ¤ß¥Æ¥¹¥È¤ò¤¹¤ë
    • numpy¤Îsavetxt¤òÍѤ¤¤Æ°Ê²¼¤Î¥³¡¼¥É¤ò¼Â¹Ô¤¹¤ë
import numpy as np
data=np.arange(10)
np.savetxt('save_test.txt',data)

Ʊ¤¸¤¯Æɤ߹þ¤ß¥Æ¥¹¥È¤ò¹Ô¤¦
    • ¥Õ¥¡¥¤¥ë¤òÆɤ߹þ¤à¤Ë¤ÏÎ㤨¤Ðloadtxt()¤òÍѤ¤¤ë
rdata=np.loadtxt('save_test.txt')
rdata

ľÀܥѥ¹»ØÄꤹ¤ë¾ì¹ç
import numpy as np
data=np.arange(10)
path="/content/drive/My Drive/Colab Notebooks/my-modules/rembg"
np.savetxt(path+'/save_test2.txt',data)

Google Drive¤Ë¥Ñ¥¹¤òÄ̤¹

  • Google Drive¾å¤Î¸«¤«¤±¤È¼ÂºÝ¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Î¹½Â¤¤¬°ã¤¦¤Î¤Ç¡¢¸«¤«¤±¾å¤Ç¥Õ¥¡¥¤¥ë¤¬Àµ¤·¤¯ÇÛÃÖ¤µ¤ì¤Æ¤¤¤Æ¤â¥Ñ¥¹¤òÄ̤µ¤Ê¤¤¤È¥¤¥ó¥Ý¡¼¥È½ÐÍè¤Ê¤¤
  • ¥Î¡¼¥È¥Ö¥Ã¥¯¤ò³«¤¤¤¿¸å¤ËGoogle Drive¾å¤Ç¥Õ¥¡¥¤¥ë¤òÄɲᦰÜÆ°¤·¤¿¤ê¡¢¥Õ¥¡¥¤¥ë¤ÎÆâÍƤòÊѹ¹¤·¤Æ¤â¤¹¤°¤Ë¤Ïǧ¼±¤µ¤ì¤Ê¤¤
  • ¥â¥¸¥å¡¼¥ë¤ÎÆâÍƤò½ñ¤­´¹¤¨¤¿¾ì¹ç¡¢ÌÀ¼¨Åª¤Ë¥ê¥í¡¼¥É¤¹¤ëɬÍפ¬¤¢¤ë
  • »þ´Ö¤¬·Ð²á¤·¤Æ½é´ü²½¾õÂ֤Ǥϡ¢Google Drive¤Î¥Þ¥¦¥ó¥È¤È¥Ñ¥¹¤òÄ̤¹¥³¡¼¥É¤ò¼Â¹Ô¤¹¤ëɬÍפ¬¤¢¤ë¤¬¡¢pip¤Ë´Ø¤·¤Æ¤Ï¼Â¹Ô¤·¤Ê¤¯¤Æ¤â¥â¥¸¥å¡¼¥ë¤¬import¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë

sys.path.append()¤Ç¥Ñ¥¹¤òÄ̤¹¡Ê¤³¤Ã¤Á¤Î¤Û¤¦¤¬¤¤¤¤¡©¡Ë
import sys
sys.path.append('/content/drive/My Drive/Colab Notebooks/my-modules/³Æ¡¹¤Î¥×¥í¥¸¥§¥¯¥È')

import module1
module1.hello()
Ëô¤Ï
import os, sys
nb_path = '/content/notebooks'
os.symlink('/content/drive/My Drive/Colab Notebooks/my-modules', nb_path)
sys.path.insert(0,nb_path)

import¥¨¥é¡¼¤Î²ò¾Ã

A;¥â¥¸¥å¡¼¥ë¤ÎÆâÍƤò½ñ¤­´¹¤¨¤¿¾ì¹ç¡¢ÌÀ¼¨Åª¤Ë¥ê¥í¡¼¥É¤¹¤ë
import importlib
importlib.reload(module1)
B¡§°ìÅÙ [Restart] > [Restart rumtime] ¤Ç¥é¥ó¥¿¥¤¥à¤òºÆµ¯Æ°