Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[preprocessors] TEED preprocessor #6

Merged
merged 2 commits into from
Sep 22, 2024
Merged

[preprocessors] TEED preprocessor #6

merged 2 commits into from
Sep 22, 2024

Conversation

asomoza
Copy link
Member

@asomoza asomoza commented Sep 22, 2024

Add TEED preprocessor (edge detection)

Code

Single image

from image_gen_aux import TeedPreprocessor
from image_gen_aux.utils import load_image

input_image = load_image(
    "https://huggingface.co/datasets/OzzyGT/testing-resources/resolve/main/teed/20240922043215.png"
)

teed_preprocessor = TeedPreprocessor.from_pretrained("OzzyGT/teed").to("cuda")
image = teed_preprocessor(input_image)[0]
image.save("teed.png")
source preprocessed
20240922043215 20240922044022

Video

import imageio
import numpy as np

from image_gen_aux.preprocessors.teed import TeedPreprocessor


reader = imageio.get_reader(
    "https://huggingface.co/datasets/OzzyGT/testing-resources/resolve/main/lineart/movie_chunk.mov"
)

frame_shape = reader.get_data(0).shape
frames = []

for frame in reader:
    normalized_frame = frame.astype(np.float32)
    frames.append(normalized_frame)


inputs = np.stack(frames, axis=0)

teed_preprocessor = TeedPreprocessor.from_pretrained("OzzyGT/teed").to("cuda")

image = teed_preprocessor(inputs, batch_size=1)

writer = imageio.get_writer("teed_movie_out.mp4", fps=24)
for singe_image in image:
    np_image = np.array(singe_image)
    writer.append_data(np_image)
writer.close()
depth_movie_out.mp4

@asomoza asomoza merged commit 4be4829 into main Sep 22, 2024
@asomoza asomoza deleted the teed branch September 22, 2024 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant