|
1 | 1 | # Copyright 2024 The HuggingFace Team. All rights reserved. |
| 2 | +# Copyright (c) Alibaba, Inc. and its affiliates. |
2 | 3 | # |
3 | 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
4 | 5 | # you may not use this file except in compliance with the License. |
|
20 | 21 |
|
21 | 22 |
|
22 | 23 | import inspect |
| 24 | +import math |
| 25 | +import os |
23 | 26 | import re |
| 27 | +import sys |
| 28 | +from functools import partial |
24 | 29 | from typing import Any, Callable, Dict, List, Optional, Tuple, Union |
25 | 30 |
|
26 | 31 | import cv2 |
|
29 | 34 | import torch |
30 | 35 | import torch.nn.functional as F |
31 | 36 | from bert_tokenizer import BasicTokenizer |
| 37 | +from easydict import EasyDict as edict |
32 | 38 | from frozen_clip_embedder_t3 import FrozenCLIPEmbedderT3 |
| 39 | +from ocr_recog.RecModel import RecModel |
33 | 40 | from PIL import Image, ImageDraw, ImageFont |
| 41 | +from safetensors.torch import load_file |
| 42 | +from skimage.transform._geometric import _umeyama as get_sym_mat |
34 | 43 | from torch import nn |
35 | 44 | from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, CLIPVisionModelWithProjection |
36 | 45 |
|
|
102 | 111 | ``` |
103 | 112 | """ |
104 | 113 |
|
105 | | -""" |
106 | | -Copyright (c) Alibaba, Inc. and its affiliates. |
107 | | -""" |
108 | | -from functools import partial |
109 | | - |
110 | | -import torch |
111 | | -import torch.nn as nn |
112 | | -from safetensors.torch import load_file |
113 | | - |
114 | 114 |
|
115 | 115 | def get_clip_token_for_string(tokenizer, string): |
116 | 116 | batch_encoding = tokenizer( |
@@ -205,25 +205,6 @@ def embedding_parameters(self): |
205 | 205 | return self.parameters() |
206 | 206 |
|
207 | 207 |
|
208 | | - |
209 | | -""" |
210 | | -Copyright (c) Alibaba, Inc. and its affiliates. |
211 | | -""" |
212 | | -import math |
213 | | -import os |
214 | | -import sys |
215 | | -import time |
216 | | -import traceback |
217 | | - |
218 | | -import cv2 |
219 | | -import numpy as np |
220 | | -import torch |
221 | | -import torch.nn.functional as F |
222 | | -from easydict import EasyDict as edict |
223 | | -from ocr_recog.RecModel import RecModel |
224 | | -from skimage.transform._geometric import _umeyama as get_sym_mat |
225 | | - |
226 | | - |
227 | 208 | sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) |
228 | 209 |
|
229 | 210 |
|
|
0 commit comments