Spaces:
Running
on
Zero
Running
on
Zero
update app
Browse files
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 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 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 =
|
| 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,
|