Matthew Trentacoste commited on
Commit
1dc5359
1 Parent(s): baf1f3b

Updating to LambdaLabs v2.0 model and associated pre-processing

Browse files
Files changed (2) hide show
  1. app.py +17 -1
  2. requirements.txt +3 -2
app.py CHANGED
@@ -1,6 +1,8 @@
1
  import gradio as gr
2
  import torch
3
  from PIL import Image
 
 
4
 
5
  from diffusers import StableDiffusionImageVariationEmbedsPipeline
6
 
@@ -17,13 +19,26 @@ def main(
17
 
18
  generator = torch.Generator(device=device).manual_seed(int(seed))
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  if len(base_prompt) == 0:
21
  base_prompt = None
22
  if len(edit_prompt) == 0:
23
  edit_prompt = None
24
 
25
  images_list = pipe(
26
- n_samples*[input_im],
27
  base_prompt=base_prompt,
28
  edit_prompt=edit_prompt,
29
  edit_prompt_weight=edit_prompt_weight,
@@ -67,6 +82,7 @@ Training was done on 4xA6000 GPUs on [Lambda GPU Cloud](https://lambdalabs.com/s
67
  device = "cuda" if torch.cuda.is_available() else "cpu"
68
  pipe = StableDiffusionImageVariationEmbedsPipeline.from_pretrained(
69
  "matttrent/sd-image-variations-diffusers",
 
70
  )
71
  pipe = pipe.to(device)
72
 
 
1
  import gradio as gr
2
  import torch
3
  from PIL import Image
4
+ from torchvision import transforms
5
+
6
 
7
  from diffusers import StableDiffusionImageVariationEmbedsPipeline
8
 
 
19
 
20
  generator = torch.Generator(device=device).manual_seed(int(seed))
21
 
22
+ tform = transforms.Compose([
23
+ transforms.ToTensor(),
24
+ transforms.Resize(
25
+ (224, 224),
26
+ interpolation=transforms.InterpolationMode.BICUBIC,
27
+ antialias=False,
28
+ ),
29
+ transforms.Normalize(
30
+ [0.48145466, 0.4578275, 0.40821073],
31
+ [0.26862954, 0.26130258, 0.27577711]),
32
+ ])
33
+ inp = tform(input_im).to(device)
34
+
35
  if len(base_prompt) == 0:
36
  base_prompt = None
37
  if len(edit_prompt) == 0:
38
  edit_prompt = None
39
 
40
  images_list = pipe(
41
+ inp.tile(n_samples, 1, 1, 1),
42
  base_prompt=base_prompt,
43
  edit_prompt=edit_prompt,
44
  edit_prompt_weight=edit_prompt_weight,
 
82
  device = "cuda" if torch.cuda.is_available() else "cpu"
83
  pipe = StableDiffusionImageVariationEmbedsPipeline.from_pretrained(
84
  "matttrent/sd-image-variations-diffusers",
85
+ # "/Users/mtrent/Code/stable-diffusion/sd-image-variations-diffusers",
86
  )
87
  pipe = pipe.to(device)
88
 
requirements.txt CHANGED
@@ -1,5 +1,6 @@
1
  git+https://github.com/matttrent/diffusers.git#egg=diffusers
2
- --extra-index-url https://download.pytorch.org/whl/cu113
3
- torch
4
  transformers
5
  accelerate
 
 
 
 
1
  git+https://github.com/matttrent/diffusers.git#egg=diffusers
 
 
2
  transformers
3
  accelerate
4
+ --extra-index-url https://download.pytorch.org/whl/cu113
5
+ torch
6
+ torchvision