ホーム 地域 Can you create Japanese manga speech bubbles using only open models? A record of falling down the rabbit hole

Can you create Japanese manga speech bubbles using only open models? A record of falling down the rabbit hole

真鍋 千夏 真鍋 千夏 • 更新: • 公開: • 読了約 30 分
目次

We live in an era where you can now easily create 3- or 4-panel manga with Japanese speech bubbles using ChatGPT or Google's "Nano Banana".

But, I suddenly wondered.

"Couldn't this be replicated using only open models?"

It's a romantic notion, but it's also practical. As long as you have a decent GPU on hand, you can regenerate images hundreds of times without worrying about costs. Cloud-based generative AI services are convenient, but the costs quietly add up when you try out many variations of long-form speech bubbles. With open models, you only pay for the electricity.

So, I've been stuck in this rabbit hole for the past few days. I'm leaving a record of my trial and error here.

I can draw short sentences. But long ones were impossible

n066c3b629ea6

Krea-2 and Ideogram, which always come up when comparing image generation models, can draw speech bubbles with high accuracy if the Japanese text is short. However, the moment the dialogue becomes long, it suddenly starts to fall apart.

Article on Krea-2 manga

So, while consulting with AI, I tried many patterns of how to write prompts for Krea-2. I based them on four main directions.

The first was a simple English prompt that straightforwardly instructed, "This is a manga panel; please draw this Japanese text accurately inside the speech bubble." I asked it to specify line breaks and leave margins.

The second was a version that reinforced this with strong reminders like "Do not summarize," "Do not omit," and "Keep it word for word."

The third was a pattern that specified the character placement and speech bubble positions more concretely and explicitly stated that it should be written vertically. This had the highest accuracy and got very close to the goal.

The fourth was a prompt focused on "creating the image," which conversely included detailed descriptions of character expressions, psychological depictions, and lighting. I tried prioritizing composition and emotional expression over text accuracy.

As a result, the third prompt pattern stood out as the best.

However, there was a fatal problem.No matter how many times I changed the seed, some characters would always get garbled. of it.

There are several reasons for this. First of all, diffusion models don't understand "character strings" as meaningful text; they generate them as image patterns. Even if it's fine for one or two characters, as long vertical sentences continue, the probability of "at least one shape collapsing somewhere" accumulates exponentially as the number of characters increases. In addition, when placing long text in two speech bubbles at the same time, the model's attention tends not to be distributed evenly to each string, making it easier for one side to collapse. It's also painful that for kanji with many strokes, such as those with hooks or sweeps, even a slight misalignment of the outline makes them "unreadable characters."

If you fix it in Photoshop, it becomes practical. But if you need to make manual corrections every time, it's far from the original goal of "easily generating speech bubbles."

The next strategy I tried was "making the model learn the characters entirely using LoRA"

Realizing that prompt engineering alone had its limits, I shifted my focus to using LoRA (additional training) to teach the model the actual shapes of Japanese characters.

I chose Z-Image. It is one of the open models that ranks just behind Krea-2 and Ideogram in its ability to render Japanese.

To be honest, I put a fair amount of serious effort into this part. I didn't just line up images of individual characters like 'a', 'i', and 'u'; I wrote a Python script from scratch to create the character set and felt I had armed myself with a decent amount of theory.

Specifically, I referred to a method introduced in research on automated manga translation (Towards Fully Automated Manga Translation), which suggests that 'synthetic text should be generated with a ratio of 90% from actual corpora and 10% from completely random strings.' I sampled 2-8 character substrings in an n-gram fashion from a corpus of short stories and dialogue-style text I had on hand, and mixed in the 2,136 common kanji, compound words, sentence-ending expressions (like '~dayone' or '~deshou'), and completely random strings to try and cover a wide range of patterns.

Regarding the appearance of the speech bubbles, I also incorporated a certain percentage of oval, rounded rectangular, and jagged (shouting style) borders in addition to white backgrounds, aiming to reduce the gap between the training data and the actual inference results. I also adopted 'font augmentation,' where I fixed MS Gothic as the main font but mixed in some Yu Gothic and Meiryo. This was because research in visual text generation like GlyphControl, TextDiffuser, and AnyText pointed out that training on a single font tends to lead to overfitting on the quirks of that specific font. I also added slight jitter (fine adjustments to angle and position) to replicate the irregularities of handwritten characters. On a more practical note, I also implemented an operational optimization: by generating multi-character data at 512x512 resolution first and single-character data at 256x256 later, I could verify early in the training process whether the VRAM was sufficient.

Armed with this theory, I created a training dataset by combining single-character images like 'a', 'i', and 'u' with multi-character images taken from the corpus.

The logic was that by mixing in natural character sequences based on actual corpora, it should work better than simple single-character training.

However, the results were the opposite of what I expected. Applying LoRA actually caused the characters to break down and become unusable.

The only achievement was that the atmosphere of the font shifted from the base model's standard to the typeface I had trained it on. The efforts I put into the corpus, font augmentation, and jitter ultimately didn't pay off. However, I don't think it was a complete waste, as the research insights and design philosophy I referenced here served as a foundation for later improvements.

Why did this happen? Looking back at the training logs, the reason becomes clear.

Although I mixed in n-grams and compound words from the corpus, the overwhelming majority of the dataset consisted of single glyph images for the 2,136 common kanji. This means that what the model saw most repeatedly during training was, in the end, individual characters. The ability to synthesize 'sentences' by arranging multiple characters in the correct order and spacing was something the base model already possessed, and it is highly likely that this dataset, dominated by single characters, did not contain enough information to sufficiently reinforce that ability. As a result, while the gradients worked well for 'drawing individual glyphs convincingly,' they likely overwrote the circuits responsible for 'arranging multiple characters correctly' in a way that was unrelated or even competitive, leading to a degradation in the multi-character synthesis capability itself. The fact that the learning rate was somewhat high and the settings caused the model to see the same characters for dozens of epochs likely contributed to this 'forgetting'.

Thinking about it further, the nature of this task is fundamentally different from typical 'character LoRA' or 'art style LoRA.' While standard LoRA training is a task of 'teaching one concept from every angle,' learning Japanese glyphs is closer to a task of 'linking over 2,000 different glyphs to 2,000 different short texts one-to-one.' It is essentially like trying to make the model memorize over 2,000 independent relationships simultaneously, which was a challenge of a scale that could not be overcome with casual LoRA training.

A breakthrough after several days of trial and error.

For the next few days, I struggled with this, trying one thing after another. I stopped the simple 'one character, one image' training, re-evaluated the data containing multi-character sequences and the training process itself, and solidified a new configuration that combined scripts (which I plan to turn into nodes in the future) with LoRA.

While I'm not at the stage where I can disclose the details of the theory yet, the sample image generation I've been using now produces clean results about 70% of the time with seed gacha.

I think the 5-panel manga I generated next will show you how far the accuracy has come.
The subject was the news that '200 fake iPhones were discovered at Kansai International Airport, and a fraudulent tax refund of 100 million yen was uncovered.' I turned this into a 5-panel manga.

As a result, I was finally able to generate dialogue with a level of perfection that could be called ChatGPT-class. Four out of the five panels were generated on the first try. The only exception was the fourth panel, where the female character's dialogue was complex, requiring three seed gacha pulls. Looking closely, it seems the combination of the first and second lines of that female character's dialogue was particularly difficult for the model. Discovering that difficulty varies even within long sentences depending on line breaks and character combinations was a small but important finding.

Even so, there are four walls remaining.

Having come this far, I have finally grasped a sense that it is usable. However, there are still several challenges left to overcome.

The first is the lack of flexibility in the format. If you don't follow a certain composition or specific writing style, the accuracy drops immediately. This is tedious, and if possible, I would like a mechanism where the AI interprets 'instructions written in normal Japanese' and converts them into prompts.

The second is that stable generation is only possible on a single-panel basis, and it is impossible to maintain character consistency in multi-panel compositions like 2-panel or 4-panel layouts. For now, it seems I have no choice but to use character LoRA, but it is time-consuming.

The third is that if I publish and register it on GitHub as a ComfyUI custom node, it will create a burden of having to continue maintaining it afterward. (Ah, what a pain lol)

The fourth is the concern that if I proceed with manual custom node creation without registration, it might interfere with other nodes in the environment.

I have a feeling there are other pitfalls I haven't even seen yet.

What to do from here

I've spent all my time on this for the past few days, so from now on, I intend to slow down the pace and continue making steady improvements. To be honest, I'm getting bored, so I want to step away from speech bubbles for a while and try out the MiniMax H3 for video generation as soon as possible.

If I can refine it to the point where it has versatility, I might release it. Alternatively, I might take the plunge and consider monetizing it as a paid delivery-based service.

That said, the world of open models is advancing day by day. There is a good chance that a model capable of drawing perfect Japanese from the start without such trial and error will appear in the near future. In a sense, this is also a race against the arrival of such a model.

In any case, I would like to release it in some form. If you are interested in follow-up reports, please be sure to follow me so you can check for updates as soon as there is any movement.

同じカテゴリの記事

真鍋 千夏
デジタルマーケター 真鍋 千夏
プロフィールを見る →

美容と暮らしの話題を担当。メーカーの公式発表、商品成分の公表資料、専門家の監修記事をもとに事実を整理します。

おすすめの関連記事