mergify[bot] on master
feat(torch): add multilabel cla… (compare)
x/detection$ ls -al model/train.lmdb/
total 29932
drwxr--r-- 2 dgtlmoon dgtlmoon 4096 Feb 4 17:10 .
drwxrwxrwx 3 dgtlmoon dgtlmoon 4096 Feb 4 17:10 ..
-rw-r--r-- 1 dgtlmoon dgtlmoon 30638080 Feb 4 17:10 data.mdb
-rw-r--r-- 1 dgtlmoon dgtlmoon 8192 Feb 4 17:10 lock.mdb
looks atleast like its writing, I'm nuking that dir when i create the service, so these are always fresh
train.lmdb/data.mdb
is created without problem brand new every time, and THEN the segfault happens
curl -X POST "http://localhost:8080/train" -d '
{
"service": "location",
"async": true,
"parameters": {
"input": {
"db": true,
"db_width": 512,
"db_height": 512,
"width": 300,
"height": 300
},
"mllib": {
"resume": false,
"net": {
"batch_size": 20,
"test_batch_size": 12
},
"solver": {
"iterations": 50000,
"test_interval": 500,
"snapshot": 1000,
"base_lr": 0.0001
},
"bbox": true
},
"output": {
"measure": [
"map"
]
}
},
"data": [ "/tags_dataset/bottom/bottom-images.txt" ]
}
'
caffe
for absolutely no reason than that's whats in the examples, maybe I should try torch? (trying squeezenet object detector here)
couldn't write model.json file in model repository
... when loading, but classifications seem to work fine. Can this message be disregarded in this case?
mllib internal error: Libtorch error:The following operation failed in the TorchScript interpreter.
Traceback of TorchScript, serialized code (most recent call last):
File "code/__torch__.py", line 12, in forward
model = self.model
transforms = self.transforms
input = torch.unsqueeze((transforms).forward(x, ), 0)
~~~~~~~~~~~~~~~~~~~ <--- HERE
return (model).forward(input, )
File "code/__torch__/torch/nn/modules/container.py", line 12, in forward
_1 = getattr(self, "1")
_0 = getattr(self, "0")
return (_1).forward((_0).forward(x, ), )
~~~~~~~~~~~ <--- HERE
File "code/__torch__/torchvision/transforms/transforms.py", line 10, in forward
img = torch.unsqueeze(x, 0)
input = torch.to(img, 6)
img0 = torch.upsample_bilinear2d(input, [299, 299], False, None)
~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
img1 = torch.squeeze(img0, 0)
img2 = torch.round(img1)
Traceback of TorchScript, original code (most recent call last):
/usr/local/lib/python3.7/dist-packages/torch/nn/functional.py(3919): interpolate
/usr/local/lib/python3.7/dist-packages/torchvision/transforms/functional_tensor.py(490): resize
/usr/local/lib/python3.7/dist-packages/torchvision/transforms/functional.py(438): resize
/usr/local/lib/python3.7/dist-packages/torchvision/transforms/transforms.py(349): forward
/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py(1098): _slow_forward
/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py(1110): _call_impl
/usr/local/lib/python3.7/dist-packages/torch/nn/modules/container.py(141): forward
/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py(1098): _slow_forward
/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py(1110): _call_impl
<ipython-input-3-4afab89cb121>(19): forward
/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py(1098): _slow_forward
/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py(1110): _call_impl
/usr/local/lib/python3.7/dist-packages/torch/jit/_trace.py(965): trace_module
/usr/local/lib/python3.7/dist-packages/torch/jit/_trace.py(750): trace
<ipython-input-10-1646f9ee17ed>(5): <module>
/usr/local/lib/python3.7/dist-packages/IPython/core/interactiveshell.py(2882): run_code
/usr/local/lib/python3.7/dist-packages/IPython/core/interactiveshell.py(2822): run_ast_nodes
/usr/local/lib/python3.7/dist-packages/IPython/core/interactiveshell.py(2718): run_cell
/usr/local/lib/python3.7/dist-packages/ipykernel/zmqshell.py(537): run_cell
/usr/local/lib/python3.7/dist-packages/ipykernel/ipkernel.py(208): do_execute
/usr/local/lib/python3.7/dist-packages/ipykernel/kernelbase.py(399): execute_request
/usr/local/lib/python3.7/dist-packages/ipykernel/kernelbase.py(233): dispatch_shell
/usr/local/lib/python3.7/dist-packages/ipykernel/kernelbase.py(283): dispatcher
/usr/local/lib/python3.7/dist-packages/tornado/stack_context.py(300): null_wrapper
/usr/local/lib/python3.7/dist-packages/zmq/eventloop/zmqstream.py(556): _run_callback
/usr/local/lib/python3.7/dist-packages/zmq/eventloop/zmqstream.py(606): _handle_recv
/usr/local/lib/python3.7/dist-packages/zmq/eventloop/zmqstream.py(577): _handle_events
/usr/local/lib/python3.7/dist-packages/tornado/stack_context.py(300): null_wrapper
/usr/local/lib/python3.7/dist-packages/tornado/platform/asyncio.py(122): _handle_events
/usr/lib/python3.7/asyncio/events.py(88): _run
/usr/lib/python3.7/asyncio/base_events.py(1786): _run_once
/usr/lib/python3.7/asyncio/base_events.py(541): run_forever
/usr/local/lib/python3.7/dist-packages/tornado/platform/asyncio.py(132): start
/usr/local/lib/python3.7/dist-packages/ipykernel/kernelapp.py(499): start
/usr/local/lib/python3.7/dist-packages/traitlets/config/application.py(846): launch_instance
/usr/local/lib/python3.7/dist-packages/ipykernel_launcher.py(16): <module>
/usr/lib/python3.7/runpy.py(85): _run_code
/usr/lib/python3.7/runpy.py(193): _run_module_as_main
RuntimeError: It is expected input_size equals to 4, but got size 5
torch::jit::script::Module module;
module = torch::jit::load(argv[1]);
cv::Mat img = cv::imread(argv[2]);
cv::cvtColor(img, img, cv::COLOR_BGR2RGB);
at::Tensor tensor_image = torch::from_blob(img.data, { img.rows, img.cols, img.channels() }, at::kByte);
tensor_image = tensor_image.to(at::kFloat);
tensor_image = tensor_image.permute({ 2, 0, 1 });
at::Tensor output = module.forward({tensor_image}).toTensor();
tensor.dim()
?
in_vals[0].dim()
at https://github.com/jolibrain/deepdetect/blob/master/src/backends/torch/torchlib.cc#L1472
source
std::vector
source
was the batch, not source[0]
?
at::Tensor output = module.forward({tensor_image}).toTensor();
where tensor_image
has size [3, 299, 299]
and so .forward()
is being passed a vector where the first and only element is [3,299,299]
in python my model had this forward()
method:
def forward(self, x: torch.Tensor) -> torch.Tensor:
with torch.no_grad():
x = torch.unsqueeze(self.transforms(x), 0)
y_pred = self.model(x)
return y_pred
so do I need to rewrite that to accept a batch of Tensors as input?