Files
Photovoltaic_Fault_Detector/ssd_keras-master/models/keras_ssd300.pyc

164 lines
23 KiB
Plaintext
Raw Normal View History

2020-02-06 16:47:03 -03:00
<03>
<EFBFBD>6<EFBFBD>\c@ s<>dZddlmZddlZddlmZddlmZm Z m
Z
m Z m Z m Z mZmZddlmZddljZddlmZddlmZdd lmZdd
lmZd d ddddd ddgd dddd%gd dddd&gd dddd'gd ddgd ddggeddddddgdeddddgdedddgddddgd d!d"d#ed$<00>Z dS((sf
A Keras port of the original Caffe SSD300 network.
Copyright (C) 2018 Pierluigi Ferrari
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
i<EFBFBD><EFBFBD><EFBFBD><EFBFBD>(tdivisionN(tModel(tInputtLambdat
ActivationtConv2Dt MaxPooling2Dt ZeroPadding2DtReshapet Concatenate(tl2(t AnchorBoxes(tL2Normalization(tDecodeDetections(tDecodeDetectionsFastttrainingg<67><67><EFBFBD><EFBFBD>Mb@?g<00>?g@g<00>?g@iii i@idi,g<><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?g<><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?t centroidsi{iuihiiig{<14>G<EFBFBD>z<EFBFBD>?g<><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?i<>i<>co s<>d}|d7}|}|d|d|d}}}|d<>kr]|d<>kr]td<00><00>n|r<>t|<00>|kr<>tdj|t|<00><00><00><00>q<>n|d<>ks<>|d<>kr<>|d<>kr<>td<00><00>n|rt|<00>|dkr)tdj|dt|<00><00><00><00>q)ntj|||d<17>}t| <00>d krYtd
jt| <00><00><00><00>ntj| <00>} tj| dk<00>r<>td j| <00><00><00>n|
d<>k r<>t|
<00>|kr<>td <00><00>n| d<>k r<>t| <00>|kr<>td <00><00>n|r<>|}n |g|}|rhg}x<>|D]C}d|k| @rN|jt|<00>d<17>q|jt|<00><00>qWn<d|k| @r<>t|<00>d}n t|<00>}|g|}|
d<>kr<>d<>g|}
n| d<>kr<>d<>g|} nd<00>} <00>fd<00>}!<00>fd<00>}"<00>fd<00>}#t d|||f<00>}$t
| d|||fdd<00>|$<00>}%<00>d<>k r<>t
|!d|||fdd<00>|%<00>}%n<00>d<>k r<>t
|"d|||fdd<00>|%<00>}%n<00>r<>t
|#d|||fdd<00>|%<00>}%nt dd<>dddddd d!t |<00>dd"<00>|%<00>}&t dd<>dddddd d!t |<00>dd#<00>|&<00>}'t d$d<>d%d<>dddd&<00>|'<00>}(t d'd<>dddddd d!t |<00>dd(<00>|(<00>})t d'd<>dddddd d!t |<00>dd)<00>|)<00>}*t d$d<>d%d<>dddd*<00>|*<00>}+t d+d<>dddddd d!t |<00>dd,<00>|+<00>},t d+d<>dddddd d!t |<00>dd-<00>|,<00>}-t d+d<>dddddd d!t |<00>dd.<00>|-<00>}.t d$d<>d%d<>dddd/<00>|.<00>}/t d0d<>dddddd d!t |<00>dd1<00>|/<00>}0t d0d<>dddddd d!t |<00>dd2<00>|0<00>}1t d0d<>dddddd d!t |<00>dd3<00>|1<00>}2t d$d<>d%d<>dddd4<00>|2<00>}3t d0d<>dddddd d!t |<00>dd5<00>|3<00>}4t d0d<>dddddd d!t |<00>dd6<00>|4<00>}5t d0d<>dddddd d!t |<00>dd7<00>|5<00>}6t d$d<>d%d<>dddd8<00>|6<00>}7t d9d<>d:d<>dddddd d!t |<00>dd;<00>|7<00>}8t d9d<>dddddd d!t |<00>dd<<00>|8<00>}9t d+d<>dddddd d!t |<00>dd=<00>|9<00>}:tdd<>d<>fdd><00>|:<00>}:t d0d<>d%d<>dddd?dd d!t |<00>dd@<00>|:<00>};t d'd<>dddddd d!t |<00>ddA<00>|;<00>}<tdd<>d<>fddB<00>|<<00>}<t d+d<>d%d<>dddd?dd d!t |<00>ddC<00>|<<00>}=t d'd<>dddddd d!t |<00>ddD<00>|=<00>}>t d+d<>d%d<>dddd?dd d!t |<00>ddE<00>|><00>}?t d'd<>dddddd d!t |<00>ddF<00>|?<00>}@t d+d<>d%d<>dddd?dd d!t |<00>ddG<00>|@<00>}AtdHdIddJ<00>|2<00>}Bt |d|d<>dddd d!t |<00>ddK<00>|B<00>}Ct |d|d<>dddd d!t |<00>ddL<00>|9<00>}Dt |d|d<>dddd d!t |<00>ddM<00>|;<00>}Et |d|d<>dddd d!t |<00>ddN<00>|=<00>}Ft |d |d<>dddd d!t |<00>ddO<00>|?<00>}Gt |dP|d<>dddd d!t |<00>ddQ<00>|A<00>}Ht |dd d<>dddd d!t |<00>ddR<00>|B<00>}It |dd d<>dddd d!t |<00>ddS<00>|9<00>}Jt |dd d<>dddd d!t |<00>ddT<00>|;<00>}Kt |dd d<>dddd d!t |<00>ddU<00>|=<00>}Lt |d d d<>dddd d!t |<00>ddV<00>|?<00>}Mt |dPd d<>dddd d!t |<00>ddW<00>|A<00>}Nt||dX|ddY|ddZ|dd[| d\|
dd]| dd^| d_| d`|da|ddb<00> |I<00>}Ot||dX|ddY|ddZ|dd[| d\|
dd]| dd^| d_| d`|da|ddc<00> |J<00>}Pt||dX|ddY|ddZ|dd[| d\|
dd]| dd^| d_| d`|da|ddd<00> |K<00>}Qt||dX|ddY|d dZ|dd[| d\|
dd]| dd^| d_| d`|da|dde<00> |L<00>}Rt||dX|d dY|dPdZ|d d[| d\|
d d]| d d^| d_| d`|da|ddf<00> |M<00>}St||dX|dPdY|ddZ|dPd[| d\|
dPd]| dPd^| d_| d`|da|ddg<00> |N<00>}Ttdh|fddi<00>|C<00>}Utdh|fddj<00>|D<00>}Vtdh|fddk<00>|E<00>}Wtdh|fddl<00>|F<00>}Xtdh|fddm<00>|G<00>}Ytdh|fddn<00>|H<00>}Ztd<>ddo<00>|I<00>}[td<>ddp<00>|J<00>}\td<>ddq<00>|K<00>}]td<>ddr<00>|L<00>}^td<>dds<00>|M<00>}_td<>ddt<00>|N<00>}`td<>ddv<00>|O<00>}atd<>ddw<00>|P<00>}btd<>ddx<00>|Q<00>}ctd<>ddy<00>|R<00>}dtd<>ddz<00>|S<00>}etd<>dd{<00>|T<00>}ftd|ddd}<00>|U|V|W|X|Y|Zg<00>}gtd|ddd~<00>|[|\|]|^|_|`g<00>}htd|ddd<00>|a|b|c|d|e|fg<00>}itd<>dd<><00>|g<00>}jtd|ddd<><00>|j|h|ig<00>}k|d<>krKtd<>|$d<>|k<00>}ln<>|d<>kr<>td<>|d<>|d<>|d<>|d`|da|d<>|d<>|dd<><00> |k<00>}mtd<>|$d<>|m<00>}ln~|d<>krtd<>|d<>|d<>|d<>|d`|da|d<>|d<>|dd<><00> |k<00>}mtd<>|$d<>|m<00>}lntd<>j|<00><00><00>|r<>tj|Cjdd!|Djdd!|Ejdd!|Fjdd!|Gjdd!|Hjdd!g<00>}n|l|nfS|lSd<53>S(<28>s&
Build a Keras model with SSD300 architecture, see references.
The base network is a reduced atrous VGG-16, extended by the SSD architecture,
as described in the paper.
Most of the arguments that this function takes are only needed for the anchor
box layers. In case you're training the network, the parameters passed here must
be the same as the ones used to set up `SSDBoxEncoder`. In case you're loading
trained weights, the parameters passed here must be the same as the ones used
to produce the trained weights.
Some of these arguments are explained in more detail in the documentation of the
`SSDBoxEncoder` class.
Note: Requires Keras v2.0 or later. Currently works only with the
TensorFlow backend (v1.0 or later).
Arguments:
image_size (tuple): The input image size in the format `(height, width, channels)`.
n_classes (int): The number of positive classes, e.g. 20 for Pascal VOC, 80 for MS COCO.
mode (str, optional): One of 'training', 'inference' and 'inference_fast'. In 'training' mode,
the model outputs the raw prediction tensor, while in 'inference' and 'inference_fast' modes,
the raw predictions are decoded into absolute coordinates and filtered via confidence thresholding,
non-maximum suppression, and top-k filtering. The difference between latter two modes is that
'inference' follows the exact procedure of the original Caffe implementation, while
'inference_fast' uses a faster prediction decoding procedure.
l2_regularization (float, optional): The L2-regularization rate. Applies to all convolutional layers.
Set to zero to deactivate L2-regularization.
min_scale (float, optional): The smallest scaling factor for the size of the anchor boxes as a fraction
of the shorter side of the input images.
max_scale (float, optional): The largest scaling factor for the size of the anchor boxes as a fraction
of the shorter side of the input images. All scaling factors between the smallest and the
largest will be linearly interpolated. Note that the second to last of the linearly interpolated
scaling factors will actually be the scaling factor for the last predictor layer, while the last
scaling factor is used for the second box for aspect ratio 1 in the last predictor layer
if `two_boxes_for_ar1` is `True`.
scales (list, optional): A list of floats containing scaling factors per convolutional predictor layer.
This list must be one element longer than the number of predictor layers. The first `k` elements are the
scaling factors for the `k` predictor layers, while the last element is used for the second box
for aspect ratio 1 in the last predictor layer if `two_boxes_for_ar1` is `True`. This additional
last scaling factor must be passed either way, even if it is not being used. If a list is passed,
this argument overrides `min_scale` and `max_scale`. All scaling factors must be greater than zero.
aspect_ratios_global (list, optional): The list of aspect ratios for which anchor boxes are to be
generated. This list is valid for all prediction layers.
aspect_ratios_per_layer (list, optional): A list containing one aspect ratio list for each prediction layer.
This allows you to set the aspect ratios for each predictor layer individually, which is the case for the
original SSD300 implementation. If a list is passed, it overrides `aspect_ratios_global`.
two_boxes_for_ar1 (bool, optional): Only relevant for aspect ratio lists that contain 1. Will be ignored otherwise.
If `True`, two anchor boxes will be generated for aspect ratio 1. The first will be generated
using the scaling factor for the respective layer, the second one will be generated using
geometric mean of said scaling factor and next bigger scaling factor.
steps (list, optional): `None` or a list with as many elements as there are predictor layers. The elements can be
either ints/floats or tuples of two ints/floats. These numbers represent for each predictor layer how many
pixels apart the anchor box center points should be vertically and horizontally along the spatial grid over
the image. If the list contains ints/floats, then that value will be used for both spatial dimensions.
If the list contains tuples of two ints/floats, then they represent `(step_height, step_width)`.
If no steps are provided, then they will be computed such that the anchor box center points will form an
equidistant grid within the image dimensions.
offsets (list, optional): `None` or a list with as many elements as there are predictor layers. The elements can be
either floats or tuples of two floats. These numbers represent for each predictor layer how many
pixels from the top and left boarders of the image the top-most and left-most anchor box center points should be
as a fraction of `steps`. The last bit is important: The offsets are not absolute pixel values, but fractions
of the step size specified in the `steps` argument. If the list contains floats, then that value will
be used for both spatial dimensions. If the list contains tuples of two floats, then they represent
`(vertical_offset, horizontal_offset)`. If no offsets are provided, then they will default to 0.5 of the step size.
clip_boxes (bool, optional): If `True`, clips the anchor box coordinates to stay within image boundaries.
variances (list, optional): A list of 4 floats >0. The anchor box offset for each coordinate will be divided by
its respective variance value.
coords (str, optional): The box coordinate format to be used internally by the model (i.e. this is not the input format
of the ground truth labels). Can be either 'centroids' for the format `(cx, cy, w, h)` (box center coordinates, width,
and height), 'minmax' for the format `(xmin, xmax, ymin, ymax)`, or 'corners' for the format `(xmin, ymin, xmax, ymax)`.
normalize_coords (bool, optional): Set to `True` if the model is supposed to use relative instead of absolute coordinates,
i.e. if the model predicts box coordinates within [0,1] instead of absolute coordinates.
subtract_mean (array-like, optional): `None` or an array-like object of integers or floating point values
of any shape that is broadcast-compatible with the image shape. The elements of this array will be
subtracted from the image pixel intensity values. For example, pass a list of three integers
to perform per-channel mean normalization for color images.
divide_by_stddev (array-like, optional): `None` or an array-like object of non-zero integers or
floating point values of any shape that is broadcast-compatible with the image shape. The image pixel
intensity values will be divided by the elements of this array. For example, pass a list
of three integers to perform per-channel standard deviation normalization for color images.
swap_channels (list, optional): Either `False` or a list of integers representing the desired order in which the input
image channels should be swapped.
confidence_thresh (float, optional): A float in [0,1), the minimum classification confidence in a specific
positive class in order to be considered for the non-maximum suppression stage for the respective class.
A lower value will result in a larger part of the selection process being done by the non-maximum suppression
stage, while a larger value will result in a larger part of the selection process happening in the confidence
thresholding stage.
iou_threshold (float, optional): A float in [0,1]. All boxes that have a Jaccard similarity of greater than `iou_threshold`
with a locally maximal box will be removed from the set of predictions for a given class, where 'maximal' refers
to the box's confidence score.
top_k (int, optional): The number of highest scoring predictions to be kept for each batch item after the
non-maximum suppression stage.
nms_max_output_size (int, optional): The maximal number of predictions that will be left over after the NMS stage.
return_predictor_sizes (bool, optional): If `True`, this function not only returns the model, but also
a list containing the spatial dimensions of the predictor layers. This isn't strictly necessary since
you can always get their sizes easily via the Keras API, but it's convenient and less error-prone
to get them this way. They are only relevant for training anyway (SSDBoxEncoder needs to know the
spatial dimensions of the predictor layers), for inference you don't need them.
Returns:
model: The Keras SSD300 model.
predictor_sizes (optional): A Numpy array containing the `(height, width)` portion
of the output tensor shape for each convolutional predictor layer. During
training, the generator function needs this in order to transform
the ground truth labels into tensors of identical structure as the
output tensors of the model, which is in turn needed for the cost
function.
References:
https://arxiv.org/abs/1512.02325v5
iiiism`aspect_ratios_global` and `aspect_ratios_per_layer` cannot both be None. At least one needs to be specified.s<>It must be either aspect_ratios_per_layer is None or len(aspect_ratios_per_layer) == {}, but len(aspect_ratios_per_layer) == {}.sDEither `min_scale` and `max_scale` or `scales` need to be specified.sMIt must be either scales is None or len(scales) == {}, but len(scales) == {}.is=4 variance values must be pased, but {} values were received.s8All variances must be >0, but the variances given are {}s=You must provide at least one step value per predictor layer.s?You must provide at least one offset value per predictor layer.cS s|S(N((ttensor((sZ/home/dl-desktop/Desktop/Tesis/8.-Object_Detection/keras-ssd-master/models/keras_ssd300.pytidentity_layer<65>sc s|tj<00><00>S(N(tnptarray(R(t subtract_mean(sZ/home/dl-desktop/Desktop/Tesis/8.-Object_Detection/keras-ssd-master/models/keras_ssd300.pytinput_mean_normalization<6F>sc s|tj<00><00>S(N(RR(R(tdivide_by_stddev(sZ/home/dl-desktop/Desktop/Tesis/8.-Object_Detection/keras-ssd-master/models/keras_ssd300.pytinput_stddev_normalization<6F>sc s<>t<00><00>dkrXtj|d<00>df|d<00>df|d<00>dfgdd<00>St<00><00>dkr<>tj|d<00>df|d<00>df|d<00>df|d<00>dfgdd<00>SdS( Ni.iiitaxisi<73><69><EFBFBD><EFBFBD>i(tlentKtstack(R(t swap_channels(sZ/home/dl-desktop/Desktop/Tesis/8.-Object_Detection/keras-ssd-master/models/keras_ssd300.pytinput_channel_swap<61>sFtshapet output_shapetnameRRRRi@it
activationtrelutpaddingtsametkernel_initializert he_normaltkernel_regularizertconv1_1tconv1_2t pool_sizetstridestpool1i<31>tconv2_1tconv2_2tpool2itconv3_1tconv3_2tconv3_3tpool3itconv4_1tconv4_2tconv4_3tpool4tconv5_1tconv5_2tconv5_3tpool5it dilation_ratetfc6tfc7tconv6_1t conv6_paddingtvalidtconv6_2tconv7_1t conv7_paddingtconv7_2tconv8_1tconv8_2tconv9_1tconv9_2t
gamma_initit conv4_3_normtconv4_3_norm_mbox_conft fc7_mbox_conftconv6_2_mbox_conftconv7_2_mbox_conftconv8_2_mbox_confitconv9_2_mbox_conftconv4_3_norm_mbox_loct fc7_mbox_loctconv6_2_mbox_loctconv7_2_mbox_loctconv8_2_mbox_loctconv9_2_mbox_loct
this_scalet
next_scalet aspect_ratiosttwo_boxes_for_ar1t
this_stepst this_offsetst
clip_boxest variancestcoordstnormalize_coordstconv4_3_norm_mbox_priorboxtfc7_mbox_priorboxtconv6_2_mbox_priorboxtconv7_2_mbox_priorboxtconv8_2_mbox_priorboxtconv9_2_mbox_priorboxi<78><69><EFBFBD><EFBFBD>tconv4_3_norm_mbox_conf_reshapetfc7_mbox_conf_reshapetconv6_2_mbox_conf_reshapetconv7_2_mbox_conf_reshapetconv8_2_mbox_conf_reshapetconv9_2_mbox_conf_reshapetconv4_3_norm_mbox_loc_reshapetfc7_mbox_loc_reshapetconv6_2_mbox_loc_reshapetconv7_2_mbox_loc_reshapetconv8_2_mbox_loc_reshapetconv9_2_mbox_loc_reshapeit"conv4_3_norm_mbox_priorbox_reshapetfc7_mbox_priorbox_reshapetconv6_2_mbox_priorbox_reshapetconv7_2_mbox_priorbox_reshapetconv8_2_mbox_priorbox_reshapetconv9_2_mbox_priorbox_reshapeRt mbox_conftmbox_loct mbox_priorboxtsoftmaxtmbox_conf_softmaxt predictionsRtinputstoutputst inferencetconfidence_thresht iou_thresholdttop_ktnms_max_output_sizet
img_heightt img_widthtdecoded_predictionstinference_fastsU`mode` must be one of 'training', 'inference' or 'inference_fast', but received '{}'.N(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(i<><69><EFBFBD><EFBFBD>i(i<><69><EFBFBD><EFBFBD>i(i<><69><EFBFBD><EFBFBD>i(i<><69><EFBFBD><EFBFBD>i(i<><69><EFBFBD><EFBFBD>i(i<><69><EFBFBD><EFBFBD>i(i<><69><EFBFBD><EFBFBD>i(i<><69><EFBFBD><EFBFBD>i(i<><69><EFBFBD><EFBFBD>i(i<><69><EFBFBD><EFBFBD>i(i<><69><EFBFBD><EFBFBD>i(i<><69><EFBFBD><EFBFBD>i(tNonet
ValueErrorRtformatRtlinspaceRtanytappendRRRR
RRR R RR RRR Rt _keras_shape(ot
image_sizet n_classestmodetl2_regularizationt min_scalet max_scaletscalestaspect_ratios_globaltaspect_ratios_per_layerR\tstepstoffsetsR_R`RaRbRRRR<>R<>R<>R<>treturn_predictor_sizestn_predictor_layerstl2_regR<67>R<>t img_channelsR[tn_boxestarRRRRtxtx1R)R*R-R.R/R0R1R2R3R4R5R6R7R8R9R:R;R<R>R?R@RCRDRFRGRHRIRJRLRMRNRORPRQRRRSRTRURVRWRXRcRdReRfRgRhRiRjRkRlRmRnRoRpRqRrRsRtRuRvRwRxRyRzR{R|R}RR<>tmodelR<6C>tpredictor_sizes((RRRsZ/home/dl-desktop/Desktop/Tesis/8.-Object_Detection/keras-ssd-master/models/keras_ssd300.pytssd_300st<00>
 $$(        
' * **99'99'999'999'999'?99!?9!?9?9?;;;;;;;;;;;;* !* !* !* !* !* !   $         
gUUUUUU<55>?gUUUUUU<55>?gUUUUUU<55>?(!t__doc__t
__future__RtnumpyRt keras.modelsRt keras.layersRRRRRRRR tkeras.regularizersR
t keras.backendtbackendRt$keras_layers.keras_layer_AnchorBoxesR t(keras_layers.keras_layer_L2NormalizationR t)keras_layers.keras_layer_DecodeDetectionsR t-keras_layers.keras_layer_DecodeDetectionsFastRR<>tTruetFalseR<65>(((sZ/home/dl-desktop/Desktop/Tesis/8.-Object_Detection/keras-ssd-master/models/keras_ssd300.pyt<module>sJ :