在 Pytorch 中,我知道某些图像处理转换可以这样组成:
import torchvision.transforms as transforms
transform = transforms.Compose([transforms.ToTensor(),
transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])
就我而言,每个图像都有相应的 YOLO 格式的边界框坐标注释。Pytorch 是否也允许将这些转换应用于图像的边界框坐标,然后将它们保存为新注释?谢谢。
每次发生错误/异常时,我一直尝试.log从 python 发送一个“”文件附件到哨兵,但到目前为止没有成功。Sentry不提供python的附件文档,所以我一直在阅读java附件示例(https://docs.sentry.io/platforms/java/enriching-events/attachments/),这是
import io.sentry.Sentry;
import io.sentry.Attachment;
Attachment fileAttachment = new Attachment("your/path/file.log");
// Global Scope
Sentry.configureScope(scope -> {
scope.addAttachment(fileAttachment);
});
// Clear all attachments in the global Scope
Sentry.configureScope(scope -> {
scope.clearAttachments();
});
// Local Scope
Sentry.withScope(scope -> {
scope.addAttachment(fileAttachment);
Sentry.captureMessage("my message");
});
Run Code Online (Sandbox Code Playgroud)
尝试使用sentry_sdk( https://github.com/getsentry/sentry-python/tree/master/sentry_sdk)在python中进行类似的转换,我的代码是:
from sentry_sdk.scope import Scope
from sentry_sdk import configure_scope, push_scope
scope=Scope()
configure_scope(lambda scope: scope.add_attachment(path="sentry.log"))
push_scope(lambda scope: scope.add_attachment(path="sentry.log"))
Run Code Online (Sandbox Code Playgroud)
ps 在 python 中,Attachment()对象是在内部创建的scope.add_attachment(),因此不需要显式赋值。我也尝试过push_scope()但是没有太大效果。
对此问题的任何帮助表示赞赏。
我正在寻找替代方案
pip install -r requirements.txt
Run Code Online (Sandbox Code Playgroud)
可用于从 python 模块安装包。我用过了
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
Run Code Online (Sandbox Code Playgroud)
但是,对于安装软件包,此命令似乎仅适用于单个软件包。提前致谢。任何帮助表示赞赏。