Giter Club home page Giter Club logo

Comments (8)

Barbetto80 avatar Barbetto80 commented on June 15, 2024 2

Yes !!!!
It seems to work now, thank you very much. A small recap for the people that can be interested:

----- File generator.py:

  1. Read tif images
#self.image_paths = list(Path(image_dir).glob("*.jpg"))
self.image_paths = list(Path(image_dir).glob("*.tif"))
  1. Fill empty data
#x = np.zeros((batch_size, image_size, image_size, 3), dtype=np.uint8)
#y = np.zeros((batch_size, image_size, image_size, 3), dtype=np.uint8)
x = np.zeros((batch_size, image_size, image_size, 1), dtype=np.uint16)
y = np.zeros((batch_size, image_size, image_size, 1), dtype=np.uint16)
  1. open the image through opencv
#image = cv2.imread(str(image_path))
image = np.expand_dims(cv2.imread(str(image_path), cv2.IMREAD_ANYDEPTH), -1)

and also

#y = cv2.imread(str(image_path))
y = np.expand_dims(cv2.imread(str(image_path), cv2.IMREAD_ANYDEPTH), -1)

----- File model.py

Just change the default SRResNet default channel

#def get_srresnet_model(input_channel_num=3, feature_dim=64, resunit_num=16):
def get_srresnet_model(input_channel_num=1, feature_dim=64, resunit_num=16):

Well thanks again 👍

from noise2noise.

yu4u avatar yu4u commented on June 15, 2024

I did not check the code but please try:

x = np.zeros((batch_size, image_size, image_size), dtype=np.uint8)
y = np.zeros((batch_size, image_size, image_size), dtype=np.uint8)

instead of

x = np.zeros((batch_size, image_size, image_size, 3), dtype=np.uint8)
y = np.zeros((batch_size, image_size, image_size, 3), dtype=np.uint8)

Some noise models might not work due to the number of channels.

from noise2noise.

Barbetto80 avatar Barbetto80 commented on June 15, 2024

Hi,

Thank for your suggestion we made one step ahead, I have made also some other modification to reach my goal but still missing something:

ValueError: Error when checking input: expected input_1 to have 4 dimensions, but got array with shape (8, 128, 128)

I include my modified python files:
noise2noise.zip

Thanks in advance
Carlo

from noise2noise.

yu4u avatar yu4u commented on June 15, 2024

Okey, please try:

image = np.expand_dims(cv2.imread(str(image_path), cv2.IMREAD_ANYDEPTH), -1)
...
x = np.zeros((batch_size, image_size, image_size, 1), dtype=np.uint8)
y = np.zeros((batch_size, image_size, image_size, 1), dtype=np.uint8)

from noise2noise.

IsabellLehmann avatar IsabellLehmann commented on June 15, 2024

Thanks a lot, I had the same problem and your solution solved it. :)

from noise2noise.

IsabellLehmann avatar IsabellLehmann commented on June 15, 2024

Hi! I was happy too early. After the first 1000 steps, the training broke up and I got the following messages:

File "/net/home/Dokumente/PA/virtualenv/lib/python3.6/site-packages/keras/engine/training.py", line 1418, in fit_generator
initial_epoch=initial_epoch)
File "/net/home/Dokumente/PA/virtualenv/lib/python3.6/site-packages/keras/engine/training_generator.py", line 234, in fit_generator
workers=0)
File "/net/home/Dokumente/PA/virtualenv/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "/net/home/Dokumente/PA/virtualenv/lib/python3.6/site-packages/keras/engine/training.py", line 1472, in evaluate_generator
verbose=verbose)
File "/net/home/Dokumente/PA/virtualenv/lib/python3.6/site-packages/keras/engine/training_generator.py", line 346, in evaluate_generator
outs = model.test_on_batch(x, y, sample_weight=sample_weight)
File "/net/home/Dokumente/PA/virtualenv/lib/python3.6/site-packages/keras/engine/training.py", line 1250, in test_on_batch
sample_weight=sample_weight)
File "/net/home/Dokumente/PA/virtualenv/lib/python3.6/site-packages/keras/engine/training.py", line 751, in _standardize_user_data
exception_prefix='input')
File "/net/home/Dokumente/PA/virtualenv/lib/python3.6/site-packages/keras/engine/training_utils.py", line 128, in standardize_input_data
'with shape ' + str(data_shape))
ValueError: Error when checking input: expected input_1 to have 4 dimensions, but got array with shape (1, 176, 512)

I have no idea, where this shape comes from. I included the changes you said, Barbaretto80, but I use STFTs of speech signals, therefore my dtype is np.float64. Can the type be the reason for the error?

from noise2noise.

yu4u avatar yu4u commented on June 15, 2024

You might have to do the same thing to ValGenerator:

https://github.com/yu4u/noise2noise/blob/master/generator.py#L63-L65

The shape seems to come from y = y[:(h // 16) * 16, :(w // 16) * 16].

from noise2noise.

shenmena avatar shenmena commented on June 15, 2024

Hello,

I've implemented Barbetto80's changes as I'm also interested in working with 16bit TIFF images. After running the following line:

python3 train.py --image_dir train --test_dir test --image_size 256 --batch_size 4 --lr 0.001 --output_path gaussian

The script goes through the first 1000 steps of the first epoch but then I get this error:

F tensorflow/stream_executor/cuda/cuda_dnn.cc:91] Check failed: narrow == wide (-1673887744 vs. 2621079552)checked narrowing failed; values not equal post-conversion
/usr/local/bin/assign-gpu: line 23: 388324 Aborted (core dumped) /usr/bin/numactl --cpunodebind="${CUDA_VISIBLE_DEVICES}" --membind="${CUDA_VISIBLE_DEVICES}" $@

The gaussian folder is created but is empty.

The training and testing TIFF images are 4700x8742 pixels and 78MB in size.

I was wondering if you could help with this. Thanks!

from noise2noise.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.