Code Monkey home page Code Monkey logo

tag-machine's Introduction

GitHub license PRs Welcome GitHub contributors GitHub issues

Tag Machine

A little Python application to auto tag your photos with the power of machine learning.
Report a bug or request a feature

Table of Contents

Getting Started

Prerequisites and dependencies

This repository is tested on Python 3.7+ and PyTorch LTS 1.8.2.

You should install Tag Machine in a virtual environment. If you're unfamiliar with Python virtual environments, check out the user guide. First, create a virtual environment with the version of Python you're going to use and activate it.

Then, you will need to install PyTorch. Please refer to PyTorch installation page regarding the specific install command for your platform.

When PyTorch is installed, ๐Ÿค— Transformers can be installed using pip as follows:

pip install transformers

You can refer to the repository of ๐Ÿค— Transformers for more information.

Then you will need to install PySide6, a port of QT for Python used for the graphic interface. It can be installed using pip as follows:

pip install pyside6

Finally you will need to install IPTCInfo3 to allow Tag Machine to write tags in your images. It can be installed using pip as follows:

pip install iptcinfo3

Installation

Follow the instructions above then clone the repo (git clone https:://github.com/torresflo/Tag-Machine.git). You can now run main.py.

Usage

Press the button Load files... to load your images then press the button Classify images to start the classifier. Depending on your machine hardware and the number of images this can take some (and eventually a lot of) time.

The results are loaded in a table below so you can see which tags are detected for each image.

If you are satisfied with the results, you can then press the button Write tags in images to write the found tags in the metadata of the image (IPTC, IIM Application 2, Keywords). Each tag is appended to the existing ones and will not be written if it already exists.

Example image

Examples

Here are some examples with results. You can find these images in the folder Photos. All images come from the Wikimedia Commons website.

Note that the detection uses the labels computed by the PhotoPrism project. It allows to regroup similar tags in more generic categories and discard non useful ones. Also, a threshold is also calculated to avoid wrong tagging.

Image Tags found Probability
tower, architecture 97,98%
Nothing --,--%
dining 87,52%
alpine, landscape, mountain 66,37%
Nothing --,--%
shark, water, fish, animal 76,77%
Nothing --,--%
castle, historic, architecture 99,64%
castle, historic, architecture 98,44%

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature)
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the GNU General Public License v3.0. See LICENSE for more information.

tag-machine's People

Contributors

torresflo 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

Watchers

 avatar  avatar  avatar

tag-machine's Issues

Additional training / feedback

I've been looking for exactly this! I have a large collection of photos with existing tags. I wonder, is it possible to further train the default model with the existing tags in my images? And improve the model as from new tags that I manually add in future? Is the model updated with feedback when its suggestions are overridden by the user?

Error saving tags

Issue writing tags to images:

Traceback (most recent call last):
  File "C:\Stable_Diffusion\metadata_tagger\UI\MainWindow.py", line 62, in onWriteTagsButtonClicked
    self.m_imageWriter.writeTagsFromPredictionsInImages(lastPredictions)
  File "C:\Stable_Diffusion\metadata_tagger\Model\ImageWriter.py", line 18, in writeTagsFromPredictionsInImages
    iptcInfo.save()
  File "C:\Stable_Diffusion\metadata_tagger\venv\lib\site-packages\iptcinfo3.py", line 627, in save
    return self.save_as(self._filename, options)
  File "C:\Stable_Diffusion\metadata_tagger\venv\lib\site-packages\iptcinfo3.py", line 633, in save_as
    logger.error('Source file %s is not a Jpeg.' % self._fob)
AttributeError: 'IPTCInfo' object has no attribute '_fob'. Did you mean: '_fobj'?

worked previously, tried a git pull, and a new git clone / install as well. Won't save tags any more.

No module named 'PIL'

All requirements and modules have been installed in a separate environment, but when I finally run this it spits out the following issue: (folder chain replaced with stars, but contains no spaces in titles)

Traceback (most recent call last):
  File "C:\****\metadata_tagger\main.py", line 4, in <module>
    from UI.MainWindow import MainWindow
  File "C:\****\metadata_tagger\UI\MainWindow.py", line 2, in <module>
    from UI.PredictionItemModel import PredictionItemModel
  File "C:\****\metadata_tagger\UI\PredictionItemModel.py", line 2, in <module>
    from PIL.ImageQt import ImageQt
ModuleNotFoundError: No module named 'PIL'

Enhancement: Application slows down with previews

The application becomes very slow when loading folders with many files or large files. In my case it becomes complicated because I want to use the application to handle large amounts of images. Likewise it is not possible to resize the window in such a state.

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.