Skip to content

Commit

Permalink
DeepFloyd support library (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
bghira committed Apr 29, 2023
1 parent b6d24f6 commit 4beaa0f
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 42 deletions.
43 changes: 43 additions & 0 deletions discord_tron_client/classes/image_manipulation/deep_floyd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import os
import torch
os.environ['FORCE_MEM_EFFICIENT_ATTN'] = "1"
import sys
from deepfloyd_if.modules import IFStageI, IFStageII, StableStageIII
from deepfloyd_if.modules.t5 import T5Embedder
from deepfloyd_if.pipelines import dream, style_transfer, super_resolution, inpainting
import torch.nn.functional as F
import random
import torchvision.transforms as T
import numpy as np
import requests
from PIL import Image
import torch
import re
from huggingface_hub import login

login()
device = 'cuda:0'
if_I = IFStageI('IF-I-XL-v1.0', device=device)
if_II = IFStageII('IF-II-L-v1.0', device=device)
if_III = StableStageIII('stable-diffusion-x4-upscaler', device=device)
t5 = T5Embedder(device=device)
prompt = 'ultra close-up color photo portrait of rainbow owl with deer horns in the woods'

count = 4

result = dream(
t5=t5, if_I=if_I, if_II=if_II, if_III=if_III,
prompt=[prompt]*count,
seed=42,
if_I_kwargs={
"guidance_scale": 7.0,
"sample_timestep_respacing": "smart100",
},
if_II_kwargs={
"guidance_scale": 4.0,
"sample_timestep_respacing": "smart50",
},
)
if_I.show(result['I'], size=3)
if_I.show(result['II'], size=6)
if_I.show(result['III'], size=14)
50 changes: 9 additions & 41 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ accelerate = "^0.18.0"
numpy = ">=1.23.2"
torch = { version = ">=1.12.1", source="torch"}
torchaudio = { version = ">=0.12.1", source="torch"}
torchvision = { version = ">=0.13.1", source="torch"}
colorama = "^0.4.6"
xformers = "^0.0.18"
compel = "^1.1.3"
Expand Down

0 comments on commit 4beaa0f

Please sign in to comment.