zkmkarlsruhe / ofxTensorFlow2

TensorFlow 2 AI/ML library wrapper for openFrameworks
Other
109 stars 16 forks source link

Training with larger image size - pix2pix #24

Closed paul-ferragut closed 1 year ago

paul-ferragut commented 2 years ago

I managed to train images in format 256x256 and tried with format 512x512 in config.py

IMG_WIDTH = 512
IMG_HEIGHT = 512

got errors the following errors

Epoch 1 going on....
  0%|                                                                                    | 0/40 [00:00<?, ?it/s]2022-06-26 00:18:30.959669: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:185] None of the MLIR Optimization Passes are enabled (registered 2)
  0%|                                                                                    | 0/40 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "main.py", line 96, in <module>
    checkpoint, checkpoint_prefix
  File "C:\Users\plesk\Documents\coding\of_v0.11.2_vs2017_release\addons\ofxTensorFlow2\example_pix2pix\python\src\training.py", line 143, in train
    fit(train_dataset, test_dataset, EPOCHS)
  File "C:\Users\plesk\Documents\coding\of_v0.11.2_vs2017_release\addons\ofxTensorFlow2\example_pix2pix\python\src\training.py", line 130, in fit
    for input_image, target in tqdm(train_ds):
  File "C:\Users\plesk\.conda\envs\inpaintEnv37\lib\site-packages\tqdm\std.py", line 1167, in __iter__
    for obj in iterable:
  File "C:\Users\plesk\.conda\envs\inpaintEnv37\lib\site-packages\tensorflow\python\data\ops\iterator_ops.py", line 761, in __next__
    return self._next_internal()
  File "C:\Users\plesk\.conda\envs\inpaintEnv37\lib\site-packages\tensorflow\python\data\ops\iterator_ops.py", line 747, in _next_internal
    output_shapes=self._flat_output_shapes)
  File "C:\Users\plesk\.conda\envs\inpaintEnv37\lib\site-packages\tensorflow\python\ops\gen_dataset_ops.py", line 2727, in iterator_get_next
    _ops.raise_from_not_ok_status(e, name)
  File "C:\Users\plesk\.conda\envs\inpaintEnv37\lib\site-packages\tensorflow\python\framework\ops.py", line 6941, in raise_from_not_ok_status
    six.raise_from(core._status_to_exception(e.code, message), None)
  File "<string>", line 3, in raise_from
tensorflow.python.framework.errors_impl.InvalidArgumentError: assertion failed: [Need value.shape >= size, got ] [2 286 286 3] [2 512 512 3]
         [[{{node StatefulPartitionedCall/random_crop/Assert/Assert}}]] [Op:IteratorGetNext]

Is it possible to train larger sizes? Is it possible training rectangular format images?

bytosaur commented 2 years ago

hey, you should look where this number 286 is coming from. There is an augmentation step in dataset.py:

input_image, real_image = resize(input_image, real_image, 286, 286)

This may not be what you want. I think this is where your error happens but you need to adjust the model, too. You would want your model to produce higher resolution which is defined by the number of up conv blocks. Same goes for your input (conv blocks). You should definitely add a layer there, too.

Anyway, for those questions you should rather check out the original repository I am sure people have asked this already.

bytosaur commented 1 year ago

closed due to lack of response