Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image processing does't working #9

Closed
vasmarfas opened this issue Jun 20, 2023 · 6 comments
Closed

Image processing does't working #9

vasmarfas opened this issue Jun 20, 2023 · 6 comments

Comments

@vasmarfas
Copy link
Contributor

I started the bot.
Sent the random picture from my gallery
Got this error in terminal:
Error processing file https://api.telegram.org/file/(MY BOT TOKEN)/photos/file_5.jpg: (1, 'Error opening data file /usr/share/tesseract-ocr/4.00/tessdata/script/Devanagari.traineddata Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory. Failed loading language 'script/Devanagari' Tesseract couldn't load any languages! Could not initialize tesseract.')
2023-06-20 17:20:24,208 (async_telebot.py:542 MainThread) ERROR - TeleBot: "Constructor parameter should be str"

I downloaded Devanagari.traineddata, put into /usr/share/tesseract-ocr/4.00/tessdata/
Changed main.py:31 to -> ocr = botocr.OCR(config=" --psm 3 --oem 3 -l Devanagari")
Got this error in terminal:
2023-06-20 17:47:14,734 (async_telebot.py:542 MainThread) ERROR - TeleBot: "Constructor parameter should be str"

How to fix it?

@noes14155
Copy link
Owner

Yes imaginepy API is down. I am looking for an alternative

@noes14155
Copy link
Owner

Fixed

@vasmarfas
Copy link
Contributor Author

If i send picture to bot, i get this error in terminal
Error processing file https://api.telegram.org/file/bot5337896746:AAETEwCAfQPmj_T594ldwp1kxDkA27Xc7ew/photos/file_0.jpg: (1, 'Error opening data file /usr/share/tesseract-ocr/4.00/tessdata/script/Devanagari.traineddata Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory. Failed loading language 'script/Devanagari' Tesseract couldn't load any languages! Could not initialize tesseract.')
ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-10' coro=<Dispatcher._process_polling_updates() done, defined at /usr/local/lib/python3.10/dist-packages/aiogram/dispatcher/dispatcher.py:407> exception=TypeError('Constructor parameter should be str')>
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/aiogram/dispatcher/dispatcher.py", line 415, in _process_polling_updates
for responses in itertools.chain.from_iterable(await self.process_updates(updates, fast)):
File "/usr/local/lib/python3.10/dist-packages/aiogram/dispatcher/dispatcher.py", line 235, in process_updates
return await asyncio.gather(*tasks)
File "/usr/local/lib/python3.10/dist-packages/aiogram/dispatcher/handler.py", line 117, in notify
response = await handler_obj.handler(*args, **partial_data)
File "/usr/local/lib/python3.10/dist-packages/aiogram/dispatcher/dispatcher.py", line 256, in process_update
return await self.message_handlers.notify(update.message)
File "/usr/local/lib/python3.10/dist-packages/aiogram/dispatcher/handler.py", line 117, in notify
response = await handler_obj.handler(*args, **partial_data)
File "/home/ubuntu/Telegrambot-with-GPT4free/main.py", line 277, in imageaudio_handler
text = await bm.generate_imagecaption(image_url,HG_TOKEN)
File "/home/ubuntu/Telegrambot-with-GPT4free/bot/botmedia.py", line 25, in generate_imagecaption
async with session.get(url) as resp1, session.post(self.HG_img2text, headers=headers, data=await resp1.read()) as resp2:
File "/usr/local/lib/python3.10/dist-packages/aiohttp/client.py", line 1141, in aenter
self._resp = await self._coro
File "/usr/local/lib/python3.10/dist-packages/aiohttp/client.py", line 423, in _request
url = self._build_url(str_or_url)
File "/usr/local/lib/python3.10/dist-packages/aiohttp/client.py", line 357, in _build_url
url = URL(str_or_url)
File "/usr/local/lib/python3.10/dist-packages/yarl/_url.py", line 179, in new
raise TypeError("Constructor parameter should be str")
TypeError: Constructor parameter should be str

@noes14155 noes14155 reopened this Jun 25, 2023
@noes14155
Copy link
Owner

Fixed. pronlem from wrong variable name

@vasmarfas
Copy link
Contributor Author

Error again

ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-11' coro=<Dispatcher._process_polling_updates() done, defined at /usr/local/lib/python3.10/dist-packages/aiogram/dispatcher/dispatcher.py:407> exception=TypeError('Constructor parameter should be str')>
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/aiogram/dispatcher/dispatcher.py", line 415, in _process_polling_updates
    for responses in itertools.chain.from_iterable(await self.process_updates(updates, fast)):
  File "/usr/local/lib/python3.10/dist-packages/aiogram/dispatcher/dispatcher.py", line 235, in process_updates
    return await asyncio.gather(*tasks)
  File "/usr/local/lib/python3.10/dist-packages/aiogram/dispatcher/handler.py", line 117, in notify
    response = await handler_obj.handler(*args, **partial_data)
  File "/usr/local/lib/python3.10/dist-packages/aiogram/dispatcher/dispatcher.py", line 256, in process_update
    return await self.message_handlers.notify(update.message)
  File "/usr/local/lib/python3.10/dist-packages/aiogram/dispatcher/handler.py", line 117, in notify
    response = await handler_obj.handler(*args, **partial_data)
  File "/home/ubuntu/Telegrambot-with-GPT4free/main.py", line 255, in imageaudio_handler
    text = await bm.generate_imagecaption(image_url,HG_TOKEN)
  File "/home/ubuntu/Telegrambot-with-GPT4free/bot/botmedia.py", line 26, in generate_imagecaption
    async with session.post(self.HG_img2text, headers=headers, data=await resp1.read()) as resp2:
  File "/usr/local/lib/python3.10/dist-packages/aiohttp/client.py", line 1141, in __aenter__
    self._resp = await self._coro
  File "/usr/local/lib/python3.10/dist-packages/aiohttp/client.py", line 423, in _request
    url = self._build_url(str_or_url)
  File "/usr/local/lib/python3.10/dist-packages/aiohttp/client.py", line 357, in _build_url
    url = URL(str_or_url)
  File "/usr/local/lib/python3.10/dist-packages/yarl/_url.py", line 179, in __new__
    raise TypeError("Constructor parameter should be str")
TypeError: Constructor parameter should be str

@noes14155
Copy link
Owner

Use with the new code or change your env file hgimg2text to HGIMG2TEXT its already changed in the example file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants