{"id":16059190,"url":"https://github.com/donrestarone/object-detectr","last_synced_at":"2026-05-09T10:16:07.669Z","repository":{"id":123144699,"uuid":"302776028","full_name":"donrestarone/object-detectr","owner":"donrestarone","description":"A tensorflow object detection model served to the internet on a Rails server (TensorFlow on Rails-- if you will)","archived":false,"fork":false,"pushed_at":"2022-12-18T04:24:30.000Z","size":60040,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-10T15:50:48.863Z","etag":null,"topics":["matplotlib","python","rails6","tensorflow"],"latest_commit_sha":null,"homepage":"http://potassium.shashike.me/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/donrestarone.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-09T23:45:12.000Z","updated_at":"2022-03-25T06:47:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"4136e858-c5e1-4b33-ac74-86757fbb486b","html_url":"https://github.com/donrestarone/object-detectr","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donrestarone%2Fobject-detectr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donrestarone%2Fobject-detectr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donrestarone%2Fobject-detectr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donrestarone%2Fobject-detectr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/donrestarone","download_url":"https://codeload.github.com/donrestarone/object-detectr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247305946,"owners_count":20917208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["matplotlib","python","rails6","tensorflow"],"created_at":"2024-10-09T04:00:29.705Z","updated_at":"2026-05-09T10:16:02.620Z","avatar_url":"https://github.com/donrestarone.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Object Detectr\nA tensorflow object detection model served to the internet on a Rails server.\n\n##### Table of Contents\n\n[Demo](#demo)\n\n[Installation](#install)\n\n[Troubleshooting](#troubleshooting)\n  \n\u003ca name=\"demo\"/\u003e\n\n## Demo:\nThe tensorflow model integrated into this app is quite good at detecting people\n\n![Demo of object detection (humans and cars)](https://media.giphy.com/media/OHpkVYXfKsLQunwScU/giphy.gif)\n\nIts also an excellent cat detector\n\n![Demo of object detection (cat)](https://media.giphy.com/media/2PS7JUvUGHtnXO7UJY/giphy.gif)\n\nHere are a few more detections using this application.\n\n![people detection](https://user-images.githubusercontent.com/35935196/95641582-47602e80-0a71-11eb-933e-8571122a33f4.png)\n\n![food detection](https://user-images.githubusercontent.com/35935196/95641586-49c28880-0a71-11eb-9098-01f519517f04.png)\n\n![horse and human detection](https://user-images.githubusercontent.com/35935196/95678138-b1bfbe80-0b98-11eb-90dd-5fcc49ed5794.png)\n\n![cat and couch detection](https://user-images.githubusercontent.com/35935196/95641584-48915b80-0a71-11eb-90f6-da963a0ed40b.png)\n\n\u003ca name=\"install\"/\u003e\n\n## Installation\n### FOR THE AI SIDE (setup protoc, python and install dependencies + script)\n\n1. The python environment is setup assuming that you are using pyenv and have already installed and set the python version in the project directory\n2. [If you are setting up python from scratch you can use this gist](https://gist.github.com/donrestarone/ccca19bb6ded91ca3fb6d71f46339899)\n3. ensure that python version is 3.7.9\n\n``` bash\npython --version\n```\nClone the repository\njump to the models research directory and run the build and install scripts\n``` bash\ncd object_detectr/models/research\npython setup.py build\npython setup.py install\n```\ngrab dependencies\n``` bash\npip install TensorFlow==1.15 lxml pillow matplotlib jupyter contextlib2 cython tf_slim\n# alternatively you can make sure that pip installs the libraries compatible with your specific python version (3.7.9 is recommended in our case)\npython -m pip install TensorFlow==1.15 lxml pillow matplotlib jupyter contextlib2 cython tf_slim\n# sometimes on EC2 there is not enough cache for installing these heavy libraries. pass the no cache option if installation is failing silently\npython -m pip install --no-cache-dir TensorFlow==1.15 lxml pillow matplotlib jupyter contextlib2 cython tf_slim\n```\n\n### FOR THE RAILS SIDE\n1. If you are setting up rails from scratch (like on a server) you can use this gist: https://gist.github.com/donrestarone/0ebe1e87b39f0f92f850c1da861e85de\n2. for a production nginx configuration (super hacky) you can use this gist: https://gist.github.com/donrestarone/e8b1157dc4a3adffe3450edd55a6f315\n```bash\ncd object_detectr/potash\nbundle install\nrails db:create\nrails db:migrate\nrails s\n```\n### Running in production\ncreate systemctl service for starting puma on boot. make sure ExecStart/ExecStop are pointing to the rbenv binary and the User has ownership over the var/www directory. Create the systemd file at: /etc/systemd/system/puma.service\n``` bash\n[Unit]\nDescription=Puma Rails Server\nAfter=network.target\n\n[Service]\nType=simple\nUser=ubuntu\nWorkingDirectory=/var/www/object-detectr/potash\nEnvironmentFile=/home/ubuntu/.potash_config\nExecStart=/home/ubuntu/.rbenv/bin/rbenv exec bundle exec puma -C /var/www/object-detectr/potash/config/puma.rb\nExecStop=/home/ubuntu/.rbenv/bin/rbenv exec bundle exec pumactl -S /var/www/object-detectr/potash/tmp/pids/puma.state stop\nTimeoutSec=15\nRestart=always\n\n\n[Install]\nWantedBy=multi-user.target\n```\nThe EnvironmentFile should look something like this (~/.potash_config)\n``` bash\nRAILS_ENV=production\nRAILS_SERVE_STATIC_FILES=true\n```\n\nAfter double checking the environment file works and RAILS_ENV is pointing to production \u0026 RAILS_SERVE_STATIC_FILES=true, reload systemd and start puma\n```bash\nsudo systemctl daemon-reload\nsudo systemctl enable puma.service\nsudo systemctl start puma.service\nsudo systemctl status puma.service\n```\nCreate the nginx virtualhost configuration for reverse proxying requests to the puma/rails server\n``` bash\nsudo nano /etc/nginx/sites-available/YOUR_SITE.conf\n```\nfill in the file with the details, proxying requests coming to port 80\n```bash\nserver {\n    listen 80;\n    server_name  potassium.shashike.me;\n\n    location / {\n        proxy_pass http://localhost:3000;\n        proxy_set_header Host $host;\n        proxy_set_header X-Real-IP $remote_addr;\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n        proxy_set_header X-Forwarded-Proto $scheme;\n    }\n    client_max_body_size 4G;\n}\n```\nsymlink the virtualhost, test and restart nginx\n``` bash\nsudo ln -s /etc/nginx/sites-available/potassium.shashike.me.conf /etc/nginx/sites-enabled/potassium.shashike.me.conf\nsudo service nginx configtest\nsudo service nginx reload\n```\nsetup SSL with Lets Encrypt and Certbot\n```bash\nsudo apt-get install python3-certbot-nginx\nsudo certbot --nginx -d your-domain.com\nsudo certbot renew\n```\n\n\u003ca name=\"troubleshooting\"/\u003e\n\n## troubleshooting\n\n1. Most of the time python in your shell and python invoked from ruby's system call are two different pythons. If the application simply fails without error it means that Python cannot be found when Ruby makes the system call in potash/app/controllers/images_controller.rb \nyou can try explicitly pointing to the python version in your $PATH like so:\n```ruby\n    system(\"cd #{path_to_python} ; /home/yourUserName/.pyenv/shims/python run.py #{file_name}\")\n```\n\n2. If the rails app / python script cannot write to disk, allow write by all users (dont do this on a production server)\n```bash\nchmod -R 777 object-detectr/\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdonrestarone%2Fobject-detectr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdonrestarone%2Fobject-detectr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdonrestarone%2Fobject-detectr/lists"}