GithubHelp home page GithubHelp logo

thumbor / remotecv Goto Github PK

View Code? Open in Web Editor NEW
95.0 95.0 34.0 16.59 MB

remotecv is an OpenCV server for facial and feature recognition.

Home Page: https://github.com/thumbor/remotecv/wiki

License: MIT License

Python 97.60% Makefile 1.01% Dockerfile 1.39%

remotecv's Introduction

Join thumbor-bootcamp for a learning and contribution experience with โค๏ธ and ๐Ÿค— from the thumbor team

thumbor

Crop, resize, transform and much more, all on-demand and AI Powered


thumbor is trusted by hundreds of companies worldwide

Wikipedia trusts thumborย  Globo.com trusts thumborย  Vox Media trusts thumborย  Forbes trusts thumborย  Square trusts thumborย  Deliveroo trusts thumborย  Canal+ trusts thumborย  Terra trusts thumborย  nrc trusts thumborย  web.dev indicates thumbor for high-performance web sitesย  aws indicates thumbor for serverless image handling
and many more!

thumbor is a smart imaging service that enables on-demand cropping, resizing, applying filters and optimizing images.

Cropping photos automatically can be a frustrating experience with severed heads involved. thumbor uses AI for smart detection.

thumbor is an HTTP server and you can create as many different images as you want just by varying path parameters:

http://<thumbor-server>/300x200/smart/thumbor.readthedocs.io/en/latest/_images/logo-thumbor.png

You should see an image of the thumbor logo in 300x200.

Learn more about all you can do in thumbor's documentation.

โš™๏ธ Installation

Decide which installation option you want to use.

Option 1: pip

# thumbor with main dependencies only
pip install thumbor

# thumbor with OpenCV dependency
pip install thumbor[opencv]

# thumbor with all dependencies
pip install thumbor[all]

Option 2: Binary

sudo add-apt-repository ppa:thumbor/ppa
sudo aptitude update
sudo aptitude install thumbor

For more ways, please check out Installation.

Run

Running it is as easy as hit:

thumbor

After this, you can reach it on https://localhost:8888/unsafe/https://raw.githubusercontent.com/thumbor/thumbor/master/example.jpg

Troubles?

If you experience any troubles, try running:

thumbor-doctor

If you have a thumbor.conf file, you can use that to help thumbor-doctor:

thumbor-doctor -c thumbor.conf

If you still need help, please raise an issue. Remember to send your thumbor-doctor output in the issue:

thumbor-doctor --nocolor -c thumbor.conf

๐ŸŽฏ Features

  • supports all common images formats out of the box
  • intelligent cropping and resizing
  • blazing fast using caching
  • supports many storages (local storage, AWS S3, Rackspace, Ceph, ...)
  • AI-powered cropping based on face and feature detection (glasses, interesting points, ...)
  • integrated with many programming languages and frameworks and many more...
  • highly extensible

๐ŸŒŸ Awesome Goodies

awesome-thumbor is a curated list of all things thumbor. There you can find filters, storages, engines, loaders, docker images, extensions in your favorite language and framework, and much more.

All of it with a clear indication of each project's quality. Have fun!

๐Ÿ‘ Contribute

thumbor is an open-source project with many contributors. Join them contributing code or contributing documentation.

If you use thumbor, please take 1 minute and answer this survey? Only 2 questions!

Join the chat at https://gitter.im/thumbor/thumbor

๐Ÿ‘€ Demo

You can see thumbor in action at http://thumborize.me/

remotecv's People

Contributors

caeugusmao avatar cezarsa avatar cristiandean avatar dependabot[bot] avatar devppjr avatar eduherraiz avatar fbtravi avatar guilhermef avatar heynemann avatar jayvdb avatar maiagripp avatar marcelometal avatar meisterzeit avatar okor avatar psyduck787 avatar raphaelvrossi avatar rodolfo3 avatar scorphus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

remotecv's Issues

Changing detection mode of RemoteCV to grayscale + Equalized

Expected behaviour

RemoteCV should find faces with more assertiveness.
After some analysis, we found out that we can achieve this applying grayscale and equalized image histogram on the images.

Actual behaviour

RemoteCV don't apply any type of filter or image processing before the face detection.
By doing that, RemoteCV results in some false positive (in which it found points, but this points aren't faces) or errors.
We've been wondering if we do a new detector or apply these new detectors on face detection?
To do this analysis we used this dataset from Kaggle.

Assertiveness by detection type
Exists face on image by detection type
Average image processing time

Getting 403 errors with RemoteCV

Turns out that there's quite a lot of servers blocking requests for content by bots (as identified by the user agent). It appears remoteCV is utilising Python-urllib for retrieving images - specifically in my case 'Python-urllib/2.7'.

E.g. Cloudflare has this in it's default list whenever the panel is set to reject requests from bots. Causing me quite a few pains at the moment.

Solution: can we bake in some config option to remoteCV/thumbor to alter the user agent? I see it exists for the thumbor's http loader but not the detector's loader.

I can have a crack but I've written almost nothing in Python before so will take me a little longer!

Thanks

remotecv-web broken

gilles@thumbor:~/thumbor-debian/remotecv/remotecv-2.2.1/debian$ remotecv-web Traceback (most recent call last): File "/usr/bin/remotecv-web", line 9, in <module> load_entry_point('remotecv==2.2.1', 'console_scripts', 'remotecv-web')() File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 356, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2476, in load_entry_point return ep.load() File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2190, in load ['__name__']) File "/usr/lib/python2.7/dist-packages/remotecv/web.py", line 18, in <module> from resweb import server as resweb_server ImportError: cannot import name server

it would appear there is no "server" in the current version of resweb: https://github.com/Pyres/resweb/tree/master/resweb

Maybe remotecv-web dates back to when resweb was still part of pyres and wasn't flask-based? This would suggest so: https://github.com/binarydud/pyres/blob/1.0/resweb/server.py

The fix doesn't seem to be too complicated, the host override just has to be pointed to the new location. But I don't know if that will make remotecv-web truly work. And for that matter, is remotecv-web still relevant and used?

No address associated with hostname

Hi there, sorry if this is not the right place to ask this question. I spent a few hours configuring Thumbor and got it to work. I am not trying to add remotcv and I am running into a issue.

Here are the logs (I removed some lines for clarity):

thumbor_1   | 2017-07-03 02:07:28 tornado.access:INFO 304 GET /unsafe/250x250/smart/photos/users/525f471da20c31e67432a3df45129b38.jpg (172.19.0.4) 90.80ms
[...]
remotecv_1  | INFO:remotecv:Detecting all for photos/users/525f471da20c31e67432a3df45129b38.jpg
remotecv_1  | ERROR:pyres.worker:(Job{Detect} | remotecv.pyres_tasks.DetectTask | [u'all', u'photos/users/525f471da20c31e67432a3df45129b38.jpg', u'photos/users/525f471da20c31e67432a3df45129b38.jpg']) failed: <urlopen error [Errno -5] No address associated with hostname>
remotecv_1  | Traceback (most recent call last):
remotecv_1  |   File "/usr/local/lib/python2.7/site-packages/pyres/worker.py", line 253, in process
remotecv_1  |     return job.perform()
remotecv_1  |   File "/usr/local/lib/python2.7/site-packages/pyres/job.py", line 55, in perform
remotecv_1  |     return payload_class.perform(*args)
remotecv_1  |   File "/usr/local/lib/python2.7/site-packages/remotecv/pyres_tasks.py", line 12, in perform
remotecv_1  |     image_data = config.loader.load_sync(image_path)
remotecv_1  |   File "/usr/local/lib/python2.7/site-packages/remotecv/http_loader.py", line 8, in load_sync
remotecv_1  |     return urllib2.urlopen(path).read()
remotecv_1  |   File "/usr/local/lib/python2.7/urllib2.py", line 154, in urlopen
remotecv_1  |     return opener.open(url, data, timeout)
remotecv_1  |   File "/usr/local/lib/python2.7/urllib2.py", line 429, in open
remotecv_1  |     response = self._open(req, data)
remotecv_1  |   File "/usr/local/lib/python2.7/urllib2.py", line 447, in _open
remotecv_1  |     '_open', req)
remotecv_1  |   File "/usr/local/lib/python2.7/urllib2.py", line 407, in _call_chain
remotecv_1  |     result = func(*args)
remotecv_1  |   File "/usr/local/lib/python2.7/urllib2.py", line 1228, in http_open
remotecv_1  |     return self.do_open(httplib.HTTPConnection, req)
remotecv_1  |   File "/usr/local/lib/python2.7/urllib2.py", line 1198, in do_open
remotecv_1  |     raise URLError(err)
remotecv_1  | URLError: <urlopen error [Errno -5] No address associated with hostname>

I deployed everything using docker-thumbor. My images are hosted in AWS S3. I assume that the issue is coming from remotecv not being able to get the file.

Here si my config:

REMOTECV_REDIS_HOST=redis
REMOTECV_REDIS_PORT=6379
REMOTECV_REDIS_DATABASE=0
LOADER=remotecv_aws.loader
AWS_ACCESS_KEY_ID=xxxx
AWS_SECRET_ACCESS_KEY=xxxx
AWS_REGION=us-east-1
AWS_LOADER_BUCKET=xxx

Any suggestion? I am not sure that AWS_REGION is the valid option. I can't find proper documentation. I'd appreciate any input!

Create metrics for Remotecv

Expected behaviour

Be able to measure the use of Remotecv.

Use as Thumbor does here, create logger metrics as default, and has a point of extension for new metric client.

Possible metrics:

  • For each detector
    • latency (ms)
    • detected (boolean - true if found points)
  • For original image, such as Thumbor does
    • response_bytes
    • status_code + host + latency
    • status_code + host + count
    • status_code + count
  • For each task (image to detect)
    • time (total time of detection)
    • count

Remotecv can't fetch url with `%20` in it

When remotecv fetchs a new image from URL, it decode from urlEncoded to normal text, transforming %20 into whitespace

URL: http://domain.org/my%20image.jpeg

ERROR:pyres.worker:(Job{Detect} | remotecv.pyres_tasks.DetectTask | ['face+profile+glass', 'http%3A//domain.org/my%20image.jpeg', 'http%3A//domain.org/my%20image.jpeg']) failed: URL can't contain control characters. 'my  image.jpeg' (found at least ' ')
Traceback (most recent call last):
  File "/home/application/python/lib/python3.9/site-packages/pyres/worker.py", line 256, in process
    return job.perform()
  File "/home/application/python/lib/python3.9/site-packages/pyres/job.py", line 83, in perform
    return payload_class.perform(*args)
  File "/home/application/python/lib/python3.9/site-packages/remotecv/pyres_tasks.py", line 17, in perform
    image_data = config.loader.load_sync(image_path)
  File "/home/application/python/lib/python3.9/site-packages/thumbor/loaders/http_loader.py", line 62, in load_sync
    return urllib.request.urlopen(sanitized_path).read()
  File "/home/application/python/lib/python3.9/urllib/request.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "/home/application/python/lib/python3.9/urllib/request.py", line 517, in open
    response = self._open(req, data)
  File "/home/application/python/lib/python3.9/urllib/request.py", line 534, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/home/application/python/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/home/application/python/lib/python3.9/urllib/request.py", line 1371, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/home/application/python/lib/python3.9/urllib/request.py", line 1342, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/home/application/python/lib/python3.9/http/client.py", line 1255, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/home/application/python/lib/python3.9/http/client.py", line 1266, in _send_request
    self.putrequest(method, url, **skips)
  File "/home/application/python/lib/python3.9/site-packages/sentry_sdk/integrations/stdlib.py", line 86, in putrequest
    rv = real_putrequest(self, method, url, *args, **kwargs)
  File "/home/application/python/lib/python3.9/http/client.py", line 1100, in putrequest
    self._validate_path(url)
  File "/home/application/python/lib/python3.9/http/client.py", line 1200, in _validate_path
    raise InvalidURL(f"URL can't contain control characters. {url!r} "
http.client.InvalidURL: URL can't contain control characters. 'my  image.jpeg' (found at least ' ')

Remotecv should load truncated images

Expected behaviour

Remotecv should load truncated images in http loader.

Actual behaviour

When we download an image that has truncated bytes, remotecv fails to load the image and generates an error, as below:

Traceback (most recent call last):
  File "/venv/lib/python3.9/site-packages/pyres/worker.py", line 256, in process
    return job.perform()
  File "/venv/lib/python3.9/site-packages/pyres/job.py", line 83, in perform
    return payload_class.perform(*args)
  File "/venv/lib/python3.9/site-packages/remotecv/pyres_tasks.py", line 18, in perform
    image_data = config.loader.load_sync(image_path)
  File "/venv/lib/python3.9/site-packages/remotecv/image_processor.py", line 30, in detect
    result = result + self.detectors[detector_key].detect(image)
  File "/venv/lib/python3.9/site-packages/remotecv/detectors/face_detector/__init__.py", line 25, in detect
    features = self.get_features(image)
  File "/venv/lib/python3.9/site-packages/remotecv/detectors/__init__.py", line 50, in get_features
    img = self.get_np_img(image)
  File "/venv/lib/python3.9/site-packages/remotecv/detectors/__init__.py", line 27, in get_np_img
    image.save(img_buffer, self.__get_format(image))
  File "/venv/lib/python3.9/site-packages/PIL/Image.py", line 2317, in save
    self._ensure_mutable()
  File "/venv/lib/python3.9/site-packages/PIL/Image.py", line 599, in _ensure_mutable
    self._copy()
  File "/venv/lib/python3.9/site-packages/PIL/Image.py", line 592, in _copy
    self.load()
  File "/venv/lib/python3.9/site-packages/PIL/ImageFile.py", line 254, in load
    raise OSError(
OSError: image file is truncated (0 bytes not processed)

Solution

We could define a PIL configuration that would allow remote loading of truncated images. I think we can set this PIL configuration with a remotecv configuration, what do you think guys?

from PIL import ImageFile

ImageFile.LOAD_TRUNCATED_IMAGES=context.config.get("LOAD_TRUNCATED_IMAGES")

remotecv is not detecting faces

Hi,

I have installed remotecv and - somewhat - it is showing something but it's not detecting anything (faces for example). The output of remotecv:

Screenshot 2019-07-27 at 02 45 53

Using the local storage or aws have the same result. Configuring thumbor without remotecv to identify faces in real-time works just fine (either using opencv or pillow engines).

Only when the detectors are changed to use remotecv it stops detecting faces (already tried all the combinations possible, including using only the face_detector):

DETECTORS = [
#'thumbor.detectors.face_detector',
#'thumbor.detectors.feature_detector'
'thumbor.detectors.queued_detector.queued_complete_detector',
'thumbor.detectors.queued_detector.queued_face_detector',
'thumbor.detectors.queued_detector.queued_feature_detector'
]

Thumbor is showing the following:

Screenshot 2019-07-27 at 04 21 50

metadata is not being generated when the images are queued for processing when remotecv is configured - at least it is not showing on the configured STORAGE (either aws or file system).

pyres_worker -l debug Detect is showing the following error:

Screenshot 2019-07-27 at 04 30 36

"AttributeError: Config instance has no attribute 'loader'"

Already tried on Ubuntu 16.04 and CentOS 7. The result is the same on both.

pip list

Package Version


backports-abc 0.5
backports.ssl-match-hostname 3.5.0.1
botocore 1.12.197
colour 0.1.5
configobj 4.7.2
decorator 3.4.0
derpconf 0.8.3
docutils 0.14
futures 3.3.0
iniparse 0.4
ipaddress 1.0.16
itty 0.8.2
jmespath 0.9.4
libthumbor 1.3.2
meld3 0.6.10
numpy 1.16.4
olefile 0.46
opencv-python 4.1.0.25
perf 0.1
pexif 0.15
piexif 1.1.3
Pillow 5.1.0
pip 19.2.1
pycryptodome 3.8.2
pycurl 7.19.0
pygobject 3.22.0
pygpgme 0.3
pyliblzma 0.5.3
pyres 1.5
pystache 0.5.4
python-dateutil 2.8.0
python-linux-procfs 0.4.9
python-magic 0.4.15
pytz 2019.1
pyudev 0.15
pyxattr 0.5.1
redis 2.10.6
remotecv 2.2.2
schedutils 0.4
setproctitle 1.1.10
setuptools 0.9.8
simplejson 3.16.0
singledispatch 3.4.0.3
six 1.12.0
slip 0.4.0
slip.dbus 0.4.0
statsd 3.3.0
supervisor 3.1.4
tc-aws 6.2.12
thumbor 6.7.0
thumbor-engine-opencv 1.0.0
tornado 5.1.1
tornado-botocore 1.5.0
urlgrabber 3.10
urllib3 1.25.3
webcolors 1.9.1
yum-metadata-parser 1.1.4

Any library that could be missing? Any configuration that could be wrong?

Avoid version limitations?

Hi,

I would like to package remotecv as RPM for CentOS7 distribution, like I did with Thumbor. Unfortunately, the project uses specific version dependencies, which might be a roadblock for possible security fixes that might arise into future. I think the queued detection is very cool and beneficial for large scale Thumbor setups which use Redis as storage backend.

Is there a way to update the project and remove the dependencies which does not allows us use the latest versions of python-redis, python-pyres and python-argparse?

Regards,

Floren

https_loader for images from thumbor on a https-only site

I'm using thumbor with the thumbor.loaders.https_loader so I don't have to include the https:// part of URLs. When it sends the images to remotecv for detection, remotecv looks at the URL and prefixes it with http://. This results in a redirect error since the site hosting the images does a 308: Permanent Redirect from http:// to https://.

def load_sync(path):
if not re.match(r'^https?', path):
path = 'http://%s' % path
path = urllib2.unquote(path)
return urllib2.urlopen(path).read()

Would you consider merging a https_loader that auto prefixes the URL with https:// rather than http://?
Another option would also be to make urllib follow the redirect. WDYT?

BooleanOptionalAction is only available on Python 3.9+

In PR #44 the following code was added:

other_group.add_argument(
        "--with-healthcheck",
        default=False,
        type=bool,
        action=argparse.BooleanOptionalAction,
        help="Start an healthchecker http endpoint",
    )

BooleanOptionalAction was added to argparse in Python 3.9. However remotecv claims to be compatible with Pthon 3.7+ (python_requires="==3.*,>=3.7.0" in setup.py)

remotecv multiprocess

We have a working docker images including remotecv working here:
https://github.com/APSL/docker-thumbor

I'm doing a v2 of this images trying to improve the performance and docker architecture.
In the old architecture, we keep a unique docker container executing a unique remotecv process.
What do you think about the possibility to have multiple remotecv processes running with the same redis configuration?
I'm considering the opportunity to scale up the remotecv service by this way and I can't found any reference in the documentation.

ResponseError: value is not an integer or out of range

Hi, i'm running remotecv installed from pip, and while the detection seems to be working fine, i get this error for every image:

ERROR:pyres.worker:(Job{Detect} | remotecv.pyres_tasks.DetectTask | [u'all', u'example.com/1538060178.BoO9N1ejRkQ.41986237_493670631148044_4684286672425189376_n.jpg', u'example.com/1538060178.BoO9N1ejRkQ.41986237_493670631148044_4684286672425189376_n.jpg']) failed: value is not an integer or out of range
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/pyres/worker.py", line 256, in process
    return job.perform()
  File "/usr/local/lib/python2.7/site-packages/pyres/job.py", line 83, in perform
    return payload_class.perform(*args)
  File "/usr/local/lib/python2.7/site-packages/remotecv/pyres_tasks.py", line 15, in perform
    result_store.store(key, points)
  File "/usr/local/lib/python2.7/site-packages/remotecv/result_store/redis_store.py", line 20, in store
    self.storage.setex(redis_key, result, 2 * self.WEEK)
  File "/usr/local/lib/python2.7/site-packages/redis/client.py", line 1540, in setex
    return self.execute_command('SETEX', name, time, value)
  File "/usr/local/lib/python2.7/site-packages/redis/client.py", line 839, in execute_command
    return self.parse_response(conn, command_name, **options)
  File "/usr/local/lib/python2.7/site-packages/redis/client.py", line 853, in parse_response
    response = connection.read_response()
  File "/usr/local/lib/python2.7/site-packages/redis/connection.py", line 718, in read_response
    raise response
ResponseError: value is not an integer or out of range

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.