someone

joined 3 weeks ago
[–] someone@lemmy.today 1 points 1 hour ago (1 children)

I don't understand what venv is or why this would work better. Will this make the compatibility issues go away? I could also just create a virtual Ubuntu environment that's fresh if that would be easier and try to give that environment access to my GPU but I don't know if that would work.

[–] someone@lemmy.today 1 points 4 hours ago (1 children)

because it's encrypted by https and my VPN has a decent reputation. Yes, it's possible that the VPN is secretly selling everything they can to big data, but if it were exposed then it would ruin their entire business.

[–] someone@lemmy.today 1 points 4 hours ago

That's exactly what I am trying to do, I'm just not that sure how to do it. I have the hardware needed, I just need to set up a docker with PyTorch and then find a way to set up Gradio inside that and then add TrOCR from hugging face, and then I'm good. I just am not totally sure how to do that and it seems hard, and when I ask AI for advice, it often is like "just run the following" and it's wrong, and I'm not skilled enough to know why.

[–] someone@lemmy.today 13 points 4 hours ago (2 children)

I disagree. I really think you are underestimating how much Americans, especially American men, especial rural men who hunt and don't like being bossed around by a government that's far away, want to buy whatever weapons they want without extra regulation.

For many people, they vote just based on the NRA's selection. If the Democrats became a more pro-gun party, they would gain a substantial amount of power in the US.

[–] someone@lemmy.today 6 points 1 day ago (1 children)

I previously tried to commit suicide when I was younger and was involuntarily hospitalized. As a result I'm a prohibited person. I can't legally buy a firearm. This makes it harder for me to protect myself if things get worse. I don't know if voting in my liberal community is going to change anything.

[–] someone@lemmy.today 0 points 1 day ago* (last edited 1 day ago) (2 children)

I don't trust big tech to not extract data and metadata and save it. Many companies get served with government requests to save data and keep it secret. Even if handwritingocr.com doesn't have such an agreement, it could run on AWS and that has an agreement. I would much rather do this locally. Some of the writings are confidential. Handwritingocr.com says data is encrypted in transit and at rest, but it's not open source and even if it were I can't verify the server code.

also Tesseract is CPU only, right? It will be so slow.

[–] someone@lemmy.today 0 points 1 day ago (3 children)

So try again... in a couple of hours...

Why would that make a difference? It's a local model right?

[–] someone@lemmy.today 6 points 1 day ago

I'm pragmatic. If a Tornado is coming towards me, I don't try to rush into the eye to fight it. I change things I can, flee the things I can't.

[–] someone@lemmy.today 0 points 1 day ago* (last edited 1 day ago) (5 children)

Terminal error after running GPT code:



python3 trocr_pdf.py small.pdf output.txt
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.10/site-packages/transformers/utils/hub.py", line 479, in cached_files
    hf_hub_download(
  File "/home/user/.local/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
    return fn(*args, **kwargs)
  File "/home/user/.local/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1007, in hf_hub_download
    return _hf_hub_download_to_cache_dir(
  File "/home/user/.local/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1124, in _hf_hub_download_to_cache_dir
    os.makedirs(os.path.dirname(blob_path), exist_ok=True)
  File "/usr/lib/python3.10/os.py", line 215, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "/usr/lib/python3.10/os.py", line 225, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/home/user/.cache/huggingface/hub/models--microsoft--trocr-base-handwritten'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/user/Documents/trocr_pdf.py", line 39, in <module>
    main(pdf_path, out_path)
  File "/home/user/Documents/trocr_pdf.py", line 11, in main
    processor = TrOCRProcessor.from_pretrained(model_name)
  File "/home/user/.local/lib/python3.10/site-packages/transformers/processing_utils.py", line 1394, in from_pretrained
    args = cls._get_arguments_from_pretrained(pretrained_model_name_or_path, **kwargs)
  File "/home/user/.local/lib/python3.10/site-packages/transformers/processing_utils.py", line 1453, in _get_arguments_from_pretrained
    args.append(attribute_class.from_pretrained(pretrained_model_name_or_path, **kwargs))
  File "/home/user/.local/lib/python3.10/site-packages/transformers/models/auto/image_processing_auto.py", line 489, in from_pretrained
    raise initial_exception
  File "/home/user/.local/lib/python3.10/site-packages/transformers/models/auto/image_processing_auto.py", line 476, in from_pretrained
    config_dict, _ = ImageProcessingMixin.get_image_processor_dict(
  File "/home/user/.local/lib/python3.10/site-packages/transformers/image_processing_base.py", line 333, in get_image_processor_dict
    resolved_image_processor_files = [
  File "/home/user/.local/lib/python3.10/site-packages/transformers/image_processing_base.py", line 337, in <listcomp>
    resolved_file := cached_file(
  File "/home/user/.local/lib/python3.10/site-packages/transformers/utils/hub.py", line 322, in cached_file
    file = cached_files(path_or_repo_id=path_or_repo_id, filenames=[filename], **kwargs)
  File "/home/user/.local/lib/python3.10/site-packages/transformers/utils/hub.py", line 524, in cached_files
    raise OSError(
OSError: PermissionError at /home/user/.cache/huggingface/hub/models--microsoft--trocr-base-handwritten when downloading microsoft/trocr-base-handwritten. Check cache directory permissions. Common causes: 1) another user is downloading the same model (please wait); 2) a previous download was canceled and the lock file needs manual removal.

LLMs are so bad at code sometimes. This happens all the time time with LLMs and code for me, the code is unusable and it saves no time because it's a rabbit hole leading to nowhere.

I also don't know if this is the right approach to the problem. Any sort of GUI interface would be easier. This is also hundreds of pages of handwritten stuff I want to change to text.

[–] someone@lemmy.today 0 points 1 day ago* (last edited 1 day ago) (10 children)

that's not for TrOCR, it's just for OCR, which may not work for handwriting

I did try some of the GPT steps:

pip install --upgrade transformers pillow pdf2image

getting some errors:

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╺━━━━━━━━━ 3/4 [transformers]  WARNING: The scripts transformers and transformers-cli are installed in '/home/user/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
mistral-common 1.5.2 requires pillow<11.0.0,>=10.3.0, but you have pillow 12.1.0 which is incompatible.
moviepy 2.1.2 requires pillow<11.0,>=9.2.0, but you have pillow 12.1.0 which is incompatible.


this is what GPT said to run, but it makes no sense because I don't have TrOCR even downloaded or running at all.

Install packages: pip install --upgrade transformers pillow pdf2image
Ensure poppler is installed:

Ubuntu/Debian: sudo apt install -y poppler-utils
macOS: brew install poppler

Execute: python3 trocr_pdf.py input.pdf output.txt

That's the script to save and run.

#!/usr/bin/env python3
import sys
from pdf2image import convert_from_path
from PIL import Image
import torch
from transformers import TrOCRProcessor, VisionEncoderDecoderModel

def main(pdf_path, out_path="output.txt", dpi=300):
    device = "cuda" if torch.cuda.is_available() else "cpu"
    model_name = "microsoft/trocr-base-handwritten"
    processor = TrOCRProcessor.from_pretrained(model_name)
    model = VisionEncoderDecoderModel.from_pretrained(model_name).to(device)

    pages = convert_from_path(pdf_path, dpi=dpi)
    results = []
    for i, page in enumerate(pages, 1):
        page = page.convert("RGB")
        # downscale if very large to avoid OOM
        max_dim = 1600
        if max(page.width, page.height) > max_dim:
            scale = max_dim / max(page.width, page.height)
            page = page.resize((int(page.width*scale), int(page.height*scale)), Image.Resampling.LANCZOS)

        pixel_values = processor(images=page, return_tensors="pt").pixel_values.to(device)
        generated_ids = model.generate(pixel_values, max_length=512)
        text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
        results.append(f"--- Page {i} ---\n{text.strip()}\n")

    with open(out_path, "w", encoding="utf-8") as f:
        f.write("\n".join(results))
    print(f"Saved OCR text to {out_path}")

if __name__ == "__main__":
    if len(sys.argv) < 2:
        print("Usage: python3 trocr_pdf.py input.pdf [output.txt]")
        sys.exit(1)
    pdf_path = sys.argv[1]
    out_path = sys.argv[2] if len(sys.argv) > 2 else "output.txt"
    main(pdf_path, out_path)

[–] someone@lemmy.today 0 points 1 day ago (12 children)

I don't remember exactly, but I have rocm 7.2 installed, and there was something I was trying to install inside pip for rocm and it just wouldn't work, it was like 7.2 rocm wasn't out or the link didn't work. The LLM tried multiple suggestion and they all failed, then I gave up. When I said "inside" pip, I don't know if that's accurate. I am very knew to pip and am decent at linux and only know a small amount of coding and lack python familiarity.

[–] someone@lemmy.today 21 points 1 day ago (3 children)

Lots of people laughing in Germany in the 30s at people fleeing weren't laughing in the 40s.

 

I have different technical questions I want to ask. I went to Stack Overflow and they blocked registration with a VPN. It's really fucking annoying. I can buy a residential IP to bypass this, but I'd rather just not use these enshitified platforms that are so hostile to VPNs.

Is there any decent alternative to Stack Overflow? I have tried getting AI answers to the technical question but they are not good.

And no, I can't just create a github ID using VPN to login, they block github logins based on IP also.

 

The situation in Iran, with no internet and jamming set up to try to even block Starlink, seems exactly the situation for which Briar was made.

Is Briar technically feasible to use in Iran or is this too problematic because of jamming of WiFi and other signals?

Is this the sort of thing where someone with access to a Starlink could download Briar from F-droid and share the apk via USB or is that not possible with Iranian cell phones?

I am asking as someone who isn't sure whether jamming can also block bluetooth signals.


Warning - use caution. Using Bluetooth or sideloaded apps like Briar may work where internet and Starlink are jammed, but jamming, detection, or device inspection can still expose users. Sharing or installing such apps could put people at serious legal or physical risk. This post only asks whether using Briar in these conditions would be helpful; it is not a recommendation or endorsement. Assess local risks before acting.

هشدار - احتیاط کنید. استفاده از بلوتوث یا نصب جانبی برنامه‌هایی مثل بریر ممکن است در شرایطی که اینترنت و استارلینک پارازیت‌دار شده‌اند کارایی داشته باشد، اما پارازیت، کشف یا بازرسی دستگاه‌ها می‌تواند کاربران را لو دهد. به‌اشتراک‌گذاری یا نصب چنین برنامه‌هایی ممکن است افراد را در معرض خطر قانونی یا جسمی جدی قرار دهد. این پست صرفاً می‌پرسد آیا استفاده از بریر در این شرایط مفید خواهد بود یا نه؛ توصیه یا تایید آن نیست. پیش از اقدام، خطرات محلی را ارزیابی کنید.***

Would the following be helpful if the information could get to Iranians or would they already know about stuff like this?

وضعیت در ایران، با قطع اینترنت و ایجاد پارازیت به‌گونه‌ای که حتی تلاش می‌شود استارلینک هم مسدود شود، دقیقاً همان وضعیتی است که برای آن بریر ساخته شده است.

آیا از نظر فنی استفاده از بریر در ایران ممکن است یا اینکه پارازیت روی وای‌فای و سایر سیگنال‌ها این کار را بیش از حد مشکل می‌کند؟

آیا این‌طور است که کسی که به استارلینک دسترسی دارد می‌تواند بریر را از F‑Droid دانلود کند و فایل apk را از طریق USB به دیگران منتقل کند، یا این با گوشی‌های ایرانی ممکن نیست؟

من این را می‌پرسم چون مطمئن نیستم که پارازیت بتواند سیگنال‌های بلوتوث را هم مسدود کند.

در اینجا یک راهنمای گام‌به‌گام به فارسی برای دانلود و نصب (sideload) فایل APK بریر از طریق Starlink یا انتقال از طریق USB/کارت حافظه، همراه با چک‌های لازم برای معماری CPU و مجوزها:

گام 1 — آماده‌سازی دانلود

  1. از طریق دستگاهی که به اینترنت (مثلاً Starlink) دسترسی دارد، به یکی از منابع رسمی بروید:
  2. دانلود نسخه APK متناسب با نسخه بریر (نسخه پایدار را انتخاب کنید).

گام 2 — بررسی معماری CPU اندروید

  1. راه ساده: روی گوشی مقصد اپلیکیشن CPU‑Z یا Droid Hardware Info را نصب کنید (در صورت امکان) و در بخش CPU معماری را ببینید (ARM64, armeabi-v7a, x86 و غیره).
  2. اگر امکان نصب اپ دیگر نیست، بیشتر گوشی‌های مدرن اندروید امروز ARM64 (aarch64) هستند — اگر گوشی جدیدتر است احتمالاً ARM64 است.
  3. در F‑Droid معمولاً نسخه‌های عمومی برای معماری‌های رایج عرضه می‌شود؛ فایل APK معمولی اغلب با اکثر گوشی‌های ARM سازگار است، اما اگر نسخه مجزا وجود داشته باشد، APK مناسب را انتخاب کنید.

گام 3 — انتقال APK به گوشی بدون اینترنت گزینه A — انتقال از طریق USB:

  1. با کابل USB گوشی را به کامپیوتر متصل کنید.
  2. در گوشی حالت اتصال را روی “File Transfer (MTP)” قرار دهید.
  3. فایل APK را در پوشه Downloads یا یک پوشه دلخواه کپی کنید.
  4. از اتصال امن (قابل اعتماد) استفاده کنید و پس از انتقال کابل را جدا کنید.

گزینه B — کارت حافظه (microSD):

  1. فایل APK را روی کارت microSD کپی کنید.
  2. کارت را در گوشی قرار دهید و فایل را از برنامه Files یا File Manager پیدا کنید.

گزینه C — انتقال مستقیم بین اندروید‌ها:

  1. از Bluetooth فایل را ارسال کنید (اگر کار کند) یا از کابل USB‑OTG و فلش USB با آداپتور استفاده کنید.

گام 4 — فعال‌سازی نصب از منابع نامعلوم

  1. در اندرویدهای جدید: تنظیمات → Apps → Special app access → Install unknown apps → برنامه‌ای که فایل APK را باز می‌کنید (Files/Browser) را انتخاب و “Allow from this source” را فعال کنید.
  2. در اندرویدهای قدیمی: Settings → Security → تیک “Unknown sources” را بزنید.

گام 5 — نصب APK

  1. با File Manager به محلی که APK قرار دارد بروید.
  2. فایل APK را لمس کنید و دستور نصب را دنبال کنید.
  3. اگر پیغام امضا/نسخه قدیمی‌تر ظاهر شد، اجازه دهید نصب جایگزین شود (یا بهتر است از نسخه رسمی و به‌روز استفاده کنید).

گام 6 — بررسی امضا و منبع (امنیت)

  1. ترجیحاً APK را از وب‌سایت رسمی یا F‑Droid بگیرید تا مطمئن شوید فایل دستکاری نشده است.
  2. اگر با F‑Droid کار می‌کنید، بهتر است ابتدا خودِ اپ F‑Droid را نصب کرده و از طریق آن Briar را مدیریت کنید (بروزرسانی و اعتبار بسته).

گام 7 — مجوزها و تنظیمات Briar

  1. پس از نصب، به مجوزهای مورد نیاز (Bluetooth، Nearby devices، Storage در صورت نیاز) دقت کنید و فقط مجوزهای لازم را بدهید.
  2. فعال‌سازی Bluetooth و/یا Wi‑Fi Direct وقتی می‌خواهید همگام‌سازی محلی انجام دهید.

نکات عملی و احتیاط‌ها

  • اگر گوشی قفل‌شده یا مدیریت شده (MDM) باشد ممکن است نصب APK از منابع نامعلوم غیرفعال باشد. در این حالت نیاز به دسترسی بیشتر یا مدل گوشی متفاوت دارید.
  • اگر نگران شنود یا شناسایی هستید، Bluetooth/Wi‑Fi را فقط هنگام نیاز روشن کنید و پس از انتقال خاموش کنید.
  • برای بروزرسانی‌ها، اگر دسترسی اینترنت دارید از داخل F‑Droid یا سایت رسمی به‌صورت دوره‌ای نسخه جدید را دانلود کنید.
  • اگر نمی‌دانید معماری CPU، اغلب ARM64 را امتحان کنید (بیشترین احتمال سازگاری با گوشی‌های جدید).

اگر می‌خواهید، می‌توانم:

  • متن دقیق پیام برای توضیح نحوه فعال کردن “Install unknown apps” برای نسخه خاص اندروید (مثلاً Android 12 یا 13) بنویسم، یا
  • لینک مستقیم به صفحه دانلود Briar برای شما آماده کنم.

در اینجا یک راهنمای گام‌به‌گام به فارسی برای دانلود و نصب (sideload) فایل APK بریر از طریق Starlink یا انتقال از طریق USB/کارت حافظه، همراه با چک‌های لازم برای معماری CPU و مجوزها:

گام 1 — آماده‌سازی دانلود

  1. از طریق دستگاهی که به اینترنت (مثلاً Starlink) دسترسی دارد، به یکی از منابع رسمی بروید:
  2. دانلود نسخه APK متناسب با نسخه بریر (نسخه پایدار را انتخاب کنید).

گام 2 — بررسی معماری CPU اندروید

  1. راه ساده: روی گوشی مقصد اپلیکیشن CPU‑Z یا Droid Hardware Info را نصب کنید (در صورت امکان) و در بخش CPU معماری را ببینید (ARM64, armeabi-v7a, x86 و غیره).
  2. اگر امکان نصب اپ دیگر نیست، بیشتر گوشی‌های مدرن اندروید امروز ARM64 (aarch64) هستند — اگر گوشی جدیدتر است احتمالاً ARM64 است.
  3. در F‑Droid معمولاً نسخه‌های عمومی برای معماری‌های رایج عرضه می‌شود؛ فایل APK معمولی اغلب با اکثر گوشی‌های ARM سازگار است، اما اگر نسخه مجزا وجود داشته باشد، APK مناسب را انتخاب کنید.

گام 3 — انتقال APK به گوشی بدون اینترنت گزینه A — انتقال از طریق USB:

  1. با کابل USB گوشی را به کامپیوتر متصل کنید.
  2. در گوشی حالت اتصال را روی “File Transfer (MTP)” قرار دهید.
  3. فایل APK را در پوشه Downloads یا یک پوشه دلخواه کپی کنید.
  4. از اتصال امن (قابل اعتماد) استفاده کنید و پس از انتقال کابل را جدا کنید.

گزینه B — کارت حافظه (microSD):

  1. فایل APK را روی کارت microSD کپی کنید.
  2. کارت را در گوشی قرار دهید و فایل را از برنامه Files یا File Manager پیدا کنید.

گزینه C — انتقال مستقیم بین اندروید‌ها:

  1. از Bluetooth فایل را ارسال کنید (اگر کار کند) یا از کابل USB‑OTG و فلش USB با آداپتور استفاده کنید.

گام 4 — فعال‌سازی نصب از منابع نامعلوم

  1. در اندرویدهای جدید: تنظیمات → Apps → Special app access → Install unknown apps → برنامه‌ای که فایل APK را باز می‌کنید (Files/Browser) را انتخاب و “Allow from this source” را فعال کنید.
  2. در اندرویدهای قدیمی: Settings → Security → تیک “Unknown sources” را بزنید.

گام 5 — نصب APK

  1. با File Manager به محلی که APK قرار دارد بروید.
  2. فایل APK را لمس کنید و دستور نصب را دنبال کنید.
  3. اگر پیغام امضا/نسخه قدیمی‌تر ظاهر شد، اجازه دهید نصب جایگزین شود (یا بهتر است از نسخه رسمی و به‌روز استفاده کنید).

گام 6 — بررسی امضا و منبع (امنیت)

  1. ترجیحاً APK را از وب‌سایت رسمی یا F‑Droid بگیرید تا مطمئن شوید فایل دستکاری نشده است.
  2. اگر با F‑Droid کار می‌کنید، بهتر است ابتدا خودِ اپ F‑Droid را نصب کرده و از طریق آن Briar را مدیریت کنید (بروزرسانی و اعتبار بسته).

گام 7 — مجوزها و تنظیمات Briar

  1. پس از نصب، به مجوزهای مورد نیاز (Bluetooth، Nearby devices، Storage در صورت نیاز) دقت کنید و فقط مجوزهای لازم را بدهید.
  2. فعال‌سازی Bluetooth و/یا Wi‑Fi Direct وقتی می‌خواهید همگام‌سازی محلی انجام دهید.

نکات عملی و احتیاط‌ها

  • اگر گوشی قفل‌شده یا مدیریت شده (MDM) باشد ممکن است نصب APK از منابع نامعلوم غیرفعال باشد. در این حالت نیاز به دسترسی بیشتر یا مدل گوشی متفاوت دارید.
  • اگر نگران شنود یا شناسایی هستید، Bluetooth/Wi‑Fi را فقط هنگام نیاز روشن کنید و پس از انتقال خاموش کنید.
  • برای بروزرسانی‌ها، اگر دسترسی اینترنت دارید از داخل F‑Droid یا سایت رسمی به‌صورت دوره‌ای نسخه جدید را دانلود کنید.
  • اگر نمی‌دانید معماری CPU، اغلب ARM64 را امتحان کنید (بیشترین احتمال سازگاری با گوشی‌های جدید).

اگر می‌خواهید، می‌توانم:

  • متن دقیق پیام برای توضیح نحوه فعال کردن “Install unknown apps” برای نسخه خاص اندروید (مثلاً Android 12 یا 13) بنویسم، یا
  • لینک مستقیم به صفحه دانلود Briar برای شما آماده کنم.
view more: next ›