|  | 
|  | 1 | +# Copyright 2024 The KerasNLP Authors | 
|  | 2 | +# | 
|  | 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 4 | +# you may not use this file except in compliance with the License. | 
|  | 5 | +# You may obtain a copy of the License at | 
|  | 6 | +# | 
|  | 7 | +#     https://www.apache.org/licenses/LICENSE-2.0 | 
|  | 8 | +# | 
|  | 9 | +# Unless required by applicable law or agreed to in writing, software | 
|  | 10 | +# distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 12 | +# See the License for the specific language governing permissions and | 
|  | 13 | +# limitations under the License. | 
|  | 14 | +""" | 
|  | 15 | +formats.py contains axis information for each supported format. | 
|  | 16 | +""" | 
|  | 17 | + | 
|  | 18 | +from keras_nlp.src.api_export import keras_nlp_export | 
|  | 19 | + | 
|  | 20 | + | 
|  | 21 | +@keras_nlp_export("keras_nlp.bounding_box.XYXY") | 
|  | 22 | +class XYXY: | 
|  | 23 | +    """XYXY contains axis indices for the XYXY format. | 
|  | 24 | +
 | 
|  | 25 | +    All values in the XYXY format should be absolute pixel values. | 
|  | 26 | +
 | 
|  | 27 | +    The XYXY format consists of the following required indices: | 
|  | 28 | +
 | 
|  | 29 | +    - LEFT: left of the bounding box | 
|  | 30 | +    - TOP: top of the bounding box | 
|  | 31 | +    - RIGHT: right of the bounding box | 
|  | 32 | +    - BOTTOM: bottom of the bounding box | 
|  | 33 | +    """ | 
|  | 34 | + | 
|  | 35 | +    LEFT = 0 | 
|  | 36 | +    TOP = 1 | 
|  | 37 | +    RIGHT = 2 | 
|  | 38 | +    BOTTOM = 3 | 
|  | 39 | + | 
|  | 40 | + | 
|  | 41 | +@keras_nlp_export("keras_nlp.bounding_box.REL_XYXY") | 
|  | 42 | +class REL_XYXY: | 
|  | 43 | +    """REL_XYXY contains axis indices for the REL_XYXY format. | 
|  | 44 | +
 | 
|  | 45 | +    REL_XYXY is like XYXY, but each value is relative to the width and height of | 
|  | 46 | +    the origin image. Values are percentages of the origin images' width and | 
|  | 47 | +    height respectively. | 
|  | 48 | +
 | 
|  | 49 | +    The REL_XYXY format consists of the following required indices: | 
|  | 50 | +
 | 
|  | 51 | +    - LEFT: left of the bounding box | 
|  | 52 | +    - TOP: top of the bounding box | 
|  | 53 | +    - RIGHT: right of the bounding box | 
|  | 54 | +    - BOTTOM: bottom of the bounding box | 
|  | 55 | +    """ | 
|  | 56 | + | 
|  | 57 | +    LEFT = 0 | 
|  | 58 | +    TOP = 1 | 
|  | 59 | +    RIGHT = 2 | 
|  | 60 | +    BOTTOM = 3 | 
|  | 61 | + | 
|  | 62 | + | 
|  | 63 | +@keras_nlp_export("keras_nlp.bounding_box.CENTER_XYWH") | 
|  | 64 | +class CENTER_XYWH: | 
|  | 65 | +    """CENTER_XYWH contains axis indices for the CENTER_XYWH format. | 
|  | 66 | +
 | 
|  | 67 | +    All values in the CENTER_XYWH format should be absolute pixel values. | 
|  | 68 | +
 | 
|  | 69 | +    The CENTER_XYWH format consists of the following required indices: | 
|  | 70 | +
 | 
|  | 71 | +    - X: X coordinate of the center of the bounding box | 
|  | 72 | +    - Y: Y coordinate of the center of the bounding box | 
|  | 73 | +    - WIDTH: width of the bounding box | 
|  | 74 | +    - HEIGHT: height of the bounding box | 
|  | 75 | +    """ | 
|  | 76 | + | 
|  | 77 | +    X = 0 | 
|  | 78 | +    Y = 1 | 
|  | 79 | +    WIDTH = 2 | 
|  | 80 | +    HEIGHT = 3 | 
|  | 81 | + | 
|  | 82 | + | 
|  | 83 | +@keras_nlp_export("keras_nlp.bounding_box.XYWH") | 
|  | 84 | +class XYWH: | 
|  | 85 | +    """XYWH contains axis indices for the XYWH format. | 
|  | 86 | +
 | 
|  | 87 | +    All values in the XYWH format should be absolute pixel values. | 
|  | 88 | +
 | 
|  | 89 | +    The XYWH format consists of the following required indices: | 
|  | 90 | +
 | 
|  | 91 | +    - X: X coordinate of the left of the bounding box | 
|  | 92 | +    - Y: Y coordinate of the top of the bounding box | 
|  | 93 | +    - WIDTH: width of the bounding box | 
|  | 94 | +    - HEIGHT: height of the bounding box | 
|  | 95 | +    """ | 
|  | 96 | + | 
|  | 97 | +    X = 0 | 
|  | 98 | +    Y = 1 | 
|  | 99 | +    WIDTH = 2 | 
|  | 100 | +    HEIGHT = 3 | 
|  | 101 | + | 
|  | 102 | + | 
|  | 103 | +@keras_nlp_export("keras_nlp.bounding_box.REL_XYWH") | 
|  | 104 | +class REL_XYWH: | 
|  | 105 | +    """REL_XYWH contains axis indices for the XYWH format. | 
|  | 106 | +
 | 
|  | 107 | +    REL_XYXY is like XYWH, but each value is relative to the width and height of | 
|  | 108 | +    the origin image. Values are percentages of the origin images' width and | 
|  | 109 | +    height respectively. | 
|  | 110 | +
 | 
|  | 111 | +    - X: X coordinate of the left of the bounding box | 
|  | 112 | +    - Y: Y coordinate of the top of the bounding box | 
|  | 113 | +    - WIDTH: width of the bounding box | 
|  | 114 | +    - HEIGHT: height of the bounding box | 
|  | 115 | +    """ | 
|  | 116 | + | 
|  | 117 | +    X = 0 | 
|  | 118 | +    Y = 1 | 
|  | 119 | +    WIDTH = 2 | 
|  | 120 | +    HEIGHT = 3 | 
|  | 121 | + | 
|  | 122 | + | 
|  | 123 | +@keras_nlp_export("keras_nlp.bounding_box.YXYX") | 
|  | 124 | +class YXYX: | 
|  | 125 | +    """YXYX contains axis indices for the YXYX format. | 
|  | 126 | +
 | 
|  | 127 | +    All values in the YXYX format should be absolute pixel values. | 
|  | 128 | +
 | 
|  | 129 | +    The YXYX format consists of the following required indices: | 
|  | 130 | +
 | 
|  | 131 | +    - TOP: top of the bounding box | 
|  | 132 | +    - LEFT: left of the bounding box | 
|  | 133 | +    - BOTTOM: bottom of the bounding box | 
|  | 134 | +    - RIGHT: right of the bounding box | 
|  | 135 | +    """ | 
|  | 136 | + | 
|  | 137 | +    TOP = 0 | 
|  | 138 | +    LEFT = 1 | 
|  | 139 | +    BOTTOM = 2 | 
|  | 140 | +    RIGHT = 3 | 
|  | 141 | + | 
|  | 142 | + | 
|  | 143 | +@keras_nlp_export("keras_nlp.bounding_box.REL_YXYX") | 
|  | 144 | +class REL_YXYX: | 
|  | 145 | +    """REL_YXYX contains axis indices for the REL_YXYX format. | 
|  | 146 | +
 | 
|  | 147 | +    REL_YXYX is like YXYX, but each value is relative to the width and height of | 
|  | 148 | +    the origin image. Values are percentages of the origin images' width and | 
|  | 149 | +    height respectively. | 
|  | 150 | +
 | 
|  | 151 | +    The REL_YXYX format consists of the following required indices: | 
|  | 152 | +
 | 
|  | 153 | +    - TOP: top of the bounding box | 
|  | 154 | +    - LEFT: left of the bounding box | 
|  | 155 | +    - BOTTOM: bottom of the bounding box | 
|  | 156 | +    - RIGHT: right of the bounding box | 
|  | 157 | +    """ | 
|  | 158 | + | 
|  | 159 | +    TOP = 0 | 
|  | 160 | +    LEFT = 1 | 
|  | 161 | +    BOTTOM = 2 | 
|  | 162 | +    RIGHT = 3 | 
0 commit comments