Spaces:
Runtime error
Runtime error
use latest diffusers
Browse files- requirements.txt +1 -1
- 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 |
-
|
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
|
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 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
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 =
|
|
|
|
|
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={
|
378 |
-
|
|
|
|
|
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 |
|