CCExtractor / Rekognition

Free and Open Source alternative to Amazon's Rekognition service. CCExtractor Development | Poor Man's Rekognition
GNU General Public License v3.0
98 stars 52 forks source link

SceneText fails with ValueError #194

Closed MauryaRitesh closed 2 years ago

MauryaRitesh commented 2 years ago

SceneText works fine with some images while it throws a ValueError for some other images

To Reproduce Steps to reproduce the behavior:

  1. Download the Text Localization (2015 edition) Dataset (or use some random images) for testing.

  2. Make a request to the Text Extraction API: curl -i -X POST -H "Content-Type: multipart/form-data " -F "file=@/home/archi/Downloads/img/img_26.jpg " http://127.0.0.1:8000/api/scenetext/

  3. If it works fine, you'll get an output like: Screenshot from 2022-04-17 11-41-05

  4. Else, you'll get an error like this: Screenshot from 2022-04-17 11-45-55

Expected behavior The API should work well for all kind of images.

Desktop :

Images with which it works Images with which it doesn't works
1, 2, 3, 4 5, 6, 7, 9
8, 10, 13 11, 12, 15
14, 18, 20 16, 17, 19
20, 21, 24, 25 22, 23, 26

(These are the image ids given in the dataset)

Detailed Error from the Server:

Django version 2.2.1, using settings 'Rekognition.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
2022-04-17 06:15:16,021 | INFO | POST Request for Scene Text Extraction made
2022-04-17 06:15:16,021 | INFO | getnewuniquefilename called
2022-04-17 06:15:16,021 | INFO | getnewuniquefilename called
2022-04-17 06:15:16,027 | INFO | id_generator called
2022-04-17 06:15:16,027 | INFO | id_generator called
2022-04-17 06:15:16,027 | INFO | text_detect called
2022-04-17 06:15:16,028 | INFO | handle_uploaded_file called
2022-04-17 06:15:16,028 | INFO | handle_uploaded_file called
WARNING:tensorflow:From /home/archi/Desktop/Rekognition/myenv/lib/python3.6/site-packages/tensorflow/python/keras/layers/normalization.py:534: _colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
Internal Server Error: /api/scenetext/
Traceback (most recent call last):
  File "/home/archi/Desktop/Rekognition/myenv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/archi/Desktop/Rekognition/myenv/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/archi/Desktop/Rekognition/myenv/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/archi/Desktop/Rekognition/myenv/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/home/archi/Desktop/Rekognition/myenv/lib/python3.6/site-packages/django/views/generic/base.py", line 71, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/archi/Desktop/Rekognition/myenv/lib/python3.6/site-packages/rest_framework/views.py", line 495, in dispatch
    response = self.handle_exception(exc)
  File "/home/archi/Desktop/Rekognition/myenv/lib/python3.6/site-packages/rest_framework/views.py", line 455, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/home/archi/Desktop/Rekognition/myenv/lib/python3.6/site-packages/rest_framework/views.py", line 492, in dispatch
    response = handler(request, *args, **kwargs)
  File "/home/archi/Desktop/Rekognition/coreapi/views.py", line 47, in post
    result = text_detect(input_file, filename)
  File "/home/archi/Desktop/Rekognition/corelib/main_api.py", line 207, in text_detect
    boxes = boxes[:, :8].reshape((-1, 4, 2))
ValueError: cannot reshape array of size 20 into shape (4,2)

Array size varies for each image, e.g., it's size is 4, 12, 20, 28, 36, etc.

augsaksham commented 2 years ago

205 Solves this