Downloads · 30 days
5
12% of all-time downloads
Akirashindo39/kanji-diffusion-v1-4-kanjidic2
kanji-diffusion-v1-4-kanjidic2 is a text-to-image model from Akirashindo39. Use it when you need an image from a text prompt. It is set up for diffusers. The card lists the license as creativeml-openrail-m.
should probably proofread and complete it, then remove this comment. --
Downloads · 30 days
5
12% of all-time downloads
All-time downloads
41
Public
Repo size
10.4 GB
Likes
0
Public
Click a slice to open those files.
.safetensors10.3 GB · 100%
From the Hugging Face model README
This model is a text-to-image diffusion model capable of hallucinating Kanji characters given any English prompt.
Use Google Colab to run the following script. It is recommended to use a GPU (such as a T4 GPU) to run the script, or else it will take a long time to process. Make sure you have your Huggingface API KEY / ACCESS TOKEN for this.
!pip install diffusers
!git clone https://github.com/huggingface/diffusers
!huggingface-cli login
import os
from google.colab import drive
# Mount Google Drive to access persistent storage across Colab sessions
drive.mount('/content/drive')
# Navigate to the project directory in Google Drive
os.chdir("/content/drive/MyDrive")
from diffusers import StableDiffusionPipeline
import torch
torch.cuda.empty_cache()
model_path = "Akirashindo39/kanji-diffusion-v1-4-kanjidic2"
pipe = StableDiffusionPipeline.from_pretrained(
"CompVis/stable-diffusion-v1-4",
torch_dtype=torch.float16,
use_safetensors=True
).to("cuda")
pipe.unet.load_attn_procs(model_path)
pipe.to("cuda")
new_kanji_meaning = "internet" # Enter new kanji meaning here
prompt = f"a Kanji meaning {new_kanji_meaning}"
image = pipe(prompt).images[0]
image.save(f"{new_kanji_meaning}-kanji-v1-4.png")
The training script below was executed, completing in approximately two hours.
# Launch LoRA fine-tuning for text-to-image model with accelerate
!accelerate launch train_text_to_image_lora.py \
--pretrained_model_name_or_path="CompVis/stable-diffusion-v1-4" \
--dataset_name="Akirashindo39/KANJIDIC2" \
--image_column="image" \
--caption_column="text" \
--resolution=512 \
--random_flip \
--train_batch_size=1 \
--num_train_epochs=1 \
--checkpointing_steps=2000 \
--learning_rate=1e-04 \
--lr_scheduler="constant" \
--lr_warmup_steps=0 \
--seed=42 \
--output_dir="Akirashindo39/kanji-diffusion-v1-4-kanjidic2" \
--validation_prompt="A kanji meaning Elon Musk" \
--push_to_hub