Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix FutureWarning in torch.load, since torch 2.3.1 #1294

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion easyocr/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def get_detector(trained_model, device='cpu', quantize=True, cudnn_benchmark=Fal
except:
pass
else:
net.load_state_dict(copyStateDict(torch.load(trained_model, map_location=device)))
net.load_state_dict(copyStateDict(torch.load(trained_model, map_location=device, weights_only=True)))
net = torch.nn.DataParallel(net).to(device)
cudnn.benchmark = cudnn_benchmark

Expand Down
2 changes: 1 addition & 1 deletion easyocr/recognition.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def get_recognizer(recog_network, network_params, character,\
pass
else:
model = torch.nn.DataParallel(model).to(device)
model.load_state_dict(torch.load(model_path, map_location=device))
model.load_state_dict(torch.load(model_path, map_location=device, weights_only=True))

return model, converter

Expand Down
2 changes: 1 addition & 1 deletion unit_test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This module can be used as a typical python module. One python wrapper script an
### Python script (*recommneded*)
The script can be called with (assuming calling from `EasyOCR/`);
```
python ./unit_test/run_unit_test.py --easyocr ./easyocr --verbose 2 --test ./unit_test/EasyOcrUnitTestPackage.pickle --data_dir ./examples
python ./unit_test/run_unit_test.py --easyocr ./easyocr --verbose 2 --test_data ./unit_test/data/EasyOcrUnitTestPackage.pickle --image_data_dir ./examples
```

#### Script arguments
Expand Down