try to fix model path bug

This commit is contained in:
Adam Wilson
2025-05-19 12:25:23 -06:00
parent 505515411c
commit 2c153206c3
+18
View File
@@ -38,6 +38,24 @@ class Phi3LanguageModel:
model_path = os.path.join(base_dir, "cpu_and_mobile", "cpu-int4-rtn-block-32-acc-level-4")
print(f"Loading Phi-3 model from: {model_path}")
# List and print the contents of the model_path directory
print(f"Listing contents of model directory: {model_path}")
try:
files = os.listdir(model_path)
for i, file in enumerate(files):
file_path = os.path.join(model_path, file)
file_size = os.path.getsize(file_path)
is_dir = os.path.isdir(file_path)
file_type = "dir" if is_dir else "file"
print(f"{i+1:2d}. {file:50s} [{file_type}] {file_size:,} bytes")
print(f"Total: {len(files)} items found")
except FileNotFoundError:
print(f"ERROR: Directory {model_path} not found!")
except PermissionError:
print(f"ERROR: Permission denied when accessing {model_path}")
except Exception as e:
print(f"ERROR: Unexpected error when listing directory: {str(e)}")
# Load the tokenizer and model
tokenizer = AutoTokenizer.from_pretrained(
pretrained_model_name_or_path=model_path,