Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
曾经的那一瞬间
Models
提交
284d7783
M
Models
项目概览
曾经的那一瞬间
/
Models
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
Models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
284d7783
编写于
10月 27, 2020
作者:
A
Abdullah Rashwan
提交者:
A. Unique TensorFlower
10月 27, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Internal change
PiperOrigin-RevId: 339275945
上级
05a95e16
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
20 addition
and
16 deletion
+20
-16
official/vision/beta/configs/semantic_segmentation.py
official/vision/beta/configs/semantic_segmentation.py
+8
-8
official/vision/beta/configs/semantic_segmentation_test.py
official/vision/beta/configs/semantic_segmentation_test.py
+2
-2
official/vision/beta/modeling/factory.py
official/vision/beta/modeling/factory.py
+1
-1
official/vision/beta/tasks/semantic_segmentation.py
official/vision/beta/tasks/semantic_segmentation.py
+9
-5
未找到文件。
official/vision/beta/configs/semantic_segmentation.py
浏览文件 @
284d7783
...
...
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""
Image
segmentation configuration definition."""
"""
Semantic
segmentation configuration definition."""
import
os
from
typing
import
List
,
Union
,
Optional
import
dataclasses
...
...
@@ -50,8 +50,8 @@ class SegmentationHead(hyperparams.Config):
@
dataclasses
.
dataclass
class
Image
SegmentationModel
(
hyperparams
.
Config
):
"""
Image
segmentation model config."""
class
Semantic
SegmentationModel
(
hyperparams
.
Config
):
"""
Semantic
segmentation model config."""
num_classes
:
int
=
0
input_size
:
List
[
int
]
=
dataclasses
.
field
(
default_factory
=
list
)
min_level
:
int
=
3
...
...
@@ -73,9 +73,9 @@ class Losses(hyperparams.Config):
@
dataclasses
.
dataclass
class
Image
SegmentationTask
(
cfg
.
TaskConfig
):
class
Semantic
SegmentationTask
(
cfg
.
TaskConfig
):
"""The model config."""
model
:
ImageSegmentationModel
=
Image
SegmentationModel
()
model
:
SemanticSegmentationModel
=
Semantic
SegmentationModel
()
train_data
:
DataConfig
=
DataConfig
(
is_training
=
True
)
validation_data
:
DataConfig
=
DataConfig
(
is_training
=
False
)
losses
:
Losses
=
Losses
()
...
...
@@ -89,7 +89,7 @@ class ImageSegmentationTask(cfg.TaskConfig):
def
semantic_segmentation
()
->
cfg
.
ExperimentConfig
:
"""Semantic segmentation general."""
return
cfg
.
ExperimentConfig
(
task
=
Image
SegmentationModel
(),
task
=
Semantic
SegmentationModel
(),
trainer
=
cfg
.
TrainerConfig
(),
restrictions
=
[
'task.train_data.is_training != None'
,
...
...
@@ -109,8 +109,8 @@ def seg_deeplabv3_pascal() -> cfg.ExperimentConfig:
eval_batch_size
=
8
steps_per_epoch
=
PASCAL_TRAIN_EXAMPLES
//
train_batch_size
config
=
cfg
.
ExperimentConfig
(
task
=
Image
SegmentationTask
(
model
=
Image
SegmentationModel
(
task
=
Semantic
SegmentationTask
(
model
=
Semantic
SegmentationModel
(
num_classes
=
21
,
# TODO(arashwan): test changing size to 513 to match deeplab.
input_size
=
[
512
,
512
,
3
],
...
...
official/vision/beta/configs/semantic_segmentation_test.py
浏览文件 @
284d7783
...
...
@@ -31,9 +31,9 @@ class ImageSegmentationConfigTest(tf.test.TestCase, parameterized.TestCase):
def
test_semantic_segmentation_configs
(
self
,
config_name
):
config
=
exp_factory
.
get_exp_config
(
config_name
)
self
.
assertIsInstance
(
config
,
cfg
.
ExperimentConfig
)
self
.
assertIsInstance
(
config
.
task
,
exp_cfg
.
Image
SegmentationTask
)
self
.
assertIsInstance
(
config
.
task
,
exp_cfg
.
Semantic
SegmentationTask
)
self
.
assertIsInstance
(
config
.
task
.
model
,
exp_cfg
.
Image
SegmentationModel
)
exp_cfg
.
Semantic
SegmentationModel
)
self
.
assertIsInstance
(
config
.
task
.
train_data
,
exp_cfg
.
DataConfig
)
config
.
task
.
train_data
.
is_training
=
None
with
self
.
assertRaises
(
KeyError
):
...
...
official/vision/beta/modeling/factory.py
浏览文件 @
284d7783
...
...
@@ -241,7 +241,7 @@ def build_retinanet(input_specs: tf.keras.layers.InputSpec,
def
build_segmentation_model
(
input_specs
:
tf
.
keras
.
layers
.
InputSpec
,
model_config
:
segmentation_cfg
.
Image
SegmentationModel
,
model_config
:
segmentation_cfg
.
Semantic
SegmentationModel
,
l2_regularizer
:
tf
.
keras
.
regularizers
.
Regularizer
=
None
):
"""Builds Segmentation model."""
backbone
=
backbones
.
factory
.
build_backbone
(
...
...
official/vision/beta/tasks/semantic_segmentation.py
浏览文件 @
284d7783
...
...
@@ -28,9 +28,9 @@ from official.vision.beta.losses import segmentation_losses
from
official.vision.beta.modeling
import
factory
@
task_factory
.
register_task_cls
(
exp_cfg
.
Image
SegmentationTask
)
class
Image
SegmentationTask
(
base_task
.
Task
):
"""A task for
image
classification."""
@
task_factory
.
register_task_cls
(
exp_cfg
.
Semantic
SegmentationTask
)
class
Semantic
SegmentationTask
(
base_task
.
Task
):
"""A task for
semantic
classification."""
def
build_model
(
self
):
"""Builds classification model."""
...
...
@@ -219,8 +219,12 @@ class ImageSegmentationTask(base_task.Task):
outputs
=
self
.
inference_step
(
features
,
model
)
outputs
=
tf
.
nest
.
map_structure
(
lambda
x
:
tf
.
cast
(
x
,
tf
.
float32
),
outputs
)
loss
=
self
.
build_losses
(
model_outputs
=
outputs
,
labels
=
labels
,
aux_losses
=
model
.
losses
)
if
self
.
task_config
.
validation_data
.
resize_eval_groundtruth
:
loss
=
self
.
build_losses
(
model_outputs
=
outputs
,
labels
=
labels
,
aux_losses
=
model
.
losses
)
else
:
loss
=
0
logs
=
{
self
.
loss
:
loss
}
logs
.
update
({
self
.
miou_metric
.
name
:
(
labels
,
outputs
)})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录