Spaces:
Sleeping
Sleeping
Commit
·
6f64e41
1
Parent(s):
9196eaa
Translate RGB
Browse files
app.py
CHANGED
|
@@ -26,9 +26,9 @@ import groundingdino.datasets.transforms as T
|
|
| 26 |
|
| 27 |
from huggingface_hub import hf_hub_download
|
| 28 |
|
| 29 |
-
picture_height =
|
| 30 |
-
picture_width =
|
| 31 |
-
picture_fov =
|
| 32 |
|
| 33 |
# Use this command for evaluate the GLIP-T model
|
| 34 |
config_file = "groundingdino/config/GroundingDINO_SwinT_OGC.py"
|
|
@@ -96,8 +96,7 @@ model = load_model_hf(config_file, ckpt_repo_id, ckpt_filenmae)
|
|
| 96 |
|
| 97 |
|
| 98 |
def run_grounding(input_image):
|
| 99 |
-
|
| 100 |
-
pil_img = Image.fromarray(cv2_img_rgb)
|
| 101 |
init_image = pil_img.convert("RGB")
|
| 102 |
original_size = init_image.size
|
| 103 |
grounding_caption = "traffic sign"
|
|
@@ -111,9 +110,9 @@ def run_grounding(input_image):
|
|
| 111 |
boxes, logits, phrases = predict(model, image_tensor, grounding_caption, box_threshold, text_threshold,
|
| 112 |
device='cpu')
|
| 113 |
annotated_frame = annotate(image_source=np.asarray(image_pil), boxes=boxes, logits=logits, phrases=phrases)
|
| 114 |
-
image_with_box = Image.fromarray(cv2.cvtColor(annotated_frame, cv2.COLOR_BGR2RGB))
|
| 115 |
|
| 116 |
-
|
|
|
|
| 117 |
|
| 118 |
|
| 119 |
if __name__ == "__main__":
|
|
@@ -126,10 +125,10 @@ if __name__ == "__main__":
|
|
| 126 |
with gr.Column():
|
| 127 |
input_image = gr.Image(source='upload', type="numpy", label="Please upload a panorama picture.")
|
| 128 |
run_button = gr.Button(label="Process & Detect")
|
| 129 |
-
|
| 130 |
with gr.Column():
|
| 131 |
gallery = gr.Gallery(label="Detection Results").style(
|
| 132 |
-
columns=[3], preview=True, object_fit="none")
|
| 133 |
|
| 134 |
run_button.click(fn=detection, inputs=[
|
| 135 |
input_image], outputs=[gallery])
|
|
|
|
| 26 |
|
| 27 |
from huggingface_hub import hf_hub_download
|
| 28 |
|
| 29 |
+
picture_height = 720
|
| 30 |
+
picture_width = 1080
|
| 31 |
+
picture_fov = 60
|
| 32 |
|
| 33 |
# Use this command for evaluate the GLIP-T model
|
| 34 |
config_file = "groundingdino/config/GroundingDINO_SwinT_OGC.py"
|
|
|
|
| 96 |
|
| 97 |
|
| 98 |
def run_grounding(input_image):
|
| 99 |
+
pil_img = Image.fromarray(input_image)
|
|
|
|
| 100 |
init_image = pil_img.convert("RGB")
|
| 101 |
original_size = init_image.size
|
| 102 |
grounding_caption = "traffic sign"
|
|
|
|
| 110 |
boxes, logits, phrases = predict(model, image_tensor, grounding_caption, box_threshold, text_threshold,
|
| 111 |
device='cpu')
|
| 112 |
annotated_frame = annotate(image_source=np.asarray(image_pil), boxes=boxes, logits=logits, phrases=phrases)
|
|
|
|
| 113 |
|
| 114 |
+
|
| 115 |
+
return annotated_frame
|
| 116 |
|
| 117 |
|
| 118 |
if __name__ == "__main__":
|
|
|
|
| 125 |
with gr.Column():
|
| 126 |
input_image = gr.Image(source='upload', type="numpy", label="Please upload a panorama picture.")
|
| 127 |
run_button = gr.Button(label="Process & Detect")
|
| 128 |
+
with gr.Row():
|
| 129 |
with gr.Column():
|
| 130 |
gallery = gr.Gallery(label="Detection Results").style(
|
| 131 |
+
rows=[2],columns=[3], preview=True, object_fit="none")
|
| 132 |
|
| 133 |
run_button.click(fn=detection, inputs=[
|
| 134 |
input_image], outputs=[gallery])
|