Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -138,10 +138,6 @@ model_m = Qwen2_5_VLForConditionalGeneration.from_pretrained(
|
|
| 138 |
trust_remote_code=True,
|
| 139 |
torch_dtype=torch.float16
|
| 140 |
).to(device).eval()
|
| 141 |
-
# --- FIX: Set pad_token_id to silence the warning ---
|
| 142 |
-
if model_m.config.pad_token_id is None:
|
| 143 |
-
model_m.config.pad_token_id = model_m.config.eos_token_id
|
| 144 |
-
|
| 145 |
|
| 146 |
# Load Nanonets-OCR2-1.5B-exp
|
| 147 |
MODEL_ID_N = "strangervisionhf/excess_layer_pruned-nanonets-1.5b"
|
|
@@ -152,9 +148,6 @@ model_n = AutoModelForImageTextToText.from_pretrained(
|
|
| 152 |
torch_dtype=torch.float16,
|
| 153 |
attn_implementation="flash_attention_2"
|
| 154 |
).to(device).eval()
|
| 155 |
-
# --- FIX: Set pad_token_id to silence the warning ---
|
| 156 |
-
if model_n.config.pad_token_id is None:
|
| 157 |
-
model_n.config.pad_token_id = model_n.config.eos_token_id
|
| 158 |
|
| 159 |
|
| 160 |
# Load Dots.OCR from the local, patched directory
|
|
@@ -167,10 +160,6 @@ model_d = AutoModelForCausalLM.from_pretrained(
|
|
| 167 |
device_map="auto",
|
| 168 |
trust_remote_code=True
|
| 169 |
).eval()
|
| 170 |
-
# --- FIX: Set pad_token_id to silence the warning ---
|
| 171 |
-
if model_d.config.pad_token_id is None:
|
| 172 |
-
model_d.config.pad_token_id = model_d.config.eos_token_id
|
| 173 |
-
|
| 174 |
|
| 175 |
# Load PaddleOCR
|
| 176 |
MODEL_ID_P = "strangervisionhf/paddle"
|
|
@@ -180,9 +169,6 @@ model_p = AutoModelForCausalLM.from_pretrained(
|
|
| 180 |
trust_remote_code=True,
|
| 181 |
torch_dtype=torch.bfloat16
|
| 182 |
).to(device).eval()
|
| 183 |
-
# --- FIX: Set pad_token_id to silence the warning ---
|
| 184 |
-
if model_p.config.pad_token_id is None:
|
| 185 |
-
model_p.config.pad_token_id = model_p.config.eos_token_id
|
| 186 |
|
| 187 |
@spaces.GPU
|
| 188 |
def generate_image(model_name: str, text: str, image: Image.Image,
|
|
@@ -286,4 +272,4 @@ with gr.Blocks(css=css, theme=steel_blue_theme) as demo:
|
|
| 286 |
)
|
| 287 |
|
| 288 |
if __name__ == "__main__":
|
| 289 |
-
demo.queue(max_size=50).launch(show_error=True)
|
|
|
|
| 138 |
trust_remote_code=True,
|
| 139 |
torch_dtype=torch.float16
|
| 140 |
).to(device).eval()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
|
| 142 |
# Load Nanonets-OCR2-1.5B-exp
|
| 143 |
MODEL_ID_N = "strangervisionhf/excess_layer_pruned-nanonets-1.5b"
|
|
|
|
| 148 |
torch_dtype=torch.float16,
|
| 149 |
attn_implementation="flash_attention_2"
|
| 150 |
).to(device).eval()
|
|
|
|
|
|
|
|
|
|
| 151 |
|
| 152 |
|
| 153 |
# Load Dots.OCR from the local, patched directory
|
|
|
|
| 160 |
device_map="auto",
|
| 161 |
trust_remote_code=True
|
| 162 |
).eval()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
# Load PaddleOCR
|
| 165 |
MODEL_ID_P = "strangervisionhf/paddle"
|
|
|
|
| 169 |
trust_remote_code=True,
|
| 170 |
torch_dtype=torch.bfloat16
|
| 171 |
).to(device).eval()
|
|
|
|
|
|
|
|
|
|
| 172 |
|
| 173 |
@spaces.GPU
|
| 174 |
def generate_image(model_name: str, text: str, image: Image.Image,
|
|
|
|
| 272 |
)
|
| 273 |
|
| 274 |
if __name__ == "__main__":
|
| 275 |
+
demo.queue(max_size=50).launch(mcp_server=True, ssr_mode=False, show_error=True)
|