I am running into a PYTORCH error under Diffuse!

312023: <p>I don’t know how else I can debug this error, can someone please help me.</p>
<hr>
<p>Frames: 0%<br>
0/10000 [00:00&lt;?, ?it/s]</p>
<p>Length: 10000, dtype: object<br>
Frame 0 Prompt: [‘A Dark Fantasy Disco Dance Floor. A unique serendipitous manner. Playstation 5.’, ‘A Beautiful, color scheme.’]<br>
Seed used: 455071194</p>
<hr>
<p>UnidentifiedImageError                    Traceback (most recent call last)</p>
<p> in <br>
216 torch.cuda.empty_cache()<br>
217 try:<br>
 → 218     do_run()<br>
219 except KeyboardInterrupt:<br>
220     pass</p>
<p>1 frames</p>
<p>/usr/local/lib/python3.8/dist-packages/PIL/Image.py in open(fp, mode, formats)<br>
3028     for message in accept_warnings:<br>
3029         warnings.warn(message)<br>
 → 3030     raise UnidentifiedImageError(<br>
3031         “cannot identify image file %r” % (filename if filename else fp)<br>
3032     )</p>
<p>UnidentifiedImageError: cannot identify image file &lt;_io.BytesIO object at 0x7f212ed13d10&gt;</p>
<hr>
<p>display_rate = 20<br>
n_batches = 50</p>
<p>if animation_mode == ‘Video Input’:<br>
steps = video_init_steps</p>
<p><span class="hashtag">#Update</span> Model Settings<br>
timestep_respacing = f’ddim{steps}’<br>
diffusion_steps = (1000//steps)*steps if steps &lt; 1000 else steps<br>
model_config.update({<br>
‘timestep_respacing’: timestep_respacing,<br>
‘diffusion_steps’: diffusion_steps,<br>
})</p>
<p>batch_size = 1</p>
<p>def move_files(start_num, end_num, old_folder, new_folder):<br>
for i in range(start_num, end_num):<br>
old_file = old_folder + f’/{batch_name}({batchNum})<em>{i:04}.png’<br>
new_file = new_folder + f’/{batch_name}({batchNum})</em>{i:04}.png’<br>
os.rename(old_file, new_file)</p>
<p>#<span class="mention">@markdown</span> —</p>
<p>resume_run = True<br>
run_to_resume = ‘latest’<br>
resume_from_frame = ‘latest’<br>
retain_overwritten_frames = False<br>
if retain_overwritten_frames:<br>
retainFolder = f’{batchFolder}/retained’<br>
createPath(retainFolder)</p>
<p>skip_step_ratio = int(frames_skip_steps.rstrip(“%”)) / 100<br>
calc_frames_skip_steps = math.floor(steps * skip_step_ratio)</p>
<p>if animation_mode == ‘Video Input’:<br>
frames = sorted(glob(in_path+‘/<em>.</em>’));<br>
if len(frames)==0:<br>
sys.exit(“ERROR: 0 frames found.\nPlease check your video input path and rerun the video settings cell.”)<br>
flows = glob(flo_folder+‘/<em>.</em>’)<br>
if (len(flows)==0) and video_init_flow_warp:<br>
sys.exit(“ERROR: 0 flow files found.\nPlease rerun the flow generation cell.”)</p>
<p>if steps &lt;= calc_frames_skip_steps:<br>
sys.exit(“ERROR: You can’t skip more steps than your total steps”)</p>
<p>if resume_run:<br>
if run_to_resume == ‘latest’:<br>
try:<br>
batchNum<br>
except:<br>
batchNum = len(glob(f"{batchFolder}/{batch_name}(<em>)<em>settings.txt"))-1<br>
else:<br>
batchNum = int(run_to_resume)<br>
if resume_from_frame == ‘latest’:<br>
start_frame = len(glob(batchFolder+f"/{batch_name}({batchNum})</em></em>.png"))<br>
if animation_mode != ‘3D’ and turbo_mode == True and start_frame &gt; turbo_preroll and start_frame % int(turbo_steps) != 0:<br>
start_frame = start_frame - (start_frame % int(turbo_steps))<br>
else:<br>
start_frame = int(resume_from_frame)+1<br>
if animation_mode != ‘3D’ and turbo_mode == True and start_frame &gt; turbo_preroll and start_frame % int(turbo_steps) != 0:<br>
start_frame = start_frame - (start_frame % int(turbo_steps))<br>
if retain_overwritten_frames is True:<br>
existing_frames = len(glob(batchFolder+f"/{batch_name}({batchNum})_<em>.png"))<br>
frames_to_save = existing_frames - start_frame<br>
print(f’Moving {frames_to_save} frames to the Retained folder’)<br>
move_files(start_frame, existing_frames, batchFolder, retainFolder)<br>
else:<br>
start_frame = 0<br>
batchNum = len(glob(batchFolder+"/</em>.txt"))<br>
while os.path.isfile(f"{batchFolder}/{batch_name}({batchNum})_settings.txt") or os.path.isfile(f"{batchFolder}/{batch_name}-{batchNum}_settings.txt"):<br>
batchNum += 1</p>
<p>print(f’Starting Run: {batch_name}({batchNum}) at frame {start_frame}')</p>
<p>if set_seed == ‘random_seed’:<br>
random.seed()<br>
seed = random.randint(0, 2**32)<br>
# print(f’Using seed: {seed}')<br>
else:<br>
seed = int(set_seed)</p>
<p>args = {<br>
‘batchNum’: batchNum,<br>
‘prompts_series’:split_prompts(text_prompts) if text_prompts else None,<br>
‘image_prompts_series’:split_prompts(image_prompts) if image_prompts else None,<br>
‘seed’: seed,<br>
‘display_rate’:display_rate,<br>
‘n_batches’:n_batches if animation_mode == ‘None’ else 1,<br>
‘batch_size’:batch_size,<br>
‘batch_name’: batch_name,<br>
‘steps’: steps,<br>
‘diffusion_sampling_mode’: diffusion_sampling_mode,<br>
‘width_height’: width_height,<br>
‘clip_guidance_scale’: clip_guidance_scale,<br>
‘tv_scale’: tv_scale,<br>
‘range_scale’: range_scale,<br>
‘sat_scale’: sat_scale,<br>
‘cutn_batches’: cutn_batches,<br>
‘init_image’: init_image,<br>
‘init_scale’: init_scale,<br>
‘skip_steps’: skip_steps,<br>
‘side_x’: side_x,<br>
‘side_y’: side_y,<br>
‘timestep_respacing’: timestep_respacing,<br>
‘diffusion_steps’: diffusion_steps,<br>
‘animation_mode’: animation_mode,<br>
‘video_init_path’: video_init_path,<br>
‘extract_nth_frame’: extract_nth_frame,<br>
‘video_init_seed_continuity’: video_init_seed_continuity,<br>
‘key_frames’: key_frames,<br>
‘max_frames’: max_frames if animation_mode != “None” else 1,<br>
‘interp_spline’: interp_spline,<br>
‘start_frame’: start_frame,<br>
‘angle’: angle,<br>
‘zoom’: zoom,<br>
‘translation_x’: translation_x,<br>
‘translation_y’: translation_y,<br>
‘translation_z’: translation_z,<br>
‘rotation_3d_x’: rotation_3d_x,<br>
‘rotation_3d_y’: rotation_3d_y,<br>
‘rotation_3d_z’: rotation_3d_z,<br>
‘midas_depth_model’: midas_depth_model,<br>
‘midas_weight’: midas_weight,<br>
‘near_plane’: near_plane,<br>
‘far_plane’: far_plane,<br>
‘fov’: fov,<br>
‘padding_mode’: padding_mode,<br>
‘sampling_mode’: sampling_mode,<br>
‘angle_series’:angle_series,<br>
‘zoom_series’:zoom_series,<br>
‘translation_x_series’:translation_x_series,<br>
‘translation_y_series’:translation_y_series,<br>
‘translation_z_series’:translation_z_series,<br>
‘rotation_3d_x_series’:rotation_3d_x_series,<br>
‘rotation_3d_y_series’:rotation_3d_y_series,<br>
‘rotation_3d_z_series’:rotation_3d_z_series,<br>
‘frames_scale’: frames_scale,<br>
‘skip_step_ratio’: skip_step_ratio,<br>
‘calc_frames_skip_steps’: calc_frames_skip_steps,<br>
‘text_prompts’: text_prompts,<br>
‘image_prompts’: image_prompts,<br>
‘cut_overview’: eval(cut_overview),<br>
‘cut_innercut’: eval(cut_innercut),<br>
‘cut_ic_pow’: eval(cut_ic_pow),<br>
‘cut_icgray_p’: eval(cut_icgray_p),<br>
‘intermediate_saves’: intermediate_saves,<br>
‘intermediates_in_subfolder’: intermediates_in_subfolder,<br>
‘steps_per_checkpoint’: steps_per_checkpoint,<br>
‘perlin_init’: perlin_init,<br>
‘perlin_mode’: perlin_mode,<br>
‘set_seed’: set_seed,<br>
‘eta’: eta,<br>
‘clamp_grad’: clamp_grad,<br>
‘clamp_max’: clamp_max,<br>
‘skip_augs’: skip_augs,<br>
‘randomize_class’: randomize_class,<br>
‘clip_denoised’: clip_denoised,<br>
‘fuzzy_prompt’: fuzzy_prompt,<br>
‘rand_mag’: rand_mag,<br>
‘turbo_mode’:turbo_mode,<br>
‘turbo_steps’:turbo_steps,<br>
‘turbo_preroll’:turbo_preroll,<br>
‘use_vertical_symmetry’: use_vertical_symmetry,<br>
‘use_horizontal_symmetry’: use_horizontal_symmetry,<br>
‘transformation_percent’: transformation_percent,<br>
<span class="hashtag">#video</span> init settings<br>
‘video_init_steps’: video_init_steps,<br>
‘video_init_clip_guidance_scale’: video_init_clip_guidance_scale,<br>
‘video_init_tv_scale’: video_init_tv_scale,<br>
‘video_init_range_scale’: video_init_range_scale,<br>
‘video_init_sat_scale’: video_init_sat_scale,<br>
‘video_init_cutn_batches’: video_init_cutn_batches,<br>
‘video_init_skip_steps’: video_init_skip_steps,<br>
‘video_init_frames_scale’: video_init_frames_scale,<br>
‘video_init_frames_skip_steps’: video_init_frames_skip_steps,<br>
<span class="hashtag">#warp</span> settings<br>
‘video_init_flow_warp’:video_init_flow_warp,<br>
‘video_init_flow_blend’:video_init_flow_blend,<br>
‘video_init_check_consistency’:video_init_check_consistency,<br>
‘video_init_blend_mode’:video_init_blend_mode<br>
}</p>
<p>if animation_mode == ‘Video Input’:<br>
# This isn’t great in terms of what will get saved to the settings… but it should work.<br>
args[‘steps’] = args[‘video_init_steps’]<br>
args[‘clip_guidance_scale’] = args[‘video_init_clip_guidance_scale’]<br>
args[‘tv_scale’] = args[‘video_init_tv_scale’]<br>
args[‘range_scale’] = args[‘video_init_range_scale’]<br>
args[‘sat_scale’] = args[‘video_init_sat_scale’]<br>
args[‘cutn_batches’] = args[‘video_init_cutn_batches’]<br>
args[‘skip_steps’] = args[‘video_init_skip_steps’]<br>
args[‘frames_scale’] = args[‘video_init_frames_scale’]<br>
args[‘frames_skip_steps’] = args[‘video_init_frames_skip_steps’]</p>
<p>args = SimpleNamespace(**args)</p>
<p>print(‘Prepping model…’)<br>
model, diffusion = create_model_and_diffusion(**model_config)<br>
if diffusion_model == ‘custom’:<br>
model.load_state_dict(torch.load(custom_path, map_location=‘cpu’))<br>
else:<br>
model.load_state_dict(torch.load(f’{model_path}/{get_model_filename(diffusion_model)}', map_location=‘cpu’))<br>
model.requires_grad_(False).eval().to(device)<br>
for name, param in model.named_parameters():<br>
if ‘qkv’ in name or ‘norm’ in name or ‘proj’ in name:<br>
param.requires_grad_()<br>
if model_config[‘use_fp16’]:<br>
model.convert_to_fp16()</p>
<p>gc.collect()<br>
torch.cuda.empty_cache()<br>
try:<br>
do_run()<br>
except KeyboardInterrupt:<br>
pass<br>
finally:<br>
print(‘Seed used:’, seed)<br>
gc.collect()<br>
torch.cuda.empty_cache()</p>

312023: <p>For clarification,</p>
<p>This is the error code that I was getting, after attempting to run this section of code</p>
<p>Length: 10000, dtype: object<br>
Frame 0 Prompt: [‘A Dark Fantasy Disco Dance Floor. A unique serendipitous manner. Playstation 5.’, ‘A Beautiful, color scheme.’]<br>
Seed used: 455071194</p>
<hr>
<p>UnidentifiedImageError                    Traceback (most recent call last)</p>
<p> in <br>
216 torch.cuda.empty_cache()<br>
217 try:<br>
 → 218     do_run()<br>
219 except KeyboardInterrupt:<br>
220     pass</p>
<p>1 frames</p>
<p>/usr/local/lib/python3.8/dist-packages/PIL/Image.py in open(fp, mode, formats)<br>
3028     for message in accept_warnings:<br>
3029         warnings.warn(message)<br>
 → 3030     raise UnidentifiedImageError(<br>
3031         “cannot identify image file %r” % (filename if filename else fp)<br>
3032     )</p>
<p>UnidentifiedImageError: cannot identify image file &lt;_io.BytesIO object at 0x7f212ed13d10&gt;</p>

ptrblck: <p><code>PIL.Image.open</code> fails to load the specified object so check which path was specified and if the image file might be corrupt.</p>

ptrblck: <p>Sorry, but posting screenshot of a chat window isn’t really helpful for this topic.<br>
I would still recommend checking my previous suggestion in narrowing down why the <code>PIL.Image.open</code> call fails first.</p>

312023: <p>Sorry, but this screenshot… is the source of the entire problem.</p>
<p>image_prompts = {<br>
0:{ }<br>
}</p>
<p>there is no IMAGE that I am trying to prompt, I am only using a video prompt…</p>

312023: <p>sh!t, I’m probably better off, talking to the AI, then relying on your expertise, ptrblck. <img src="https://discuss.pytorch.org/images/emoji/apple/joy.png?v=12" title=":joy:" class="emoji" alt=":joy:" loading="lazy" width="20" height="20"></p>