Image-to-Text
Transformers
Safetensors
Persian
English
nemotron_parse
feature-extraction
bina
ocr
persian
farsi
document-understanding
custom_code
Run this model with HF Jobs
Run Reza2kn/Bina-0.4-Koochik on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/Reza2kn/Bina-0.4-Koochik. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/Reza2kn/Bina-0.4-Koochik on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use Reza2kn/Bina-0.4-Koochik with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Reza2kn/Bina-0.4-Koochik with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "image-to-text" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # pip install "transformers<5.0.0" from transformers import pipeline pipe = pipeline("image-to-text", model="Reza2kn/Bina-0.4-Koochik", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Reza2kn/Bina-0.4-Koochik", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download geometry_client.py from Reza2kn/Bina-0.4-Koochik: direct link, hf CLI and curl.
- Browser
- Download file 2.08 kB
-
https://huggingface.co/Reza2kn/Bina-0.4-Koochik/resolve/main/geometry_client.py
- Command line
-
hf download hf://Reza2kn/Bina-0.4-Koochik/geometry_client.py
-
curl -L -o geometry_client.py https://huggingface.co/Reza2kn/Bina-0.4-Koochik/resolve/main/geometry_client.py
2.08 kB
| """Persistent isolated CPU layout helper; no Surya dependency in the VLM process.""" | |
| import base64,io,json,os,pathlib,select,subprocess,time | |
| ROOT=pathlib.Path(__file__).resolve().parent | |
| class LayoutClient: | |
| def __init__(self):self.process=None;self.log=None | |
| def __call__(self,image): | |
| if self.process is None: | |
| python=pathlib.Path(os.environ.get('BINA_LAYOUT_PYTHON',str(ROOT/'.rizeh-runtime/layout/bin/python'))) | |
| if not python.exists():raise RuntimeError('Run python setup_table_runtime.py --with-layout before table-v3 OCR') | |
| runtime=ROOT/'.rizeh-runtime';runtime.mkdir(exist_ok=True);self.log=(runtime/'layout-worker.log').open('a') | |
| env=os.environ.copy();env.pop('PYTHONPATH',None);env['CUDA_VISIBLE_DEVICES']='' | |
| self.process=subprocess.Popen([str(python),'-u',str(ROOT/'rizeh_table/layout_worker.py')],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=self.log,text=True,env=env) | |
| stream=io.BytesIO();image.save(stream,format='PNG');self.process.stdin.write(json.dumps(dict(image=base64.b64encode(stream.getvalue()).decode()))+'\n');self.process.stdin.flush();tick=time.monotonic() | |
| while not select.select([self.process.stdout],[],[],.5)[0]: | |
| if time.monotonic()-tick>300:self.close();raise TimeoutError('Layout worker exceeded 300 seconds') | |
| line=self.process.stdout.readline() | |
| if not line:raise RuntimeError('Layout worker exited; inspect .rizeh-runtime/layout-worker.log') | |
| reply=json.loads(line) | |
| if not reply['ok']:raise RuntimeError(reply['error']) | |
| return reply['result'] | |
| def close(self): | |
| if self.process is not None: | |
| try:self.process.stdin.close();self.process.wait(timeout=15) | |
| except (subprocess.TimeoutExpired,BrokenPipeError): | |
| self.process.terminate() | |
| try:self.process.wait(timeout=10) | |
| except subprocess.TimeoutExpired:self.process.kill();self.process.wait() | |
| self.process=None | |
| if self.log:self.log.close();self.log=None | |