(frames, per_side, batch_size, fillindenoise, edgedenoise, _smol_resolution,square_texture)
| 342 | |
| 343 | |
| 344 | def process_video(frames, per_side, batch_size, fillindenoise, edgedenoise, _smol_resolution,square_texture): |
| 345 | |
| 346 | frame_count = 0 |
| 347 | print(len(frames)) |
| 348 | batches = split_into_batches(frames, batch_size, per_side * per_side) |
| 349 | print("Number of batches:", len(batches)) |
| 350 | first_frames = [batch[0] for batch in batches] |
| 351 | #actuallyprocessthevideo |
| 352 | debug = False |
| 353 | |
| 354 | frame_count = 0 |
| 355 | global resolution |
| 356 | print(len(frames)) |
| 357 | |
| 358 | |
| 359 | if debug is False: |
| 360 | #result_texture = sdprocess.square_Image_request(encoded_square_texture, prompt, initial_denoise, resolution, seed) |
| 361 | result_texture = square_texture |
| 362 | #save_square_texture(encoded_returns, "./result/processed.png") |
| 363 | |
| 364 | else: |
| 365 | f = open("./result/processed.png", "rb") |
| 366 | bytes = f.read() |
| 367 | result_texture = base64.b64encode(bytes).decode("utf-8") |
| 368 | resolution_get = Image.open("./result/processed.png") |
| 369 | resolution= resolution_get.height |
| 370 | # this is stupid and inefficiant i dont care |
| 371 | #its not really encoded anymore is it |
| 372 | encoded_returns = result_texture |
| 373 | #encoded_returns = cv2.cvtColor(utilityb.base64_to_texture(result_texture), cv2.COLOR_BGR2RGB) |
| 374 | |
| 375 | new_frames = split_square_texture(encoded_returns,len(first_frames), per_side * per_side,_smol_resolution,False) |
| 376 | |
| 377 | if check_edges: |
| 378 | for i, image in enumerate(new_frames): |
| 379 | image = utilityb.check_edges(image) |
| 380 | #:( |
| 381 | |
| 382 | # Save first frames |
| 383 | #for idx, first_frame in enumerate(first_frames): |
| 384 | # save_square_texture(first_frame, os.path.join(output_folder, f"first_frame_{idx}.png")) |
| 385 | # save_square_texture(new_frames[idx], os.path.join(output_folder, f"first_frame_processed_{idx}.png")) |
| 386 | """ |
| 387 | Turns out merging each frame backwards and forwards doesn't actually work, you'd think it did because each frame is conceptually closer to it's origin, but it breaks the flowmap in all sorts of weird ways if you tell it to go backwards, very very annoying |
| 388 | last_processed = None |
| 389 | for i, batch in enumerate(batches): |
| 390 | |
| 391 | encoded_batch = [] |
| 392 | for b, image in enumerate(batch): |
| 393 | encoded_batch.append(utilityb.texture_to_base64(image)) |
| 394 | encoded_new_frame = utilityb.texture_to_base64(new_frames[i]) |
| 395 | |
| 396 | processed_batch_before,all_flow_before = sdprocess.batch_sd_run(encoded_batch, encoded_new_frame, frame_count, seed, False, fillindenoise, edgedenoise, _smol_resolution,False,encoded_new_frame,False) |
| 397 | |
| 398 | if i < len(batches) - 1: |
| 399 | |
| 400 | encoded_batch_next = [] |
| 401 | for b, image in enumerate(batches[i+1]): |
no test coverage detected