-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
429 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .monologue import animated_monologue | ||
from .dialogue import animated_dialogue | ||
from .story import animated_story | ||
from .story import animated_story | ||
from .comic import illustrated_comic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import os | ||
import requests | ||
import tempfile | ||
|
||
from .. import utils | ||
from ..plugins import replicate, s3 | ||
from ..character import EdenCharacter | ||
from ..llm import LLM | ||
from ..models import ComicRequest, ComicResult | ||
from ..prompt_templates.comic import comicwriter_system_template | ||
from .animation import comic_strip | ||
|
||
|
||
def illustrated_comic(request: ComicRequest): | ||
params = {"temperature": 1.0, "max_tokens": 2000, **request.params} | ||
loras = { | ||
"Verdelis": "https://edenartlab-prod-data.s3.us-east-1.amazonaws.com/f290723c93715a8eb14e589ca1eec211e10691f683d53cde37139bc7d3a91c22.tar" | ||
} | ||
|
||
comicwriter = LLM( | ||
model=request.model, | ||
system_message=str(comicwriter_system_template), | ||
params=params, | ||
) | ||
|
||
comic_book = comicwriter(request.prompt, output_schema=ComicResult) | ||
|
||
def run_panel(panel): | ||
|
||
# pick lora of character | ||
# pick init image character x genre | ||
|
||
return replicate.sdxl({ | ||
"text_input": panel['image'], | ||
"lora": loras["Verdelis"], | ||
"width": 1024, | ||
"height": 1024, | ||
"n_samples": 1, | ||
}) | ||
|
||
results = utils.process_in_parallel( | ||
comic_book['panels'], | ||
run_panel, | ||
max_workers=4 | ||
) | ||
|
||
image_urls = [image_url for image_url, thumbnail in results] | ||
images = [utils.download_image(url) for url in image_urls] | ||
captions = [panel['caption'] for panel in comic_book['panels']] | ||
|
||
composite_image, thumbnail_image = comic_strip(images, captions) | ||
|
||
img_bytes = utils.PIL_to_bytes(composite_image, ext="JPEG") | ||
thumbnail_bytes = utils.PIL_to_bytes(thumbnail_image, ext="WEBP") | ||
|
||
output_url = s3.upload(img_bytes, "jpg") | ||
thumbnail_url = s3.upload(thumbnail_bytes, "webp") | ||
|
||
return output_url, thumbnail_url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from string import Template | ||
from pathlib import Path | ||
|
||
dir_path = Path(__file__).parent | ||
|
||
with open(dir_path / 'comicwriter_system.txt', 'r') as file: | ||
comicwriter_system_template = Template(file.read()) |
Oops, something went wrong.