logo
down
shadow

How to add photo encodings to db with django using face_recognition api?


How to add photo encodings to db with django using face_recognition api?

Content Index :

How to add photo encodings to db with django using face_recognition api?
Tag : django , By : user165781
Date : November 29 2020, 04:01 AM

like below fixes the issue You have to convert the file to an image file by using PIL library. face_recognition.face_encodings expect a numpy array as input
 import PIL.Image

class Staff(models.Model):

    photo = models.FileField()
    encodings = models.TextField()

    def get_encodings(self):
        enc = face_recognition.face_encodings(self.read_image_from_file(self.photo))
        return enc

    def save(self, *args, **kwargs):
        self.encodings = self.get_encodings()
        super(Staff, self).save(*args, **kwargs)

   def read_image_from_file(file):
       return np.array(PIL.Image.open(file))

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Django: How to update Photo model that uses Imagekit without re-uploading photo on save()


Tag : django , By : lewing
Date : March 29 2020, 07:55 AM
wish helps you Your file storage shouldn't be called unless the file associated with your FileField has changed. In your case, I don't see a reason why s3 should ever even get hit by doing a simple photo.title = 'New title'; photo.save()
It could be lots of other issues, granted, I haven't tried Imagekit yet (very nice app!), but I'm guessing something, somewhere is inadvertently altering your ImageField file data. I suggest you write a simple test that edits an existing Photo model instance and debug the issue thoroughly.

iOS 7 Pick Photo From Photo Album, Edit Photo, Replace Original Photo


Tag : ios , By : dexteryy
Date : March 29 2020, 07:55 AM
this one helps. ...its a bad idea to override the original image, the rule of thumb is to always work with the copy of the original image. !
you can refer to THIS ANSWER! which explains how to select image/s, store them and do anything with them after selection.

Tag : django , By : joshski
Date : March 29 2020, 07:55 AM
this one helps. Using Django 1.8. I am building app that has photo galleries with photos that belong to those galleries (my galleries are called 'fountains')
def home(request):
context = {}
context['photos'] = Photo.objects.first()
return render (request, 'html', context)
  photo = Photo.objects.first()
  return render(request, 'html', {'photo':photo})
<p>{{ photo.fanat.name }}</p>
<img src="{{ photo.image.url }}">

Django not running: ModuleNotFoundError: No module named 'encodings'


Tag : django , By : Waheedoo
Date : March 29 2020, 07:55 AM
will be helpful for those in need I have installed django website in a new Ubuntu 17.10 server. It is based on python3. It works fine when i run the website in development mode using , Instead of:
python-home=/home/usr/mygpsproject/venv/bin/
python-home=/home/usr/mygpsproject/venv

ModuleNotFoundError: No module named 'encodings' in Django on NGINX / uWSGI


Tag : python , By : user155548
Date : March 29 2020, 07:55 AM
Hope this helps I noticed in the uWSGI error log that Python 3.5 was being invoked before it set the virtual environment. I resolved the problem with the following lines in the uWSGI config file.
plugins-dir = /usr/lib/uwsgi/plugins/
plugin = python36
Related Posts Related QUESTIONS :
  • how to convert Django 2.0 url() to path()
  • Signal/Method for every executed sql statement
  • How to sum django model fields
  • django template styntex {% if p.category == "help" %} {% endif %} is not work
  • NGINX 502 bad gateway gunicorn timeout
  • How to pass a variable from a template to a view in Django
  • How to force redirect_uri to use HTTPS with python-social-app?
  • How to restrict Django models from using certain foreign key values?
  • Product items is not iterable from models
  • Removing items from celery_beat doesn't remove them from database schedule
  • Column field is not recognized/not defined
  • AttributeError at has no attribute 'objects'
  • how to Validate Expire date is bigger than start date in Django Model Form
  • Django Application
  • How to get my Django app in a real server?
  • How do I run a unit test against the production database?
  • How to browse (no text editor) .rst files?
  • Filter Queryset in Django inlineformset_factory
  • IPN delivery failed. HTTP error code 403: Forbidden
  • integrating django-paypal
  • Django equivalent for latest entry for each user
  • Writing custom Django form fields and widgets
  • Django queryset to find a char value with filtered out spaces?
  • Django i18n: how to not translate the admin site?
  • apache virtual host to work with django
  • Using django-piston, how can I write out HTTP headers in the response?
  • Error in django url.py?
  • Django: getting the list of related records for a list of objects
  • Edit/show Primary Key in Django Admin
  • How do I list all available context variables?
  • Treebeard admin in Django
  • Django and Secure iCalendar Feed
  • Syncing data between devel/live databases in Django
  • What custom themes are there for Django Admin?
  • ChoiceField or CharField in django form
  • Django and ImageField Question
  • Django crash without message
  • Django: do I need to do HttpResponseRedirect to render a simple string after a POST?
  • modelform "object not callable" error
  • Django model forms
  • Django subprocess
  • Writing validators with Django: How to display Validation Error Message?
  • Image upload to the rich text field from vue to amazon s3 via django REST framework
  • Django: overriding predefined save() method - request is not defined
  • Uploading a CSV or Excel file along with json data through React html form to Django
  • unable to specify custom Django Model from nested app as AUTH_USER_MODEL
  • How to restrict access to DetailView depending on user permission AND MODEL ATTRIBUTE VALUE?
  • path function for URL throwing error when we want to capture an integer or slug paramter
  • Celery task not starting at the start time provided
  • How to add username to the filefield?
  • How to make a correct password encryption in django users?
  • How to show an alert on the success url
  • Python Django - Associating a ForeignKey on users. IntegrityError NOT NULL constraint failed
  • Django Heroku deployment URLconf error. Page not found (404)
  • How to create a dropdown menu in django with selections from created model objects?
  • django-rest returning http 301 status code when calling http delete without trailing slash
  • DRF nested serializer not able to updated nested data
  • Django - needs to have a value for field "id" before this many-to-many relationship can be used
  • Allowing only superuser to call template column - Django
  • django-rest ModelSerializer select fields to display in nested relationship
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com