14
14
use Codewithkyrian \Transformers \Models \Auto \AutoModelForSequenceClassification ;
15
15
use Codewithkyrian \Transformers \Models \Auto \AutoModelForTokenClassification ;
16
16
use Codewithkyrian \Transformers \Models \Auto \AutoModelForVision2Seq ;
17
+ use Codewithkyrian \Transformers \Models \Auto \AutoModelForZeroShotObjectDetection ;
17
18
use Codewithkyrian \Transformers \Models \Pretrained \PretrainedModel ;
18
19
use Codewithkyrian \Transformers \PretrainedTokenizers \AutoTokenizer ;
19
20
use Codewithkyrian \Transformers \PretrainedTokenizers \PretrainedTokenizer ;
@@ -43,6 +44,7 @@ enum Task: string
43
44
case ZeroShotImageClassification = 'zero-shot-image-classification ' ;
44
45
45
46
case ObjectDetection = 'object-detection ' ;
47
+ case ZeroShotObjectDetection = 'zero-shot-object-detection ' ;
46
48
47
49
48
50
public function pipeline (PretrainedModel $ model , ?PretrainedTokenizer $ tokenizer , ?Processor $ processor ): Pipeline
@@ -78,6 +80,8 @@ public function pipeline(PretrainedModel $model, ?PretrainedTokenizer $tokenizer
78
80
self ::ZeroShotImageClassification => new ZeroShotImageClassificationPipeline ($ this , $ model , $ tokenizer , $ processor ),
79
81
80
82
self ::ObjectDetection => new ObjectDetectionPipeline ($ this , $ model , $ tokenizer , $ processor ),
83
+
84
+ self ::ZeroShotObjectDetection => new ZeroShotObjectDetectionPipeline ($ this , $ model , $ tokenizer , $ processor ),
81
85
};
82
86
}
83
87
@@ -112,6 +116,8 @@ public function defaultModelName(): string
112
116
self ::ZeroShotImageClassification => 'Xenova/clip-vit-base-patch32 ' , // Original: 'openai/clip-vit-base-patch32'
113
117
114
118
self ::ObjectDetection => 'Xenova/detr-resnet-50 ' , // Original: 'facebook/detr-resnet-50',
119
+
120
+ self ::ZeroShotObjectDetection => 'Xenova/owlvit-base-patch32 ' , // Original: 'google/owlvit-base-patch32',
115
121
};
116
122
}
117
123
@@ -153,6 +159,8 @@ public function autoModel(
153
159
self ::ZeroShotImageClassification => AutoModel::fromPretrained ($ modelNameOrPath , $ quantized , $ config , $ cacheDir , $ revision , $ modelFilename , $ output ),
154
160
155
161
self ::ObjectDetection => AutoModelForObjectDetection::fromPretrained ($ modelNameOrPath , $ quantized , $ config , $ cacheDir , $ revision , $ modelFilename , $ output ),
162
+
163
+ self ::ZeroShotObjectDetection => AutoModelForZeroShotObjectDetection::fromPretrained ($ modelNameOrPath , $ quantized , $ config , $ cacheDir , $ revision , $ modelFilename , $ output ),
156
164
};
157
165
}
158
166
@@ -185,7 +193,8 @@ public function autoTokenizer(
185
193
self ::TokenClassification,
186
194
self ::Ner,
187
195
self ::ImageToText,
188
- self ::ZeroShotImageClassification => AutoTokenizer::fromPretrained ($ modelNameOrPath , $ quantized , $ config , $ cacheDir , $ revision , null , $ output ),
196
+ self ::ZeroShotImageClassification,
197
+ self ::ZeroShotObjectDetection => AutoTokenizer::fromPretrained ($ modelNameOrPath , $ quantized , $ config , $ cacheDir , $ revision , null , $ output ),
189
198
};
190
199
}
191
200
@@ -202,7 +211,8 @@ public function autoProcessor(
202
211
self ::ImageToText,
203
212
self ::ImageClassification,
204
213
self ::ZeroShotImageClassification,
205
- self ::ObjectDetection => AutoProcessor::fromPretrained ($ modelNameOrPath , $ config , $ cacheDir , $ revision , $ output ),
214
+ self ::ObjectDetection,
215
+ self ::ZeroShotObjectDetection => AutoProcessor::fromPretrained ($ modelNameOrPath , $ config , $ cacheDir , $ revision , $ output ),
206
216
207
217
208
218
self ::SentimentAnalysis,
0 commit comments