Posts

Showing posts from February 13, 2019

Remove files if command not sucessful

Image
0 I mux mp4 videos and webm videos with srt (subtitles) files. All the files have the same filenames but different extensions. Like this: Video1.mp4 Video1.srt or Video2.webm Video2.srt Sometimes the muxing (merge video with subtitles) is not successful because the srt file is empty. The command line tool I use to merge video with subtitles is called MKVMerge and has 3 exit codes: 0 -- This exit codes means that muxing has completed successfully. 1 -- In this case mkvmerge(1) has output at least one warning, but muxing did continue. A warning is prefixed with the text 'Warning:'. Depending on the issues involved the resulting file might be ok or not. The user is urged to check both the warning and the resulting file. 2 -- This exit code is used after an error occurred. mkvmerge(1) aborts r

Custom preprocessing_function with tf.image.rgb_to_grayscale - ValueError: setting an array element with a...

Image
0 1 I am trying to use a custom preprocessing function to convert RGB images to grayscale during training. As such, I try to use tf.image.rbg_to_grayscale for this. My function looks as following: def prep_data(x): x = tf.image.rgb_to_grayscale(x) return x datagen = ImageDataGenerator(preprocessing_function=prep_data,validation_split=0.15) The train_generator is defined using datagen.flow_from_dataframe(...) . Training without this custom function works just fine, however once I use it I get the following error: ValueError: setting an array element with a sequence. Judging from this answer here, I assume I need to change my input to rgb_to_grayscale , but I don't know what's the correct way of passing x to the function. Any idea on how to solve this?