Update Example use in README.md
#2
by
laxmareddyp
- opened
README.md
CHANGED
@@ -33,6 +33,30 @@ The following model checkpoints are provided by the Keras team. Full code exampl
|
|
33 |
|------------------------------------|------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
34 |
| deeplab_v3_plus_resnet50_pascalvoc | 39.1M | DeeplabV3Plus with a ResNet50 v2 backbone. Trained on PascalVOC 2012 Semantic segmentation task, which consists of 20 classes and one background class. This model achieves a final categorical accuracy of 89.34% and mIoU of 0.6391 on evaluation dataset. This preset is only comptabile with Keras 3. |
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
## Model paper
|
37 |
|
38 |
https://arxiv.org/abs/1802.02611
|
|
|
33 |
|------------------------------------|------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
34 |
| deeplab_v3_plus_resnet50_pascalvoc | 39.1M | DeeplabV3Plus with a ResNet50 v2 backbone. Trained on PascalVOC 2012 Semantic segmentation task, which consists of 20 classes and one background class. This model achieves a final categorical accuracy of 89.34% and mIoU of 0.6391 on evaluation dataset. This preset is only comptabile with Keras 3. |
|
35 |
|
36 |
+
|
37 |
+
## Example Use
|
38 |
+
|
39 |
+
Load DeepLabv3+ presets a extension of DeepLabv3 by adding a simple yet effective decoder module to refine the segmentation results especially along object boundaries.
|
40 |
+
|
41 |
+
```
|
42 |
+
images = np.ones(shape=(1, 96, 96, 3))
|
43 |
+
labels = np.zeros(shape=(1, 96, 96, 2))
|
44 |
+
segmenter = keras_hub.models.DeepLabV3ImageSegmenter.from_preset(
|
45 |
+
"hf://keras/deeplab_v3_plus_resnet50_pascalvoc",
|
46 |
+
)
|
47 |
+
segmenter.predict(images)
|
48 |
+
```
|
49 |
+
Specify `num_classes` to load randomly initialized segmentation head.
|
50 |
+
|
51 |
+
```
|
52 |
+
segmenter = keras_hub.models.DeepLabV3ImageSegmenter.from_preset(
|
53 |
+
"hf://keras/deeplab_v3_plus_resnet50_pascalvoc",
|
54 |
+
num_classes=2,
|
55 |
+
)
|
56 |
+
segmenter.preprocessor.image_size = (96, 96)
|
57 |
+
segmenter.fit(images, labels, epochs=3)
|
58 |
+
segmenter.predict(images) # Trained 2 class segmentation.
|
59 |
+
```
|
60 |
## Model paper
|
61 |
|
62 |
https://arxiv.org/abs/1802.02611
|