15 Commits

Author SHA1 Message Date
Vik Paruchuri
cba67c6d15 Merge pull request #47 from datalab-to/dev
Shift import
2025-11-19 12:19:23 -05:00
Vik Paruchuri
c049e7524f Shift import 2025-11-19 12:18:57 -05:00
Vik Paruchuri
7ac08e16e1 Merge pull request #46 from datalab-to/dev
Hide imports
2025-11-19 12:06:47 -05:00
Vik Paruchuri
b96eb84094 Hide imports 2025-11-19 12:06:07 -05:00
Vik Paruchuri
7d967717a3 Merge pull request #41 from datalab-to/dev
Enable piping through params
2025-11-12 18:06:41 -05:00
Vik Paruchuri
94786516c8 Merge pull request #40 from datalab-to/dev
fix issue with pop
2025-11-12 17:34:47 -05:00
Vik Paruchuri
c735484ad4 Merge pull request #39 from datalab-to/dev
Enable passing bbox scale
2025-11-12 17:17:34 -05:00
Vik Paruchuri
914d508ddd Merge pull request #38 from datalab-to/dev
Add a small sleep
2025-11-12 16:06:21 -05:00
Vik Paruchuri
f04e0d146b Merge pull request #37 from datalab-to/dev
Dev
2025-11-12 16:03:23 -05:00
Vik Paruchuri
393d3d53f4 Merge pull request #32 from datalab-to/dev
Dev
2025-11-10 11:37:06 -05:00
Vik Paruchuri
5330679cf3 Merge pull request #22 from datalab-to/dev
Dev
2025-11-03 17:16:02 -05:00
Vik Paruchuri
b6320b09bd Merge pull request #10 from datalab-to/dev
Enable passing custom headers
2025-10-30 10:21:48 -04:00
Vik Paruchuri
b99aa32e19 Merge pull request #9 from datalab-to/dev
Improve robustness
2025-10-29 18:17:02 -04:00
Vik Paruchuri
ba6a5f71da Merge pull request #6 from datalab-to/dev
Change image rendering
2025-10-26 10:40:23 -04:00
Vik Paruchuri
57cb163663 Merge pull request #2 from datalab-to/dev
Dev
2025-10-23 16:55:57 -04:00
3 changed files with 7 additions and 45 deletions

View File

@@ -1,8 +1,5 @@
from typing import List
from qwen_vl_utils import process_vision_info
from transformers import Qwen3VLForConditionalGeneration, Qwen3VLProcessor
from chandra.model.schema import BatchInputItem, GenerationResult
from chandra.model.util import scale_to_fit
from chandra.prompts import PROMPT_MAPPING
@@ -16,6 +13,8 @@ def generate_hf(
bbox_scale: int = settings.BBOX_SCALE,
**kwargs,
) -> List[GenerationResult]:
from qwen_vl_utils import process_vision_info
if max_output_tokens is None:
max_output_tokens = settings.MAX_OUTPUT_TOKENS
@@ -71,12 +70,15 @@ def process_batch_element(item: BatchInputItem, processor, bbox_scale: int):
def load_model():
import torch
from transformers import Qwen3VLForConditionalGeneration, Qwen3VLProcessor
device_map = "auto"
if settings.TORCH_DEVICE:
device_map = {"": settings.TORCH_DEVICE}
kwargs = {
"dtype": settings.TORCH_DTYPE,
"dtype": torch.bfloat16,
"device_map": device_map,
}
if settings.TORCH_ATTN:

View File

@@ -6,7 +6,7 @@ from functools import lru_cache
import six
from PIL import Image
from bs4 import BeautifulSoup, NavigableString
from bs4 import BeautifulSoup
from markdownify import MarkdownConverter, re_whitespace
from chandra.settings import settings
@@ -89,39 +89,6 @@ def parse_html(
return out_html
def escape_dollars(text):
return text.replace("$", r"\$")
def get_formatted_table_text(element):
text = []
for content in element.contents:
if content is None:
continue
if isinstance(content, NavigableString):
stripped = content.strip()
if stripped:
text.append(escape_dollars(stripped))
elif content.name == "br":
text.append("<br>")
elif content.name == "math":
text.append("$" + content.text + "$")
else:
content_str = escape_dollars(str(content))
text.append(content_str)
full_text = ""
for i, t in enumerate(text):
if t == "<br>":
full_text += t
elif i > 0 and text[i - 1] != "<br>":
full_text += " " + t
else:
full_text += t
return full_text
class Markdownify(MarkdownConverter):
def __init__(
self,

View File

@@ -1,7 +1,5 @@
from dotenv import find_dotenv
from pydantic import computed_field
from pydantic_settings import BaseSettings
import torch
import os
@@ -24,11 +22,6 @@ class Settings(BaseSettings):
VLLM_GPUS: str = "0"
MAX_VLLM_RETRIES: int = 6
@computed_field
@property
def TORCH_DTYPE(self) -> torch.dtype:
return torch.bfloat16
class Config:
env_file = find_dotenv("local.env")
extra = "ignore"