Tirth27 / Detecting-diabetic-retinopathy

Deep learning applied to Kaggle's Diabetic retinopathy dataset.
https://diabetic-retinopathy-detection.herokuapp.com/
MIT License
35 stars 23 forks source link

the file X_train_256_v2.npy can't be build? #5

Closed YUN-XIAO-MO closed 2 years ago

YUN-XIAO-MO commented 2 years ago

respected sir,I come from gregwchase/eyenet ---2018, I saw your message in the issue.May I ask how you solve the question that the file X_train_256_v2.npy can't be build?

Tirth27 commented 2 years ago

Hi @YUN-XIAO-MO , the file X_train_256_v2.npy that you want to create is just the numpy array (i.e. .npy or .npz).

It is nothing but a numpy array of training images (X_train) off resolution 256x256.

When I initially worked on the project, I tried to build the numpy array based on the this and this, but found that it is not the ideal way to do it. Because if you create a numpy array on training images(X_train) then I will be of size ~14GiB. And when training a model you have to load that ~14GiB of numpy array in the RAM. Which requires more RAM and computation.

So, I suggest if you can use the flow_from_directory then you can augment the images on fly, during model training. You can find more resources on Keras Website and its explanation of Medium

YUN-XIAO-MO commented 2 years ago

I'am glad that you responsed quickly.

I did get the warn that the RAM of the GPU is not enough.

So,I decrease the training set,I picked a little piece from the whole training set to try the model.

But my computer only have one GPU, I changed the code from gregwchase to fit my computer.

here is my code.

I use X_train to try the model, but i got a bug,I show you the traceback:

==============================================================================

Traceback (most recent call last):

File "D:\Desktop\Python_WorkSpace\workspace\EYE\src\cnn_test.py", line 154, in model = cnn_model(X_train=X_train,

File "D:\Desktop\Python_WorkSpace\workspace\EYE\src\cnn_test.py", line 83, in cnn_model model.fit(X_train, y_train, batch_size=batch_size, epochs=num_epoch,

File "D:\Anaconda3\envs\tensorflow\lib\site-packages\keras\utils\traceback_utils.py", line 67, in error_handler raise e.with_traceback(filtered_tb) from None

File "D:\Anaconda3\envs\tensorflow\lib\site-packages\keras\engine\data_adapter.py", line 1420, in_make_class_weight_map_fn class_ids = list(sorted(class_weight.keys())) AttributeError: 'str' object has no attribute 'keys'

==============================================================================

Would you mind helping me with this problem. @Tirth27

Tirth27 commented 2 years ago

Hi @YUN-XIAO-MO , I was not able to properly debug the code, would be mind providing detail about what changes you made in your script from the originals. Plus, what you wanted to achieve.

And if you can provide the full error logs to better understand the issue.

YUN-XIAO-MO commented 2 years ago

Thank you, honourable sir. @Tirth27

I uploaded my details

I just want to make the model work。

Tirth27 commented 2 years ago

If you look at Keras Model APIs class_weight in the model.fit() takes dictionary, but you passed the string.

Direct quote from the website:

class_weight: Optional dictionary mapping class indices (integers) to a weight (float) value, used for weighting the loss function (during training only). This can be useful to tell the model to "pay more attention" to samples from an under-represented class.

Also, you might be interested in this discussion on StackOverflow