-
Notifications
You must be signed in to change notification settings - Fork 821
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Formatting * [version] Update to 3.1.0 * Fix jina clip processor * Fix typo * Support partial model inputs for `JinaCLIPModel` * Increase model load test time (avoid timeouts)
- Loading branch information
Showing
14 changed files
with
128 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,26 @@ | ||
import { | ||
import { | ||
ImageProcessor, | ||
} from "../../base/image_processors_utils.js"; | ||
|
||
export class JinaCLIPImageProcessor extends ImageProcessor {} | ||
export class JinaCLIPImageProcessor extends ImageProcessor { | ||
constructor(config) { | ||
// JinaCLIPImageProcessor uses a custom preprocessor_config.json, so we configure it here | ||
const { resize_mode, fill_color, interpolation, size, ...other } = config; | ||
|
||
const new_size = resize_mode === 'squash' | ||
? { width: size, height: size } | ||
: resize_mode === 'shortest' | ||
? { shortest_edge: size } | ||
: { longest_edge: size }; | ||
|
||
const resample = interpolation === 'bicubic' ? 3 : 2; | ||
super({ | ||
...other, | ||
size: new_size, | ||
resample, | ||
do_center_crop: true, | ||
crop_size: size, | ||
do_normalize: true, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
import { Processor } from "../../base/processing_utils.js"; | ||
import { AutoImageProcessor } from "../auto/image_processing_auto.js"; | ||
import { AutoTokenizer } from "../../tokenizers.js"; | ||
|
||
export class JinaCLIPProcessor extends Processor { | ||
static tokenizer_class = AutoTokenizer | ||
static image_processor_class = AutoImageProcessor | ||
|
||
async _call(text=null, images=null, kwargs = {}) { | ||
|
||
if (!text && !images){ | ||
throw new Error('Either text or images must be provided'); | ||
} | ||
|
||
const text_inputs = text ? this.tokenizer(text, kwargs) : {}; | ||
const image_inputs = images ? await this.image_processor(images, kwargs) : {}; | ||
|
||
return { | ||
...text_inputs, | ||
...image_inputs, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters