Thanks this sort of worked, but now new problems arise.
I followed the solutions for vision in the inference tutorials and am able to predict different classes of boats from single images from the test set. However, images from a test_set folder returns only one class.
Have a look at the inference section in my gist-notebook
I am facing the same issue, i am getting image class as 0 using learn,get_preds(),however my class range is 1-5.Please suggest solution to incorrect class prediction .
@sariabod-For test test prediction we have to create new data using databunch and instead of valid we have replace Test folder in the argument.then learn.data=new data ,finally we can make prediction on that using your code.This was suggested in this Forum .But Still Its not working .Prediction for test class labels is not supported directly in fastai.
For my image classification problem with 5 classes below code worked with the help of your link .
preds,_ = learn.get_preds(ds_type=DatasetType.Test)
labels = np.argmax(preds, 1)
test_predictions_direct = [data.classes[int(x)] for x in labels]
I downloaded your code from AV competition and ran the above code , but I am stuck at these lines of code.
all_test_preds = []
for i in range(1, 3+1):
learn.load(‘stage-’ + str(i))
learn.model.eval();
probs, y = learn.get_preds(ds_type=DatasetType.Test);
all_test_preds.append(probs.numpy());
final = [data.classes[i] for i in np.argmax(np.mean(all_test_preds, 0), axis=1)]
This is the error am getting.
Traceback (most recent call last):
File “/usr/lib/python3.6/multiprocessing/queues.py”, line 240, in _feed
send_bytes(obj)
File “/usr/lib/python3.6/multiprocessing/connection.py”, line 200, in send_bytes
self._send_bytes(m[offset:offset + size])
File “/usr/lib/python3.6/multiprocessing/connection.py”, line 404, in _send_bytes
self._send(header + buf)
File “/usr/lib/python3.6/multiprocessing/connection.py”, line 368, in _send
n = write(self._handle, buf)
OSError: [Errno 9] Bad file descriptor
Traceback (most recent call last):
File “/usr/lib/python3.6/multiprocessing/queues.py”, line 230, in _feed
close()
File “/usr/lib/python3.6/multiprocessing/connection.py”, line 177, in close
self._close()
File “/usr/lib/python3.6/multiprocessing/connection.py”, line 361, in _close
_close(self._handle)
OSError: [Errno 9] Bad file descriptor…
Any idea why this is? Does this take lot of time to run??