Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files16 unmodified lines17181920212223242526272829303119 unmodified lines515253495054555657581 unmodified line606162585960616364656667686970717236 unmodified lines10911011110611211311410911511611711846 unmodified lines16516616716216816917016517117217317493 unmodified lines26826927026527127227327416 unmodified lines Qwen2_5_VLForConditionalGeneration, Qwen2VLForConditionalGeneration, AutoProcessor, AutoTokenizer, TextIteratorStreamer,)from transformers.image_utils import load_image
import subprocesssubprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
# Constants for text generationMAX_MAX_NEW_TOKENS = 2048DEFAULT_MAX_NEW_TOKENS = 102419 unmodified lines torch_dtype=torch.float16).to(device).eval()
# Load RelaxedMODEL_ID_Z = "Qwen/Qwen2.5-VL-3B-Instruct"# Load Space ThinkerMODEL_ID_Z = "remyxai/SpaceThinker-Qwen2.5VL-3B"processor_z = AutoProcessor.from_pretrained(MODEL_ID_Z, trust_remote_code=True)model_z = Qwen2_5_VLForConditionalGeneration.from_pretrained( MODEL_ID_Z,1 unmodified line torch_dtype=torch.float16).to(device).eval()
# Load ImageScopeMODEL_ID_T = "prithivMLmods/Imgscope-OCR-2B-0527"processor_t = AutoProcessor.from_pretrained(MODEL_ID_X, trust_remote_code=True)model_t = Qwen2VLForConditionalGeneration.from_pretrained(# Load moondreamMODEL_ID_T = "moondream/moondream-2b-2025-04-14-4bit"processor_t = AutoTokenizer.from_pretrained(MODEL_ID_X, trust_remote_code=True)model_t = AutoModelForCausalLM.from_pretrained( MODEL_ID_T, trust_remote_code=True, attn_implementation="flash_attention_2", torch_dtype=torch.float16).to(device).eval()
36 unmodified lines elif model_name == "coreOCR-7B-050325-preview": processor = processor_x model = model_x elif model_name == "Qwen2.5-VL-3B": elif model_name == "SpaceThinker-Qwen2.5VL-3B": processor = processor_z model = model_z elif model_name == "Imgscope-OCR-2B": elif model_name == "moondream-2b-2025-04-14-4bit": processor = processor_t model = model_t else:46 unmodified lines elif model_name == "coreOCR-7B-050325-preview": processor = processor_x model = model_x elif model_name == "Qwen2.5-VL-3B": elif model_name == "SpaceThinker-Qwen2.5VL-3B": processor = processor_z model = model_z elif model_name == "Imgscope-OCR-2B": elif model_name == "moondream-2b-2025-04-14-4bit": processor = processor_t model = model_t else:93 unmodified lines with gr.Column(): output = gr.Textbox(label="Output", interactive=False, lines=2, scale=2) model_choice = gr.Radio( choices=["coreOCR-7B-050325-preview", "typhoon-ocr-7b", "Qwen2.5-VL-3B", "Imgscope-OCR-2B"], choices=["coreOCR-7B-050325-preview", "typhoon-ocr-7b", "SpaceThinker-Qwen2.5VL-3B", "moondream-2b-2025-04-14-4bit"], label="Select Model", value="coreOCR-7B-050325-preview" )app.py+17-11