@@ -1398,13 +1398,18 @@ export class PreTrainedModel extends Callable {
13981398 ] ) ;
13991399 } else if ( modelType === MODEL_TYPES . Supertonic ) {
14001400 info = await Promise . all ( [
1401- constructSessions ( pretrained_model_name_or_path , {
1402- text_encoder : 'text_encoder' ,
1403- latent_denoiser : 'latent_denoiser' ,
1404- voice_decoder : 'voice_decoder' ,
1405- } , options ) ,
1401+ constructSessions (
1402+ pretrained_model_name_or_path ,
1403+ {
1404+ text_encoder : 'text_encoder' ,
1405+ latent_denoiser : 'latent_denoiser' ,
1406+ voice_decoder : 'voice_decoder' ,
1407+ } ,
1408+ options ,
1409+ ) ,
14061410 ] ) ;
1407- } else { // should be MODEL_TYPES.EncoderOnly
1411+ } else {
1412+ // should be MODEL_TYPES.EncoderOnly
14081413 if ( modelType !== MODEL_TYPES . EncoderOnly ) {
14091414 const type = modelName ?? config ?. model_type ;
14101415 if ( type !== 'custom' ) {
@@ -6141,8 +6146,8 @@ export class SamModel extends SamPreTrainedModel {
61416146 // Compute the image embeddings if they are missing
61426147 model_inputs = {
61436148 ...model_inputs ,
6144- ...( await this . get_image_embeddings ( model_inputs ) )
6145- }
6149+ ...( await this . get_image_embeddings ( model_inputs ) ) ,
6150+ } ;
61466151 } else {
61476152 model_inputs = { ...model_inputs } ;
61486153 }
@@ -6213,9 +6218,8 @@ export class Sam2ImageSegmentationOutput extends ModelOutput {
62136218 }
62146219}
62156220
6216- export class Sam2PreTrainedModel extends PreTrainedModel { }
6221+ export class Sam2PreTrainedModel extends PreTrainedModel { }
62176222export class Sam2Model extends Sam2PreTrainedModel {
6218-
62196223 /**
62206224 * Compute image embeddings and positional image embeddings, given the pixel values of an image.
62216225 * @param {Object } model_inputs Object containing the model inputs.
@@ -6225,7 +6229,7 @@ export class Sam2Model extends Sam2PreTrainedModel {
62256229 async get_image_embeddings ( { pixel_values } ) {
62266230 // in:
62276231 // - pixel_values: tensor.float32[batch_size,3,1024,1024]
6228- //
6232+ //
62296233 // out:
62306234 // - image_embeddings.0: tensor.float32[batch_size,32,256,256]
62316235 // - image_embeddings.1: tensor.float32[batch_size,64,128,128]
@@ -6238,29 +6242,30 @@ export class Sam2Model extends Sam2PreTrainedModel {
62386242 const { num_feature_levels } = this . config . vision_config ;
62396243 const image_embeddings_name = Array . from ( { length : num_feature_levels } , ( _ , i ) => `image_embeddings.${ i } ` ) ;
62406244
6241- if ( image_embeddings_name . some ( name => ! model_inputs [ name ] ) ) {
6245+ if ( image_embeddings_name . some ( ( name ) => ! model_inputs [ name ] ) ) {
62426246 // Compute the image embeddings if they are missing
62436247 model_inputs = {
62446248 ...model_inputs ,
6245- ...( await this . get_image_embeddings ( model_inputs ) )
6246- }
6249+ ...( await this . get_image_embeddings ( model_inputs ) ) ,
6250+ } ;
62476251 } else {
62486252 model_inputs = { ...model_inputs } ;
62496253 }
62506254
62516255 if ( model_inputs . input_points ) {
62526256 if ( model_inputs . input_boxes && model_inputs . input_boxes . dims [ 1 ] !== 1 ) {
6253- throw new Error ( 'When both `input_points` and `input_boxes` are provided, the number of boxes per image must be 1.' ) ;
6257+ throw new Error (
6258+ 'When both `input_points` and `input_boxes` are provided, the number of boxes per image must be 1.' ,
6259+ ) ;
62546260 }
62556261 const shape = model_inputs . input_points . dims ;
62566262 model_inputs . input_labels ??= ones ( shape . slice ( 0 , - 1 ) ) ;
62576263 model_inputs . input_boxes ??= full ( [ shape [ 0 ] , 0 , 4 ] , 0.0 ) ;
6258-
6259- } else if ( model_inputs . input_boxes ) { // only boxes
6264+ } else if ( model_inputs . input_boxes ) {
6265+ // only boxes
62606266 const shape = model_inputs . input_boxes . dims ;
62616267 model_inputs . input_labels = full ( [ shape [ 0 ] , shape [ 1 ] , 0 ] , - 1n ) ;
62626268 model_inputs . input_points = full ( [ shape [ 0 ] , 1 , 0 , 2 ] , 0.0 ) ;
6263-
62646269 } else {
62656270 throw new Error ( 'At least one of `input_points` or `input_boxes` must be provided.' ) ;
62666271 }
@@ -6284,11 +6289,10 @@ export class Sam2Model extends Sam2PreTrainedModel {
62846289 return new Sam2ImageSegmentationOutput ( await super . _call ( model_inputs ) ) ;
62856290 }
62866291}
6287- export class EdgeTamModel extends Sam2Model { } // NOTE: extends Sam2Model
6288- export class Sam3TrackerModel extends Sam2Model { } // NOTE: extends Sam2Model
6292+ export class EdgeTamModel extends Sam2Model { } // NOTE: extends Sam2Model
6293+ export class Sam3TrackerModel extends Sam2Model { } // NOTE: extends Sam2Model
62896294//////////////////////////////////////////////////
62906295
6291-
62926296//////////////////////////////////////////////////
62936297// MarianMT models
62946298export class MarianPreTrainedModel extends PreTrainedModel { }
@@ -6985,9 +6989,8 @@ export class SpeechT5HifiGan extends PreTrainedModel {
69856989}
69866990//////////////////////////////////////////////////
69876991
6988- export class SupertonicPreTrainedModel extends PreTrainedModel { }
6992+ export class SupertonicPreTrainedModel extends PreTrainedModel { }
69896993export class SupertonicForConditionalGeneration extends SupertonicPreTrainedModel {
6990-
69916994 async generate_speech ( {
69926995 // Required inputs
69936996 input_ids,
@@ -7003,7 +7006,9 @@ export class SupertonicForConditionalGeneration extends SupertonicPreTrainedMode
70037006
70047007 // 1. Text Encoder
70057008 const { last_hidden_state, durations } = await sessionRun ( this . sessions [ 'text_encoder' ] , {
7006- input_ids, attention_mask, style,
7009+ input_ids,
7010+ attention_mask,
7011+ style,
70077012 } ) ;
70087013 durations . div_ ( speed ) ; // Apply speed factor to duration
70097014
@@ -7036,11 +7041,10 @@ export class SupertonicForConditionalGeneration extends SupertonicPreTrainedMode
70367041 return {
70377042 waveform,
70387043 durations,
7039- }
7044+ } ;
70407045 }
70417046}
70427047
7043-
70447048//////////////////////////////////////////////////
70457049// TrOCR models
70467050export class TrOCRPreTrainedModel extends PreTrainedModel { }
0 commit comments