fffiloni commited on
Commit
108ebf6
1 Parent(s): 6f87c0d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -5,12 +5,13 @@ import torch
5
  import os
6
  from diffusers import DiffusionPipeline, DDIMScheduler
7
  MY_SECRET_TOKEN=os.environ.get('HF_TOKEN_SD')
 
8
  has_cuda = torch.cuda.is_available()
9
- device = 'cpu' if not has_cuda else 'cuda'
10
 
11
  pipe = DiffusionPipeline.from_pretrained(
12
  "CompVis/stable-diffusion-v1-4",
13
- safety_checker=None,
14
  use_auth_token=MY_SECRET_TOKEN,
15
  custom_pipeline="imagic_stable_diffusion",
16
  scheduler = DDIMScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", clip_sample=False, set_alpha_to_one=False)
@@ -19,6 +20,9 @@ pipe = DiffusionPipeline.from_pretrained(
19
  #generator = torch.Generator("cuda").manual_seed(0)
20
 
21
  def infer(prompt, init_image):
 
 
 
22
  res = pipe.train(
23
  prompt,
24
  init_image,
 
5
  import os
6
  from diffusers import DiffusionPipeline, DDIMScheduler
7
  MY_SECRET_TOKEN=os.environ.get('HF_TOKEN_SD')
8
+
9
  has_cuda = torch.cuda.is_available()
10
+ device = torch.device('cpu' if not has_cuda else 'cuda')
11
 
12
  pipe = DiffusionPipeline.from_pretrained(
13
  "CompVis/stable-diffusion-v1-4",
14
+ safety_checker=None,
15
  use_auth_token=MY_SECRET_TOKEN,
16
  custom_pipeline="imagic_stable_diffusion",
17
  scheduler = DDIMScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", clip_sample=False, set_alpha_to_one=False)
 
20
  #generator = torch.Generator("cuda").manual_seed(0)
21
 
22
  def infer(prompt, init_image):
23
+ init_image = Image.open(BytesIO(init_image)).convert("RGB")
24
+ init_image = init_image.resize((512, 512))
25
+
26
  res = pipe.train(
27
  prompt,
28
  init_image,