radames commited on
Commit
4058d57
1 Parent(s): 3a90284

use latest diffusers

Browse files
Files changed (2) hide show
  1. requirements.txt +1 -1
  2. stablediffusion-infinity/app.py +13 -10
requirements.txt CHANGED
@@ -1,7 +1,7 @@
1
  --extra-index-url https://download.pytorch.org/whl/cu113
2
  torch
3
  huggingface_hub
4
- git+https://github.com/huggingface/diffusers.git@9f476388
5
  transformers
6
  scikit-image==0.19.3
7
  Pillow==9.2.0
 
1
  --extra-index-url https://download.pytorch.org/whl/cu113
2
  torch
3
  huggingface_hub
4
+ diffusers==0.9
5
  transformers
6
  scikit-image==0.19.3
7
  Pillow==9.2.0
stablediffusion-infinity/app.py CHANGED
@@ -13,7 +13,7 @@ from fastapi_utils.tasks import repeat_every
13
  import numpy as np
14
  import torch
15
  from torch import autocast
16
- from diffusers import StableDiffusionInpaintPipeline
17
  from diffusers.models import AutoencoderKL
18
 
19
  from PIL import Image
@@ -108,12 +108,11 @@ def sync_rooms_data_repo():
108
 
109
  def get_model():
110
  if "inpaint" not in model:
111
- vae = AutoencoderKL.from_pretrained(f"stabilityai/sd-vae-ft-ema")
112
- inpaint = StableDiffusionInpaintPipeline.from_pretrained(
113
- "radames/stable-diffusion-v2-inpainting",
114
- torch_dtype=torch.float16,
115
- vae=vae,
116
- ).to("cuda")
117
  model["inpaint"] = inpaint
118
 
119
  return model["inpaint"]
@@ -182,7 +181,9 @@ async def run_outpaint(
182
  guidance_scale=guidance,
183
  )
184
  image = output["images"][0]
185
- is_nsfw = output["nsfw_content_detected"][0]
 
 
186
  image_url = {}
187
 
188
  if not is_nsfw:
@@ -374,8 +375,10 @@ async def upload_file(image: Image.Image, prompt: str, room_id: str, image_key:
374
  filename = f"{date}-{id}-{image_key}-{prompt_slug}.webp"
375
  timelapse_name = f"{id}.webp"
376
  key_name = f"{room_id}/{filename}"
377
- s3.upload_fileobj(Fileobj=temp_file, Bucket=AWS_S3_BUCKET_NAME, Key=key_name, ExtraArgs={"ContentType": "image/webp", "CacheControl": "max-age=31536000"})
378
- s3.copy_object(Bucket=AWS_S3_BUCKET_NAME, CopySource=f"{AWS_S3_BUCKET_NAME}/{key_name}", Key=f"timelapse/{room_id}/{timelapse_name}")
 
 
379
 
380
  temp_file.close()
381
 
 
13
  import numpy as np
14
  import torch
15
  from torch import autocast
16
+ from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
17
  from diffusers.models import AutoencoderKL
18
 
19
  from PIL import Image
 
108
 
109
  def get_model():
110
  if "inpaint" not in model:
111
+ inpaint = DiffusionPipeline.from_pretrained(
112
+ "stabilityai/stable-diffusion-2-inpainting", torch_dtype=torch.float16, revision="fp16")
113
+ inpaint.scheduler = DPMSolverMultistepScheduler.from_config(
114
+ inpaint.scheduler.config)
115
+ inpaint = inpaint.to("cuda")
 
116
  model["inpaint"] = inpaint
117
 
118
  return model["inpaint"]
 
181
  guidance_scale=guidance,
182
  )
183
  image = output["images"][0]
184
+ is_nsfw = False
185
+ if "nsfw_content_detected" in output:
186
+ is_nsfw = output["nsfw_content_detected"][0]
187
  image_url = {}
188
 
189
  if not is_nsfw:
 
375
  filename = f"{date}-{id}-{image_key}-{prompt_slug}.webp"
376
  timelapse_name = f"{id}.webp"
377
  key_name = f"{room_id}/{filename}"
378
+ s3.upload_fileobj(Fileobj=temp_file, Bucket=AWS_S3_BUCKET_NAME, Key=key_name, ExtraArgs={
379
+ "ContentType": "image/webp", "CacheControl": "max-age=31536000"})
380
+ s3.copy_object(Bucket=AWS_S3_BUCKET_NAME,
381
+ CopySource=f"{AWS_S3_BUCKET_NAME}/{key_name}", Key=f"timelapse/{room_id}/{timelapse_name}")
382
 
383
  temp_file.close()
384