mirror of
https://github.com/yuruotong1/autoMate.git
synced 2026-03-22 13:07:17 +08:00
本地processor
This commit is contained in:
@@ -33,35 +33,19 @@ class VisionAgent:
|
|||||||
|
|
||||||
# load the image caption model and processor
|
# load the image caption model and processor
|
||||||
self.caption_processor = AutoProcessor.from_pretrained(
|
self.caption_processor = AutoProcessor.from_pretrained(
|
||||||
"microsoft/Florence-2-base",
|
"processor",
|
||||||
trust_remote_code=True
|
trust_remote_code=True
|
||||||
)
|
)
|
||||||
|
|
||||||
# load the model according to the device type
|
|
||||||
try:
|
try:
|
||||||
if self.device.type == 'cuda':
|
self.caption_model = AutoModelForCausalLM.from_pretrained(
|
||||||
# CUDA device uses float16
|
caption_model_path,
|
||||||
self.caption_model = AutoModelForCausalLM.from_pretrained(
|
torch_dtype=torch.float32,
|
||||||
caption_model_path,
|
trust_remote_code=True
|
||||||
torch_dtype=torch.float16,
|
).to(self.device)
|
||||||
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)
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
print(f"Model loading failed for path: {caption_model_path}")
|
||||||
raise e
|
raise e
|
||||||
self.prompt = "<CAPTION>"
|
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
Reference in New Issue
Block a user