【发布时间】:2021-08-14 18:57:21
【问题描述】:
我想从 S3 存储桶加载 pytorch 模型 (model.pt)。我写了以下代码:
from smart_open import open as smart_open
import io
load_path = "s3://serial-no-images/yolo-models/model4/model.pt"
with smart_open(load_path) as f:
buffer = io.BytesIO(f.read())
model.load_state_dict(torch.load(buffer))
这会导致以下错误:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 64: invalid start byte
一种解决方案是在本地下载模型,但我想避免这种情况并直接从 S3 加载模型。不幸的是,我在网上找不到一个好的解决方案。有人可以帮我吗?
【问题讨论】: