Spaces:
Runtime error
Runtime error
Download test_model.py from ksj47/img-classifier: direct link, hf CLI and curl.
- Browser
- Download file 662 Bytes
-
https://huggingface.co/spaces/ksj47/img-classifier/resolve/main/test_model.py
- Command line
-
hf download hf://spaces/ksj47/img-classifier/test_model.py
-
curl -L -o test_model.py https://huggingface.co/spaces/ksj47/img-classifier/resolve/main/test_model.py
662 Bytes
| import torch | |
| import os | |
| # Check if model file exists | |
| model_path = "model.pth" | |
| if os.path.exists(model_path): | |
| print(f"Model file exists at {model_path}") | |
| print(f"File size: {os.path.getsize(model_path)} bytes") | |
| try: | |
| # Try to load the model | |
| model_data = torch.load(model_path, map_location=torch.device('cpu')) | |
| print("Model loaded successfully!") | |
| print(f"Model type: {type(model_data)}") | |
| if isinstance(model_data, dict): | |
| print(f"Model keys: {list(model_data.keys())}") | |
| except Exception as e: | |
| print(f"Error loading model: {e}") | |
| else: | |
| print(f"Model file not found at {model_path}") |