Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -142,26 +142,26 @@ def get_depth_image(
|
|
142 |
image = Image.fromarray((image * 255.0).clip(0, 255).astype(np.uint8))
|
143 |
return image
|
144 |
|
145 |
-
# ---------------------
|
146 |
-
# ------- DETR --------
|
147 |
-
# ---------------------
|
148 |
-
@torch.inference_mode()
|
149 |
-
@spaces.GPU
|
150 |
-
def run_detr(image:Image, confidence_threshold: float = 0.8):
|
151 |
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
|
166 |
def resize_dimensions(dimensions, target_size):
|
167 |
"""
|
@@ -415,11 +415,11 @@ depth_estimator = depth_estimator.to(device)
|
|
415 |
# ---------------------------------------
|
416 |
# Load Detr Model
|
417 |
# ---------------------------------------
|
418 |
-
detr_model = DetrForObjectDetection.from_pretrained("facebook-detr-50",
|
419 |
-
|
420 |
-
|
421 |
-
detr_processor = DetrImageProcessor.from_pretrained("facebook-detr-50",
|
422 |
-
|
423 |
|
424 |
def main():
|
425 |
model = ControlNetDepthDesignModelMulti()
|
|
|
142 |
image = Image.fromarray((image * 255.0).clip(0, 255).astype(np.uint8))
|
143 |
return image
|
144 |
|
145 |
+
# # ---------------------
|
146 |
+
# # ------- DETR --------
|
147 |
+
# # ---------------------
|
148 |
+
# @torch.inference_mode()
|
149 |
+
# @spaces.GPU
|
150 |
+
# def run_detr(image:Image, confidence_threshold: float = 0.8):
|
151 |
|
152 |
+
# target = {'image_id': 0, 'annotations': []}
|
153 |
+
# encoding = detr_processor(images=image, annotations=target, return_tensors="pt")
|
154 |
+
# pixel_values = encoding["pixel_values"].to(device)
|
155 |
+
# outputs = detr_model(pixel_values=pixel_values, pixel_mask=None)
|
156 |
|
157 |
+
# width, height = image.size
|
158 |
+
# postprocessed_outputs = detr_processor.post_process_object_detection(outputs,
|
159 |
+
# target_sizes=[(height, width)],
|
160 |
+
# threshold=confidence_threshold)
|
161 |
+
# outputs = postprocessed_outputs[0]
|
162 |
+
# # dict{scores, logits, labels, boxes}
|
163 |
+
# outputs = outputs['boxes']
|
164 |
+
# return outputs
|
165 |
|
166 |
def resize_dimensions(dimensions, target_size):
|
167 |
"""
|
|
|
415 |
# ---------------------------------------
|
416 |
# Load Detr Model
|
417 |
# ---------------------------------------
|
418 |
+
# detr_model = DetrForObjectDetection.from_pretrained("facebook-detr-50",
|
419 |
+
# # id2label={v:k for k,v in CLASS2ID.items()},
|
420 |
+
# use_safetensors=True)
|
421 |
+
# detr_processor = DetrImageProcessor.from_pretrained("facebook-detr-50",
|
422 |
+
# use_safetensors=True)
|
423 |
|
424 |
def main():
|
425 |
model = ControlNetDepthDesignModelMulti()
|