資源簡介
視覺處理(test_shape.py)
代碼片段和文件信息
import?os
import?sys
import?random
import?math
import?numpy?as?np
import?skimage.io
import?matplotlib
import?matplotlib.pyplot?as?plt
from?mrcnn.config?import?Config
from?mrcnn?import?utils
import?mrcnn.model?as?modellib
from?mrcnn?import?visualize
import?cv2
from?mrcnn.model?import?log
#?修改為自己的識別類別
class_names?=?[‘BG‘?‘plane‘]
width=600
height=800
class?ShapesConfig(Config):
????“““Configuration?for?training?on?the?toy?shapes?dataset.
????Derives?from?the?base?Config?class?and?overrides?values?specific
????to?the?toy?shapes?dataset.
????“““
????#?Give?the?configuration?a?recognizable?name
????NAME?=?“shapes“
????#?Train?on?1?GPU?and?8?images?per?GPU.?We?can?put?multiple?images?on?each
????#?GPU?because?the?images?are?small.?Batch?size?is?8?(GPUs?*?images/GPU).
????GPU_COUNT?=?1
????IMAGES_PER_GPU?=1
????#?Number?of?classes?(including?background)
????NUM_CLASSES?=?1?+?1??#?background?+?3?shapes
????#?Use?small?images?for?faster?training.?Set?the?limits?of?the?small?side
????#?the?large?side?and?that?determines?the?image?shape.
????IMAGE_MIN_DIM?=?128
????IMAGE_MAX_DIM?=?128
????#?Use?smaller?anchors?because?our?image?and?objects?are?small
????RPN_ANCHOR_SCALES?=?(8?16?32?64?128)??#?anchor?side?in?pixels
????#?Reduce?training?ROIs?per?image?because?the?images?are?small?and?have
????#?few?objects.?Aim?to?allow?ROI?sampling?to?pick?33%?positive?ROIs.
????TRAIN_ROIS_PER_IMAGE?=?32
????#?Use?a?small?epoch?since?the?data?is?simple
????STEPS_PER_EPOCH?=?10
????#?use?small?validation?steps?since?the?epoch?is?small
????VALIDATION_STEPS?=?2
class?InferenceConfig(ShapesConfig):
????#?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
評論
共有 條評論