Commit 84a6b66
authored
Only load a full task config when
* Only load a full task config when `load_task` is passed
This switches the way we load task configuration and "head weights"
to better accommodate upcoming vision models.
For many vision models, like resnet trained on imagenet, or
deeplabv3, we have head weights that some users may want but others
will not. We need to add an option for loading head weights.
With this change, we will be able to do the following...
```python
classifier = ImageClassifier.from_preset("resnet50", num_classes=2)
classifier = ImageClassifier.from_preset("resnet50", load_task=True)
```
We could do this other ways as well, or flip the default, but I think
we need to add an option to control wether to load just the backbone
with random weights, or loading the full task.
* Try changing the name of the argument
* Address review commentsload_task_extras is passed (keras-team#1812)1 parent a806571 commit 84a6b66
File tree
5 files changed
+108
-65
lines changed- keras_nlp/src
- models
- utils
5 files changed
+108
-65
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| 92 | + | |
92 | 93 | | |
93 | 94 | | |
94 | 95 | | |
| |||
112 | 113 | | |
113 | 114 | | |
114 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
115 | 119 | | |
116 | 120 | | |
117 | 121 | | |
| |||
138 | 142 | | |
139 | 143 | | |
140 | 144 | | |
141 | | - | |
| 145 | + | |
142 | 146 | | |
143 | 147 | | |
144 | 148 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
35 | 39 | | |
36 | | - | |
37 | | - | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| |||
80 | 82 | | |
81 | 83 | | |
82 | 84 | | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
90 | 88 | | |
91 | 89 | | |
92 | | - | |
| 90 | + | |
93 | 91 | | |
94 | | - | |
| 92 | + | |
| 93 | + | |
95 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
96 | 98 | | |
97 | | - | |
| 99 | + | |
98 | 100 | | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
| 101 | + | |
| 102 | + | |
104 | 103 | | |
105 | 104 | | |
106 | 105 | | |
107 | 106 | | |
108 | 107 | | |
109 | 108 | | |
110 | 109 | | |
111 | | - | |
112 | | - | |
113 | | - | |
| 110 | + | |
| 111 | + | |
114 | 112 | | |
115 | 113 | | |
116 | 114 | | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
| 115 | + | |
121 | 116 | | |
122 | | - | |
123 | | - | |
124 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| 149 | + | |
149 | 150 | | |
150 | 151 | | |
151 | 152 | | |
| |||
171 | 172 | | |
172 | 173 | | |
173 | 174 | | |
174 | | - | |
175 | | - | |
176 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
177 | 182 | | |
178 | 183 | | |
179 | 184 | | |
| |||
201 | 206 | | |
202 | 207 | | |
203 | 208 | | |
204 | | - | |
| 209 | + | |
205 | 210 | | |
206 | 211 | | |
207 | 212 | | |
208 | 213 | | |
209 | 214 | | |
210 | | - | |
| 215 | + | |
| 216 | + | |
211 | 217 | | |
212 | 218 | | |
213 | 219 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 113 | + | |
| 114 | + | |
116 | 115 | | |
117 | 116 | | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
129 | 123 | | |
130 | 124 | | |
131 | 125 | | |
| |||
138 | 132 | | |
139 | 133 | | |
140 | 134 | | |
141 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
142 | 138 | | |
143 | 139 | | |
144 | 140 | | |
145 | | - | |
146 | | - | |
147 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
148 | 159 | | |
149 | 160 | | |
150 | 161 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
656 | 656 | | |
657 | 657 | | |
658 | 658 | | |
659 | | - | |
| 659 | + | |
660 | 660 | | |
661 | 661 | | |
662 | 662 | | |
| |||
671 | 671 | | |
672 | 672 | | |
673 | 673 | | |
674 | | - | |
| 674 | + | |
| 675 | + | |
675 | 676 | | |
676 | 677 | | |
677 | 678 | | |
678 | | - | |
| 679 | + | |
679 | 680 | | |
680 | 681 | | |
681 | 682 | | |
| |||
704 | 705 | | |
705 | 706 | | |
706 | 707 | | |
707 | | - | |
| 708 | + | |
708 | 709 | | |
709 | 710 | | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
710 | 715 | | |
711 | | - | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
712 | 722 | | |
713 | 723 | | |
714 | | - | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
715 | 729 | | |
716 | 730 | | |
717 | 731 | | |
718 | 732 | | |
719 | 733 | | |
720 | | - | |
721 | 734 | | |
| 735 | + | |
722 | 736 | | |
723 | 737 | | |
| 738 | + | |
| 739 | + | |
724 | 740 | | |
725 | 741 | | |
726 | 742 | | |
727 | 743 | | |
728 | | - | |
729 | | - | |
730 | | - | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
731 | 747 | | |
732 | | - | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
733 | 754 | | |
734 | 755 | | |
735 | | - | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
736 | 761 | | |
737 | 762 | | |
738 | 763 | | |
| |||
0 commit comments