MCPcopy Create free account
hub / github.com/Hunyuan-PromptEnhancer/PromptEnhancer / __init__

Method __init__

inference/app.py:27–46  ·  view source on GitHub ↗
(self, models_root_path, device_map="auto", torch_dtype="bfloat16")

Source from the content-addressed store, hash-verified

25
26class PromptEnhancerV2:
27 def __init__(self, models_root_path, device_map="auto", torch_dtype="bfloat16"):
28 if not logging.getLogger(__name__).handlers:
29 logging.basicConfig(level=logging.INFO)
30 self.logger = logging.getLogger(__name__)
31
32 # dtype 兼容处理
33 if torch_dtype == "bfloat16":
34 dtype = torch.bfloat16
35 elif torch_dtype == "float16":
36 dtype = torch.float16
37 else:
38 dtype = torch.float32
39
40 self.model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
41 models_root_path,
42 torch_dtype=dtype,
43 attn_implementation="flash_attention_2",
44 device_map=device_map,
45 )
46 self.processor = AutoProcessor.from_pretrained(models_root_path)
47
48 @torch.inference_mode()
49 def predict(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected