mirror of
https://github.com/yuruotong1/autoMate.git
synced 2025-12-26 05:16:21 +08:00
本地processor
This commit is contained in:
parent
b778dcc87d
commit
9c5ede79b1
@ -33,35 +33,19 @@ class VisionAgent:
|
||||
|
||||
# load the image caption model and processor
|
||||
self.caption_processor = AutoProcessor.from_pretrained(
|
||||
"microsoft/Florence-2-base",
|
||||
"processor",
|
||||
trust_remote_code=True
|
||||
)
|
||||
|
||||
# load the model according to the device type
|
||||
try:
|
||||
if self.device.type == 'cuda':
|
||||
# CUDA device uses float16
|
||||
self.caption_model = AutoModelForCausalLM.from_pretrained(
|
||||
caption_model_path,
|
||||
torch_dtype=torch.float16,
|
||||
trust_remote_code=True
|
||||
).to(self.device)
|
||||
elif self.device.type == 'mps':
|
||||
# MPS device uses float32 (MPS has limited support for float16)
|
||||
self.caption_model = AutoModelForCausalLM.from_pretrained(
|
||||
caption_model_path,
|
||||
torch_dtype=torch.float32,
|
||||
trust_remote_code=True
|
||||
).to(self.device)
|
||||
else:
|
||||
# CPU uses float32
|
||||
self.caption_model = AutoModelForCausalLM.from_pretrained(
|
||||
caption_model_path,
|
||||
torch_dtype=torch.float32,
|
||||
trust_remote_code=True
|
||||
).to(self.device)
|
||||
self.caption_model = AutoModelForCausalLM.from_pretrained(
|
||||
caption_model_path,
|
||||
torch_dtype=torch.float32,
|
||||
trust_remote_code=True
|
||||
).to(self.device)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Model loading failed for path: {caption_model_path}")
|
||||
raise e
|
||||
self.prompt = "<CAPTION>"
|
||||
|
||||
|
||||
1026
processor/added_tokens.json
Normal file
1026
processor/added_tokens.json
Normal file
File diff suppressed because it is too large
Load Diff
50001
processor/merges.txt
Normal file
50001
processor/merges.txt
Normal file
File diff suppressed because it is too large
Load Diff
33
processor/preprocessor_config.json
Normal file
33
processor/preprocessor_config.json
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
"auto_map": {
|
||||
"AutoProcessor": "microsoft/Florence-2-base--processing_florence2.Florence2Processor"
|
||||
},
|
||||
"crop_size": {
|
||||
"height": 768,
|
||||
"width": 768
|
||||
},
|
||||
"do_center_crop": false,
|
||||
"do_convert_rgb": null,
|
||||
"do_normalize": true,
|
||||
"do_rescale": true,
|
||||
"do_resize": true,
|
||||
"image_mean": [
|
||||
0.485,
|
||||
0.456,
|
||||
0.406
|
||||
],
|
||||
"image_processor_type": "CLIPImageProcessor",
|
||||
"image_seq_length": 577,
|
||||
"image_std": [
|
||||
0.229,
|
||||
0.224,
|
||||
0.225
|
||||
],
|
||||
"processor_class": "Florence2Processor",
|
||||
"resample": 3,
|
||||
"rescale_factor": 0.00392156862745098,
|
||||
"size": {
|
||||
"height": 768,
|
||||
"width": 768
|
||||
}
|
||||
}
|
||||
7185
processor/special_tokens_map.json
Normal file
7185
processor/special_tokens_map.json
Normal file
File diff suppressed because it is too large
Load Diff
259573
processor/tokenizer.json
Normal file
259573
processor/tokenizer.json
Normal file
File diff suppressed because it is too large
Load Diff
9277
processor/tokenizer_config.json
Normal file
9277
processor/tokenizer_config.json
Normal file
File diff suppressed because it is too large
Load Diff
1
processor/vocab.json
Normal file
1
processor/vocab.json
Normal file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user