Spaces:
Configuration error
Configuration error
Commit
·
10da2a6
1
Parent(s):
d473aed
update
Browse files
app.py
CHANGED
@@ -60,6 +60,21 @@ refiner.scheduler = DPMSolverMultistepScheduler.from_config(base.scheduler.confi
|
|
60 |
|
61 |
|
62 |
# DepthAnything
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
@torch.no_grad()
|
64 |
def predict_depth(model, image):
|
65 |
return model(image)
|
@@ -87,7 +102,8 @@ def depthify(image):
|
|
87 |
|
88 |
# DifferentialDiffusion
|
89 |
|
90 |
-
def preprocess_image(
|
|
|
91 |
image = image.convert("RGB")
|
92 |
image = transforms.CenterCrop((image.size[1] // 64 * 64, image.size[0] // 64 * 64))(image)
|
93 |
image = transforms.ToTensor()(image)
|
@@ -137,7 +153,7 @@ def run(image, gs, prompt, neg_prompt):
|
|
137 |
# first run
|
138 |
[(original_image, colored_depth), name, raw_depth] = depthify(image)
|
139 |
print(f"original_image={original_image} colored_depth={colored_depth}, name={name}, raw_depth={raw_depth}")
|
140 |
-
return inference(original_image, raw_depth, gs, prompt, neg_prompt)
|
141 |
|
142 |
with gr.Blocks() as demo:
|
143 |
with gr.Row():
|
@@ -153,6 +169,7 @@ with gr.Blocks() as demo:
|
|
153 |
clr_btn=gr.ClearButton(components=[input_image, gs, prompt, neg_prompt])
|
154 |
run_btn = gr.Button("Run",variant="primary")
|
155 |
|
|
|
156 |
output = gr.Image(label="Output Image")
|
157 |
run_btn.click(
|
158 |
run,
|
|
|
60 |
|
61 |
|
62 |
# DepthAnything
|
63 |
+
|
64 |
+
transform = Compose([
|
65 |
+
Resize(
|
66 |
+
width=518,
|
67 |
+
height=518,
|
68 |
+
resize_target=False,
|
69 |
+
keep_aspect_ratio=True,
|
70 |
+
ensure_multiple_of=14,
|
71 |
+
resize_method='lower_bound',
|
72 |
+
image_interpolation_method=cv2.INTER_CUBIC,
|
73 |
+
),
|
74 |
+
NormalizeImage(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
|
75 |
+
PrepareForNet(),
|
76 |
+
])
|
77 |
+
|
78 |
@torch.no_grad()
|
79 |
def predict_depth(model, image):
|
80 |
return model(image)
|
|
|
102 |
|
103 |
# DifferentialDiffusion
|
104 |
|
105 |
+
def preprocess_image(image_array):
|
106 |
+
image = Image.fromarray(image_array)
|
107 |
image = image.convert("RGB")
|
108 |
image = transforms.CenterCrop((image.size[1] // 64 * 64, image.size[0] // 64 * 64))(image)
|
109 |
image = transforms.ToTensor()(image)
|
|
|
153 |
# first run
|
154 |
[(original_image, colored_depth), name, raw_depth] = depthify(image)
|
155 |
print(f"original_image={original_image} colored_depth={colored_depth}, name={name}, raw_depth={raw_depth}")
|
156 |
+
return raw_depth, inference(original_image, raw_depth, gs, prompt, neg_prompt)
|
157 |
|
158 |
with gr.Blocks() as demo:
|
159 |
with gr.Row():
|
|
|
169 |
clr_btn=gr.ClearButton(components=[input_image, gs, prompt, neg_prompt])
|
170 |
run_btn = gr.Button("Run",variant="primary")
|
171 |
|
172 |
+
change_map = gr.Image(label="Change Map")
|
173 |
output = gr.Image(label="Output Image")
|
174 |
run_btn.click(
|
175 |
run,
|