ryanzhangfan commited on
Commit
ce50c4e
1 Parent(s): 3c39f43

fix bugs and add constant files

Browse files
Files changed (5) hide show
  1. app.py +2 -3
  2. demo/constants.py +47 -0
  3. demo/generation_frontend.py +2 -2
  4. demo/meta.py +3 -3
  5. demo/utils.py +3 -1
app.py CHANGED
@@ -6,8 +6,8 @@
6
  # Email : zhangfan@baai.ac.cn
7
  # Institute : Beijing Academy of Artificial Intelligence (BAAI)
8
  # Create On : 2023-12-11 15:34
9
- # Last Modified : 2023-12-20 03:59
10
- # File Name : frontend.py
11
  # Description :
12
  #
13
  # ===================================================
@@ -35,7 +35,6 @@ args = parser.parse_args()
35
 
36
  if __name__ == "__main__":
37
  title = "EmuV2: An Open Multimodal Generalist"
38
- os.makedirs("log", exist_ok=True)
39
 
40
  interface_list, tab_names = [], []
41
  if not args.disable_generate:
 
6
  # Email : zhangfan@baai.ac.cn
7
  # Institute : Beijing Academy of Artificial Intelligence (BAAI)
8
  # Create On : 2023-12-11 15:34
9
+ # Last Modified : 2023-12-20 04:10
10
+ # File Name : app.py
11
  # Description :
12
  #
13
  # ===================================================
 
35
 
36
  if __name__ == "__main__":
37
  title = "EmuV2: An Open Multimodal Generalist"
 
38
 
39
  interface_list, tab_names = [], []
40
  if not args.disable_generate:
demo/constants.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ EVA_IMAGE_SIZE = 448
2
+ OPENAI_DATASET_MEAN = (0.48145466, 0.4578275, 0.40821073)
3
+ OPENAI_DATASET_STD = (0.26862954, 0.26130258, 0.27577711)
4
+
5
+ DEFAULT_IMAGE_FILE_SUFFIX = ['jpg', '0.png', 'png', 'jpeg', 'webp']
6
+ DEFAULT_TEXT_FILE_SUFFIX = ['txt', '0.txt']
7
+
8
+ IGNORE_INDEX = -100
9
+
10
+ # special tokens
11
+ # START
12
+ DEFAULT_PAD_TOKEN = "[PAD]"
13
+ DEFAULT_BOS_TOKEN = '<s>'
14
+ DEFAULT_EOS_TOKEN = '</s>'
15
+ DEFAULT_UNK_TOKEN = "<unk>"
16
+
17
+ DEFAULT_IMG_TOKEN = "[IMG]"
18
+ DEFAULT_IMG_END_TOKEN = "[/IMG]"
19
+ DEFAULT_IMAGE_TOKEN = "<image>"
20
+ DEFAULT_gIMG_TOKEN = "[gIMG]"
21
+ DEFAULT_gIMG_END_TOKEN = "[/gIMG]"
22
+ DEFAULT_EOC_TOKEN = "[EOC]"
23
+ DEFAULT_VIDEO_TOKEN = "[VIDEO]"
24
+
25
+ GRD_SYMBOL = "<grounding>"
26
+ BOP_SYMBOL = "<phrase>"
27
+ EOP_SYMBOL = "</phrase>"
28
+ BOO_SYMBOL = "<object>"
29
+ EOO_SYMBOL = "</object>"
30
+ DOM_SYMBOL = "</delimiter_of_multi_objects/>"
31
+
32
+ REC_SYMBOL = "<REC>"
33
+
34
+ USER_TOKEN = "[USER]"
35
+ ASSISTANT_TOKEN = "[ASSISTANT]"
36
+ # END
37
+
38
+ # special token id
39
+ # START
40
+ IMAGE = 32003
41
+ BOI = 32001
42
+ VIDEO = 32004
43
+ # END
44
+
45
+ DEFAULT_IMG_PLACEHOLDER = "[<IMG_PLH>]"
46
+ DEFAULT_VID_PLACEHOLDER = "[<VID_PLH>]"
47
+ FAKE_VIDEO_END_TOKEN = "[/VIDEO]"
demo/generation_frontend.py CHANGED
@@ -6,7 +6,7 @@
6
  # Email : zhangfan@baai.ac.cn
7
  # Institute : Beijing Academy of Artificial Intelligence (BAAI)
8
  # Create On : 2023-12-11 15:35
9
- # Last Modified : 2023-12-19 15:02
10
  # File Name : generation_frontend.py
11
  # Description :
12
  #
@@ -21,7 +21,7 @@ import requests
21
 
22
  import gradio as gr
23
 
24
- from emu.constants import EVA_IMAGE_SIZE
25
  from .meta import ConvMeta, Role, DataMeta
26
  from .utils import frontend_logger as logging
27
 
 
6
  # Email : zhangfan@baai.ac.cn
7
  # Institute : Beijing Academy of Artificial Intelligence (BAAI)
8
  # Create On : 2023-12-11 15:35
9
+ # Last Modified : 2023-12-20 04:09
10
  # File Name : generation_frontend.py
11
  # Description :
12
  #
 
21
 
22
  import gradio as gr
23
 
24
+ from .constants import EVA_IMAGE_SIZE
25
  from .meta import ConvMeta, Role, DataMeta
26
  from .utils import frontend_logger as logging
27
 
demo/meta.py CHANGED
@@ -8,7 +8,7 @@
8
  # Email : zhangfan@baai.ac.cn
9
  # Institute : Beijing Academy of Artificial Intelligence (BAAI)
10
  # Create On : 2023-12-12 02:54
11
- # Last Modified : 2023-12-19 15:00
12
  # File Name : meta.py
13
  # Description :
14
  #
@@ -24,8 +24,8 @@ from typing import List, Tuple
24
  import cv2
25
  import numpy as np
26
 
27
- from emu.constants import EVA_IMAGE_SIZE, GRD_SYMBOL, BOP_SYMBOL, EOP_SYMBOL, BOO_SYMBOL, EOO_SYMBOL
28
- from emu.constants import DEFAULT_VIDEO_TOKEN, DEFAULT_EOS_TOKEN, USER_TOKEN, ASSISTANT_TOKEN, FAKE_VIDEO_END_TOKEN
29
 
30
  from .utils import gen_id, frontend_logger as logging
31
 
 
8
  # Email : zhangfan@baai.ac.cn
9
  # Institute : Beijing Academy of Artificial Intelligence (BAAI)
10
  # Create On : 2023-12-12 02:54
11
+ # Last Modified : 2023-12-20 04:08
12
  # File Name : meta.py
13
  # Description :
14
  #
 
24
  import cv2
25
  import numpy as np
26
 
27
+ from .constants import EVA_IMAGE_SIZE, GRD_SYMBOL, BOP_SYMBOL, EOP_SYMBOL, BOO_SYMBOL, EOO_SYMBOL
28
+ from .constants import DEFAULT_VIDEO_TOKEN, DEFAULT_EOS_TOKEN, USER_TOKEN, ASSISTANT_TOKEN, FAKE_VIDEO_END_TOKEN
29
 
30
  from .utils import gen_id, frontend_logger as logging
31
 
demo/utils.py CHANGED
@@ -6,7 +6,7 @@
6
  # Email : zhangfan@baai.ac.cn
7
  # Institute : Beijing Academy of Artificial Intelligence (BAAI)
8
  # Create On : 2023-12-13 09:48
9
- # Last Modified : 2023-12-14 01:53
10
  # File Name : utils.py
11
  # Description :
12
  #
@@ -16,12 +16,14 @@ from datetime import datetime
16
  import logging
17
  import logging.config
18
  import hashlib
 
19
  import os.path as osp
20
  import uuid
21
  from PIL import Image
22
 
23
  from decord import VideoReader
24
 
 
25
 
26
  def config_logger(logger_name):
27
  logger_config = {
 
6
  # Email : zhangfan@baai.ac.cn
7
  # Institute : Beijing Academy of Artificial Intelligence (BAAI)
8
  # Create On : 2023-12-13 09:48
9
+ # Last Modified : 2023-12-20 04:10
10
  # File Name : utils.py
11
  # Description :
12
  #
 
16
  import logging
17
  import logging.config
18
  import hashlib
19
+ import os
20
  import os.path as osp
21
  import uuid
22
  from PIL import Image
23
 
24
  from decord import VideoReader
25
 
26
+ os.makedirs(osp.join(osp.dirname(__file__), "..", "log"), exist_ok=True)
27
 
28
  def config_logger(logger_name):
29
  logger_config = {