add omost.py + omost_flux_example

This commit is contained in:
tc2000731
2024-09-03 19:40:40 +08:00
parent fe485b3fa1
commit 0b066d3cb4
7 changed files with 398 additions and 13 deletions

View File

@@ -195,7 +195,10 @@ def load_model_from_huggingface_folder(file_path, model_names, model_classes, to
model = model_class.from_pretrained(file_path, torch_dtype=torch_dtype).eval()
if torch_dtype == torch.float16 and hasattr(model, "half"):
model = model.half()
model = model.to(device=device)
try:
model = model.to(device=device)
except:
pass
loaded_model_names.append(model_name)
loaded_models.append(model)
return loaded_model_names, loaded_models