Custom_MaskRCNN icon indicating copy to clipboard operation
Custom_MaskRCNN copied to clipboard

custom demo.ipynd needs an update

Open sadhoss opened this issue 3 years ago • 1 comments

The current demo.ipynb only supports coco model/weights. Need to update the notebook to use custom config, and to use custom model weights.

TL;DR:

These needs an update:

# Import COCO config
sys.path.append(os.path.join(ROOT_DIR, "samples/coco/"))  # To find local version
import coco

replace with

# Import Custom config
sys.path.append(os.path.join(ROOT_DIR, "samples/custom/"))  # To find local version
import custom
# Local path to trained weights file
COCO_MODEL_PATH = os.path.join(ROOT_DIR, "mask_rcnn_coco.h5")
# Download COCO trained weights from Releases if needed
if not os.path.exists(COCO_MODEL_PATH):
    utils.download_trained_weights(COCO_MODEL_PATH)

replace with

# Local path to trained weights file
CUSTOM_MODEL_PATH = os.path.join(MODEL_DIR, "mask_rcnn_custom.h5")
class InferenceConfig(coco.CocoConfig):
    # Set batch size to 1 since we'll be running inference on
    # one image at a time. Batch size = GPU_COUNT * IMAGES_PER_GPU
    GPU_COUNT = 1
    IMAGES_PER_GPU = 1

replace with

class InferenceConfig(custom.CustomConfig):
    # Set batch size to 1 since we'll be running inference on
    # one image at a time. Batch size = GPU_COUNT * IMAGES_PER_GPU
    GPU_COUNT = 1
    IMAGES_PER_GPU = 1
# Load weights trained on MS-COCO
model.load_weights(COCO_MODEL_PATH, by_name=True)

replace with

# Load weights trained on custom
model.load_weights(CUSTOM_MODEL_PATH, by_name=True)

sadhoss avatar Jul 14 '21 08:07 sadhoss

THANKS!!!

IrroIrro avatar Apr 05 '22 22:04 IrroIrro