Skip to content

custom demo.ipynd needs an update #10

@sadhoss

Description

@sadhoss

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions