Upload anytext.py
Browse files- anytext.py +4 -2
anytext.py
CHANGED
|
@@ -58,6 +58,8 @@ from diffusers.pipelines.pipeline_utils import DiffusionPipeline, StableDiffusio
|
|
| 58 |
from diffusers.pipelines.stable_diffusion.pipeline_output import StableDiffusionPipelineOutput
|
| 59 |
from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker
|
| 60 |
from diffusers.schedulers import KarrasDiffusionSchedulers
|
|
|
|
|
|
|
| 61 |
from diffusers.utils import (
|
| 62 |
USE_PEFT_BACKEND,
|
| 63 |
deprecate,
|
|
@@ -735,7 +737,8 @@ class FrozenCLIPEmbedderT3(AbstractEncoder):
|
|
| 735 |
return self
|
| 736 |
|
| 737 |
|
| 738 |
-
class TextEmbeddingModule(
|
|
|
|
| 739 |
def __init__(self, font_path, use_fp16=False, device="cpu"):
|
| 740 |
super().__init__()
|
| 741 |
self.font = ImageFont.truetype(font_path, 60)
|
|
@@ -748,7 +751,6 @@ class TextEmbeddingModule(nn.Module):
|
|
| 748 |
args = {}
|
| 749 |
args["rec_image_shape"] = "3, 48, 320"
|
| 750 |
args["rec_batch_num"] = 6
|
| 751 |
-
args["rec_char_dict_path"] = "./text_embedding_module/OCR/ppocr_keys_v1.txt"
|
| 752 |
args["rec_char_dict_path"] = hf_hub_download(
|
| 753 |
repo_id="tolgacangoz/anytext",
|
| 754 |
filename="text_embedding_module/OCR/ppocr_keys_v1.txt",
|
|
|
|
| 58 |
from diffusers.pipelines.stable_diffusion.pipeline_output import StableDiffusionPipelineOutput
|
| 59 |
from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker
|
| 60 |
from diffusers.schedulers import KarrasDiffusionSchedulers
|
| 61 |
+
from diffusers.configuration_utils import register_to_config, ConfigMixin
|
| 62 |
+
from diffusers.models.modeling_utils import ModelMixin
|
| 63 |
from diffusers.utils import (
|
| 64 |
USE_PEFT_BACKEND,
|
| 65 |
deprecate,
|
|
|
|
| 737 |
return self
|
| 738 |
|
| 739 |
|
| 740 |
+
class TextEmbeddingModule(ModelMixin, ConfigMixin):
|
| 741 |
+
@register_to_config
|
| 742 |
def __init__(self, font_path, use_fp16=False, device="cpu"):
|
| 743 |
super().__init__()
|
| 744 |
self.font = ImageFont.truetype(font_path, 60)
|
|
|
|
| 751 |
args = {}
|
| 752 |
args["rec_image_shape"] = "3, 48, 320"
|
| 753 |
args["rec_batch_num"] = 6
|
|
|
|
| 754 |
args["rec_char_dict_path"] = hf_hub_download(
|
| 755 |
repo_id="tolgacangoz/anytext",
|
| 756 |
filename="text_embedding_module/OCR/ppocr_keys_v1.txt",
|