prithivMLmods commited on
Commit
decd76c
·
verified ·
1 Parent(s): 13b8121

update app

Browse files
Files changed (1) hide show
  1. app.py +31 -33
app.py CHANGED
@@ -122,38 +122,36 @@ if torch.cuda.is_available():
122
 
123
  print("Using device:", device)
124
 
125
- CACHE_PATH = "./model_cache"
126
- if not os.path.exists(CACHE_PATH):
127
- os.makedirs(CACHE_PATH)
128
-
129
-
130
- model_path_d_local = snapshot_download(
131
- repo_id='rednote-hilab/dots.ocr',
132
- local_dir=os.path.join(CACHE_PATH, 'dots.ocr'),
133
- max_workers=20,
134
- local_dir_use_symlinks=False
135
- )
136
-
137
- config_file_path = os.path.join(model_path_d_local, "configuration_dots.py")
138
-
139
- if os.path.exists(config_file_path):
140
- with open(config_file_path, 'r') as f:
141
- input_code = f.read()
142
-
143
- lines = input_code.splitlines()
144
- if "class DotsVLProcessor" in input_code and not any("attributes = " in line for line in lines):
145
- output_lines = []
146
- for line in lines:
147
- output_lines.append(line)
148
- if line.strip().startswith("class DotsVLProcessor"):
149
- output_lines.append(" attributes = [\"image_processor\", \"tokenizer\"]")
150
-
151
- with open(config_file_path, 'w') as f:
152
- f.write('\n'.join(output_lines))
153
- print("Patched configuration_dots.py successfully.")
154
-
155
-
156
- sys.path.append(model_path_d_local)
157
 
158
  MAX_MAX_NEW_TOKENS = 4096
159
  DEFAULT_MAX_NEW_TOKENS = 2048
@@ -180,7 +178,7 @@ model_x = Qwen2_5_VLForConditionalGeneration.from_pretrained(
180
  ).to(device).eval()
181
 
182
  # Load Dots.OCR from the local, patched directory
183
- MODEL_PATH_D = model_path_d_local
184
  processor_d = AutoProcessor.from_pretrained(MODEL_PATH_D, trust_remote_code=True)
185
  model_d = AutoModelForCausalLM.from_pretrained(
186
  MODEL_PATH_D,
 
122
 
123
  print("Using device:", device)
124
 
125
+ # CACHE_PATH = "./model_cache"
126
+ # if not os.path.exists(CACHE_PATH):
127
+ # os.makedirs(CACHE_PATH)
128
+ #
129
+ # model_path_d_local = snapshot_download(
130
+ # repo_id='rednote-hilab/dots.ocr',
131
+ # local_dir=os.path.join(CACHE_PATH, 'dots.ocr'),
132
+ # max_workers=20,
133
+ # local_dir_use_symlinks=False
134
+ # )
135
+ #
136
+ # config_file_path = os.path.join(model_path_d_local, "configuration_dots.py")
137
+ #
138
+ # if os.path.exists(config_file_path):
139
+ # with open(config_file_path, 'r') as f:
140
+ # input_code = f.read()
141
+ #
142
+ # lines = input_code.splitlines()
143
+ # if "class DotsVLProcessor" in input_code and not any("attributes = " in line for line in lines):
144
+ # output_lines = []
145
+ # for line in lines:
146
+ # output_lines.append(line)
147
+ # if line.strip().startswith("class DotsVLProcessor"):
148
+ # output_lines.append(" attributes = [\"image_processor\", \"tokenizer\"]")
149
+ #
150
+ # with open(config_file_path, 'w') as f:
151
+ # f.write('\n'.join(output_lines))
152
+ # print("Patched configuration_dots.py successfully.")
153
+ #
154
+ #sys.path.append(model_path_d_local)
 
 
155
 
156
  MAX_MAX_NEW_TOKENS = 4096
157
  DEFAULT_MAX_NEW_TOKENS = 2048
 
178
  ).to(device).eval()
179
 
180
  # Load Dots.OCR from the local, patched directory
181
+ MODEL_PATH_D = "strangervisionhf/dots.ocr-base-fix"
182
  processor_d = AutoProcessor.from_pretrained(MODEL_PATH_D, trust_remote_code=True)
183
  model_d = AutoModelForCausalLM.from_pretrained(
184
  MODEL_PATH_D,