You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I predict the image show:detected 100 instances in 0.69s,and i print the predictor:Instances(num_instances=100, image_height=1080,
my weight only have 2 class, i want to change the num_instances ,please tell me how to change
The text was updated successfully, but these errors were encountered:
To change the number of instances detected in the image, modify the detection threshold or apply post-processing to filter out unwanted instances based on your criteria.
from detectron2.engine import DefaultPredictor
from detectron2.config import get_cfg
from detectron2 import model_zoo
# Load the model configuration and set the desired threshold
cfg = get_cfg()
cfg.merge_from_file(model_zoo.get_config_file("COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml"))
cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.7 # Set your desired threshold here
cfg.MODEL.WEIGHTS = "path/to/your/model_weights.pth" # Update with your model weights
predictor = DefaultPredictor(cfg)
# Run the prediction
image = cv2.imread("path/to/your/image.jpg") # Replace with the path to your image
outputs = predictor(image)
# Post-processing to filter the instances if needed
instances = outputs["instances"]
filtered_instances = instances[instances.scores > 0.7] # Filtering based on score threshold
print(f"Number of detected instances: {len(filtered_instances)}")
📚 Documentation Issue
I predict the image show:detected 100 instances in 0.69s,and i print the predictor:Instances(num_instances=100, image_height=1080,
my weight only have 2 class, i want to change the num_instances ,please tell me how to change
The text was updated successfully, but these errors were encountered: