Give me drug having same rasa panchak and group them and drugs having same rasa panchak but with some different make include them also in that group with their change.
cd /tmp/workspace/attachments/22dcdf76-5350-4035-9640-a81911f1fef9/ && python3 -c " import pdfplumber with pdfplumber.open('Dg drugs- Dr.Sujata.pdf') as pdf: print(f'Total pages: {len(pdf.pages)}') for i, page in enumerate(pdf.pages): print(f'\n===== PAGE {i+1} =====') text = page.extract_text() if text: print(text) # Also try tables tables = page.extract_tables() if tables: for t_idx, table in enumerate(tables): print(f'--- TABLE {t_idx+1} ---') for row in table: print(row) "
python3 -c " from pypdf import PdfReader, PdfWriter import os reader = PdfReader('/tmp/workspace/attachments/22dcdf76-5350-4035-9640-a81911f1fef9/Dg drugs- Dr.Sujata.pdf') print(f'Pages: {len(reader.pages)}') # Extract images from pages os.makedirs('/tmp/workspace/pdf_images', exist_ok=True) for page_num, page in enumerate(reader.pages): print(f'Page {page_num+1}: images={len(page.images)}') for img_idx, image in enumerate(page.images): img_path = f'/tmp/workspace/pdf_images/page{page_num+1}_img{img_idx+1}.{image.name.split(\".\")[-1] if \".\" in image.name else \"png\"}' with open(img_path, 'wb') as f: f.write(image.data) print(f' Saved: {img_path} ({len(image.data)} bytes)') "
You need to extract ALL text from 10 image files that are Ayurvedic drug tables. The images are located at: /tmp/workspace/pdf_images/page1_img1.jpg through /tmp/workspace/pdf_images/page10_img1.jpg Use Python with the Pillow library and pytesseract (if available) OR use the fetch_image tool to view each image and manually extract ALL text. IMPORTANT: Use the fetch_image tool to view each image (pass file:// path or use the read_file approach). Actually, use the analyse_media tool with the actual file path formatted as a local URL. Since local file:// URLs don't work for analyse_media, instead: 1. First use read_file or execute to check what Python OCR tools are available 2. Try: execute with python3 using pytesseract, easyocr, or any available OCR library 3. If no OCR available, use fetch_image tool to VIEW each image (fetch_image supports local file paths via file:// - try it) 4. If fetch_image doesn't work with local paths, use execute to convert images to base64 and try another approach The goal: Extract EVERY drug entry from all 10 pages. Each entry should have: - Drug name (Sanskrit/Ayurvedic name) - Rasa (taste/s) - Guna (qualities) - Veerya (potency - Ushna/Sheeta) - Vipaka (post-digestive taste) - Any other properties like Prabhava, Karma, etc. Return the COMPLETE extracted data as structured text, listing every single drug with all its properties. This is for grouping drugs by their "Rasa Panchak" (which is the combination of Rasa + Guna + Veerya + Vipaka + Prabhava - these 5 properties together). Try multiple OCR approaches: 1. pytesseract: import pytesseract; from PIL import Image; text = pytesseract.image_to_string(Image.open('/tmp/workspace/pdf_images/page1_img1.jpg')) 2. easyocr: import easyocr; reader = easyocr.Reader(['en']); result = reader.readtext('/tmp/workspace/pdf_images/page1_img1.jpg') Return ALL extracted text from all 10 pages.
~/pdf_images
python3 -c "import pytesseract; print('pytesseract available:', pytesseract.__version__)" 2>&1; python3 -c "import easyocr; print('easyocr available')" 2>&1; python3 -c "from PIL import Image; print('Pillow available')" 2>&1; which tesseract 2>&1
pip install pytesseract 2>&1 | tail -5; apt-get install -y tesseract-ocr 2>&1 | tail -10
python3 -c "import pytesseract; from PIL import Image; img = Image.open('/tmp/workspace/pdf_images/page1_img1.jpg'); text = pytesseract.image_to_string(img); print(text[:500])" 2>&1
pip install easyocr 2>&1 | tail -5
python3 -c " import easyocr reader = easyocr.Reader(['en']) result = reader.readtext('/tmp/workspace/pdf_images/page1_img1.jpg', detail=0, paragraph=True) for line in result: print(line) " 2>&1 | head -80
python3 -c " from PIL import Image import os for i in range(1, 11): path = f'/tmp/workspace/pdf_images/page{i}_img1.jpg' img = Image.open(path) size = os.path.getsize(path) print(f'page{i}: {img.size[0]}x{img.size[1]} px, {size//1024} KB, mode={img.mode}') "
python3 -c " import easyocr from PIL import Image import numpy as np # Test with page1 - resize to 25% of original size first img = Image.open('/tmp/workspace/pdf_images/page1_img1.jpg') print('Original size:', img.size) # Convert to grayscale to save memory, resize to 30% img_small = img.convert('L').resize((img.width//3, img.height//3), Image.LANCZOS) print('Resized to:', img_small.size) img_array = np.array(img_small) print('Array shape:', img_array.shape, 'dtype:', img_array.dtype) reader = easyocr.Reader(['en'], gpu=False, verbose=False) print('Reader created, now running readtext...') result = reader.readtext(img_array, detail=0, paragraph=False, canvas_size=960, mag_ratio=1.0) print('SUCCESS! Lines found:', len(result)) for line in result[:20]: print(line) " 2>&1 | tail -40
python3 -c " import easyocr from PIL import Image import numpy as np # Try at 50% with canvas_size=640 on just the top half img = Image.open('/tmp/workspace/pdf_images/page1_img1.jpg').convert('RGB') # Crop top quarter w, h = img.size top_quarter = img.crop((0, 0, w, h//4)) print('Top quarter size:', top_quarter.size) img_array = np.array(top_quarter) reader = easyocr.Reader(['en'], gpu=False, verbose=False) result = reader.readtext(img_array, detail=1, paragraph=False, canvas_size=1280, mag_ratio=1.5) print('Lines found:', len(result)) for item in result: bbox, text, conf = item if conf > 0.3: print(f'[{conf:.2f}] {text}') " 2>&1 | tail -50
pip install paddlepaddle paddleocr 2>&1 | tail -5
python3 -c " from paddleocr import PaddleOCR from PIL import Image import numpy as np # Initialize with English only first ocr = PaddleOCR(use_doc_orientation_classify=False, use_doc_unwarping=False, use_textline_orientation=False, lang='en') print('PaddleOCR initialized') # Test on top portion of page1 img = Image.open('/tmp/workspace/pdf_images/page1_img1.jpg') w, h = img.size # Take just first 500 lines (top portion with header) top = img.crop((0, 0, w, 500)) top.save('/tmp/test_crop.jpg') result = ocr.predict('/tmp/test_crop.jpg') print('Result type:', type(result)) print('Result:', result) " 2>&1 | tail -30
Read timeout on endpoint URL: "https://bedrock-agentcore.ap-south-1.amazonaws.com/code-interpreters/orris_code_interpreter-jiK9AacE5I/tools/invoke"
We encountered an error while processing your request. Please try again or reach out to us for help.