Spaces:
				
			
			
	
			
			
		Sleeping
		
	
	
	
			
			
	
	
	
	
		
		
		Sleeping
		
	Update pipeline/tool/object_detetction_model.py
Browse files
    	
        pipeline/tool/object_detetction_model.py
    CHANGED
    
    | @@ -42,7 +42,7 @@ class GroundingDINO: | |
| 42 | 
             
                    image_source, image = load_image(IMAGE_PATH)
         | 
| 43 | 
             
                    if use_text_rec:
         | 
| 44 | 
             
                        # 在场景文本中下调boxthreshold
         | 
| 45 | 
            -
                        boxes, logits, phrases = predict(model=self.model,image=image,caption=content,box_threshold=0.2,text_threshold=self.TEXT_TRESHOLD | 
| 46 | 
             
                        h, w, _ = image_source.shape
         | 
| 47 | 
             
                        torch_boxes = boxes * torch.Tensor([w, h, w, h])
         | 
| 48 | 
             
                        xyxy = box_convert(boxes=torch_boxes, in_fmt="cxcywh", out_fmt="xyxy").numpy()
         | 
| @@ -72,7 +72,7 @@ class GroundingDINO: | |
| 72 | 
             
                    else:
         | 
| 73 | 
             
                        new_path = new_path + IMAGE_PATH.split('/')[-1]
         | 
| 74 | 
             
                        print(content)
         | 
| 75 | 
            -
                        boxes, logits, phrases = predict(model=self.model,image=image,caption=content,box_threshold=self.BOX_TRESHOLD,text_threshold=self.TEXT_TRESHOLD | 
| 76 | 
             
                        annotated_frame = annotate(image_source=image_source, boxes=boxes, logits=logits, phrases=phrases)
         | 
| 77 | 
             
                        cv2.imwrite(new_path, annotated_frame)
         | 
| 78 | 
             
                        h, w, _ = image_source.shape
         | 
|  | |
| 42 | 
             
                    image_source, image = load_image(IMAGE_PATH)
         | 
| 43 | 
             
                    if use_text_rec:
         | 
| 44 | 
             
                        # 在场景文本中下调boxthreshold
         | 
| 45 | 
            +
                        boxes, logits, phrases = predict(model=self.model,image=image,caption=content,box_threshold=0.2,text_threshold=self.TEXT_TRESHOLD, device='cpu')
         | 
| 46 | 
             
                        h, w, _ = image_source.shape
         | 
| 47 | 
             
                        torch_boxes = boxes * torch.Tensor([w, h, w, h])
         | 
| 48 | 
             
                        xyxy = box_convert(boxes=torch_boxes, in_fmt="cxcywh", out_fmt="xyxy").numpy()
         | 
|  | |
| 72 | 
             
                    else:
         | 
| 73 | 
             
                        new_path = new_path + IMAGE_PATH.split('/')[-1]
         | 
| 74 | 
             
                        print(content)
         | 
| 75 | 
            +
                        boxes, logits, phrases = predict(model=self.model,image=image,caption=content,box_threshold=self.BOX_TRESHOLD,text_threshold=self.TEXT_TRESHOLD, device='cpu')
         | 
| 76 | 
             
                        annotated_frame = annotate(image_source=image_source, boxes=boxes, logits=logits, phrases=phrases)
         | 
| 77 | 
             
                        cv2.imwrite(new_path, annotated_frame)
         | 
| 78 | 
             
                        h, w, _ = image_source.shape
         |