Spaces:
Runtime error
Runtime error
Update app2.py
Browse files
app2.py
CHANGED
|
@@ -45,7 +45,22 @@ import torchvision.transforms.functional as TF
|
|
| 45 |
from torchvision.transforms import InterpolationMode
|
| 46 |
|
| 47 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 48 |
-
pipe = DepthNormalEstimationPipeline.from_pretrained(CHECKPOINT)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
try:
|
| 51 |
import xformers
|
|
@@ -61,7 +76,7 @@ def depth_normal(img,
|
|
| 61 |
denoising_steps,
|
| 62 |
ensemble_size,
|
| 63 |
processing_res,
|
| 64 |
-
guidance_scale,
|
| 65 |
domain):
|
| 66 |
|
| 67 |
#img = img.resize((processing_res, processing_res), Image.Resampling.LANCZOS)
|
|
@@ -71,7 +86,7 @@ def depth_normal(img,
|
|
| 71 |
ensemble_size=ensemble_size,
|
| 72 |
processing_res=processing_res,
|
| 73 |
batch_size=0,
|
| 74 |
-
guidance_scale=guidance_scale,
|
| 75 |
domain=domain,
|
| 76 |
show_progress_bar=True,
|
| 77 |
)
|
|
@@ -135,13 +150,13 @@ def run_demo():
|
|
| 135 |
label="Data Type (Must Select One matches your image)",
|
| 136 |
value="indoor",
|
| 137 |
)
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
)
|
| 145 |
denoising_steps = gr.Slider(
|
| 146 |
label="Number of denoising steps (More stepes, better quality)",
|
| 147 |
minimum=1,
|
|
@@ -178,7 +193,7 @@ def run_demo():
|
|
| 178 |
inputs=[input_image, denoising_steps,
|
| 179 |
ensemble_size,
|
| 180 |
processing_res,
|
| 181 |
-
guidance_scale,
|
| 182 |
domain],
|
| 183 |
outputs=[depth, normal]
|
| 184 |
)
|
|
|
|
| 45 |
from torchvision.transforms import InterpolationMode
|
| 46 |
|
| 47 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 48 |
+
#pipe = DepthNormalEstimationPipeline.from_pretrained(CHECKPOINT)
|
| 49 |
+
|
| 50 |
+
stable_diffusion_repo_path = '.'
|
| 51 |
+
vae = AutoencoderKL.from_pretrained(stable_diffusion_repo_path, subfolder='vae')
|
| 52 |
+
scheduler = DDIMScheduler.from_pretrained(stable_diffusion_repo_path, subfolder='scheduler')
|
| 53 |
+
sd_image_variations_diffusers_path = '.'
|
| 54 |
+
image_encoder = CLIPVisionModelWithProjection.from_pretrained(sd_image_variations_diffusers_path, subfolder="image_encoder")
|
| 55 |
+
feature_extractor = CLIPImageProcessor.from_pretrained(sd_image_variations_diffusers_path, subfolder="feature_extractor")
|
| 56 |
+
|
| 57 |
+
unet = UNet2DConditionModel.from_pretrained('tbd')
|
| 58 |
+
|
| 59 |
+
pipe = DepthNormalEstimationPipeline(vae=vae,
|
| 60 |
+
image_encoder=image_encoder,
|
| 61 |
+
feature_extractor=feature_extractor,
|
| 62 |
+
unet=unet,
|
| 63 |
+
scheduler=scheduler)
|
| 64 |
|
| 65 |
try:
|
| 66 |
import xformers
|
|
|
|
| 76 |
denoising_steps,
|
| 77 |
ensemble_size,
|
| 78 |
processing_res,
|
| 79 |
+
#guidance_scale,
|
| 80 |
domain):
|
| 81 |
|
| 82 |
#img = img.resize((processing_res, processing_res), Image.Resampling.LANCZOS)
|
|
|
|
| 86 |
ensemble_size=ensemble_size,
|
| 87 |
processing_res=processing_res,
|
| 88 |
batch_size=0,
|
| 89 |
+
#guidance_scale=guidance_scale,
|
| 90 |
domain=domain,
|
| 91 |
show_progress_bar=True,
|
| 92 |
)
|
|
|
|
| 150 |
label="Data Type (Must Select One matches your image)",
|
| 151 |
value="indoor",
|
| 152 |
)
|
| 153 |
+
# guidance_scale = gr.Slider(
|
| 154 |
+
# label="Classifier Free Guidance Scale",
|
| 155 |
+
# minimum=1,
|
| 156 |
+
# maximum=5,
|
| 157 |
+
# step=1,
|
| 158 |
+
# value=3,
|
| 159 |
+
# )
|
| 160 |
denoising_steps = gr.Slider(
|
| 161 |
label="Number of denoising steps (More stepes, better quality)",
|
| 162 |
minimum=1,
|
|
|
|
| 193 |
inputs=[input_image, denoising_steps,
|
| 194 |
ensemble_size,
|
| 195 |
processing_res,
|
| 196 |
+
#guidance_scale,
|
| 197 |
domain],
|
| 198 |
outputs=[depth, normal]
|
| 199 |
)
|