The Dataset looks alright.
It might help if you try to overfit a very small sample of your data to see if there might be other bugs in the code. E.g. you could start with 5 intact and 5 defect pill images and see if the network successfully learns them. If that’s not the case, we might look for other possible bugs.
Also, as a small side note: Variables are deprecated sind 0.4.0, so you can just remove them and use tensors instead.