mikael-alafriz-deel / lucid-sonic-dreams

MIT License
771 stars 157 forks source link

index out of bounds #37

Open shoegazerstella opened 2 years ago

shoegazerstella commented 2 years ago

Hi! I am trying out the script in order to sync some images I have generated using VQGAN+CLIP to my audio. Here's the code:

def load_imgs(noise_batch, class_batch):
    # just loads N images randomly
    return images

L = LucidSonicDream('audio_5.mp3',
                    style = load_imgs, 
                    input_shape = 592,
                    num_possible_classes = 1000)

L.hallucinate('video_sync.mp4',
              output_audio = 'audio_sync.mp3',
              speed_fpm = 3,
              classes = [13, 14, 22, 24, 301, 84, 99, 100, 134, 143, 393, 394],
              class_shuffle_seconds = 10, 
              class_shuffle_strength = 0.1,
              class_complexity = 0.5,
              class_smooth_seconds = 4,
              motion_react = 0.35,
              flash_strength = 1)
              #contrast_strength = 0.5)

The error appears just at the end of the process:

IndexError                                Traceback (most recent call last)
<ipython-input-15-aeedb41e1387> in <module>()
     15               class_smooth_seconds = 4,
     16               motion_react = 0.35,
---> 17               flash_strength = 1)
     18               #contrast_strength = 0.5)

2 frames
/usr/local/lib/python3.7/dist-packages/lucidsonicdreams/main.py in apply_effect(self, array, index)
    742     '''Apply effect to image (array)'''
    743 
--> 744     amplitude = self.spec[index]
    745     return self.func(array=array, strength = self.strength, amplitude=amplitude)

IndexError: index 207 is out of bounds for axis 0 with size 207

Any idea on how to avoid it? Thanks in advance!