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

Add lineart preprocessor #2

Merged
merged 22 commits into from
Sep 11, 2024
Merged

Add lineart preprocessor #2

merged 22 commits into from
Sep 11, 2024

Conversation

asomoza
Copy link
Member

@asomoza asomoza commented Aug 19, 2024

Adds the lineart preprocessor

  • Lineart preprocesor for images
  • Docstrings
  • Documentation
  • For videos

Code

Single image

from image_gen_aux import LineArtPreprocessor
from image_gen_aux.utils import load_image

lineart_preprocessor = LineArtPreprocessor.from_pretrained("OzzyGT/lineart")
lineart_preprocessor.to("cuda")

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

image = lineart_preprocessor(input_image)[0]
image.save("lineart.png")
original preprocessed
hippowaffle 20240904034104

Video

import imageio
import numpy as np

from image_gen_aux import LineArtPreprocessor


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) / 255.0
    frames.append(normalized_frame)

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

lineart_preprocessor = LineArtPreprocessor.from_pretrained("OzzyGT/lineart").to("cuda")

image = lineart_preprocessor(inputs, batch_size=10)

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

Original

movie_chunk.mp4

Preprocessed

lineart_movie_out.mp4

Copy link
Member

@stevhliu stevhliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice job and great docstrings as well! Mostly left comments on formatting and structure 😄

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
src/image_gen_aux/image_processor.py Outdated Show resolved Hide resolved
src/image_gen_aux/image_processor.py Outdated Show resolved Hide resolved
src/image_gen_aux/modeling_utils.py Outdated Show resolved Hide resolved
src/image_gen_aux/preprocessors/preprocessor.py Outdated Show resolved Hide resolved
src/image_gen_aux/preprocessors/preprocessor.py Outdated Show resolved Hide resolved
src/image_gen_aux/preprocessors/preprocessor.py Outdated Show resolved Hide resolved
asomoza and others added 19 commits August 20, 2024 10:28
Co-authored-by: Steven Liu <[email protected]>
@asomoza asomoza merged commit 19549df into main Sep 11, 2024
@asomoza asomoza deleted the lineart branch September 11, 2024 17:31
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.

2 participants