GithubHelp home page GithubHelp logo

bpops / timeslide Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 18.53 MB

a super-simple gui to slide old photographs into TODAY

License: GNU General Public License v3.0

Shell 14.00% Python 86.00%
deoldify machine-learning easy-to-use photographs pyqt6

timeslide's Introduction

TimeSlide

a super-simple gui to slide old photographs into TODAY

TimeSlide is a prototype concept to balance the ease of applying machine-learning colorizing and up-sampling of old photographs without having to possess coding expertise or uploading your photographs to an online service. It is inspired by my desire to provide an easy-to-use offline option for my mother with her older family and ancestral photos. The goal is to give the people a secure and easy way to make your old photos look like they were taken today. The application name is derived from the title of an episode of the amazing British sitcom, "Red Dwarf," wherein timeslides provided much more interactive features of old photographs.

TimeSlide Screenshot

TimeSlide is really just an attempt at pretty packaging of the hard work by others--e.g., the deoldify project, torch developers and all the other selfless contributors to both the open source and free software communities that provide enabling technologies.

Importantly, TimeSlide targets macOS. Currently, since it is based solely on python modules, you could certainly bundle a Windows application. But no support on that procedure is provided herein (though you're welcome to figure it out yourself and submit a PR). I haven't gone through all licenses yet and so do not provide a "release" here. But the instructions for bundling/packaging a distribution yourself is provided herein.

Requirements

  • macOS (tested with Monterey 12.0.1)
  • brew
  • python 3.9

Setup for Development

In macOS, install homebrew. Then, use it to install Python 3.9.

brew install [email protected]

Link it in your path with

echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc

Ensure that the python3 command is correctly inked to the homebrew version with

which python3

Also verify here that it is python 3.9, or else just run python3 --version to confirm.

Next, run the bootstrap file which will clone deoldify, download the colorizing models, install a few packages through homebrew, and install all python requirements in a virtual environment. Edit it if you desire or require, then run

source bootstrap.sh

Execute TimeSlide for Development

After activating the python virtual environment (source venv/bin/activate), simply run the python script:

python timeslide.py

Bundle for macOS

Since the whole point of TimeSlide is ease of use, we require a solution for bundling the app that can be distributed to others. To do this, first open the file timeslide.spec and ensure that the path to your homebrew (Cellar'ed) version of libpng16.16.dylib is correct (slight modifications may be necessary depending on version number.)

Next, in terminal, run:

source bundle.sh

With this, pyinstaller will bundle the app, including all necessary python modules, dynamic libraries, and machine learning models (pretrained weights). It will be bundled into a single .app bundle (as well as a binary executable) under the dist folder. Additionally, the bash script will copy over the icon files into the .app file. I recommend running the binary executable first to troubleshoot, as you'll be able to see any errors that occur.

Running the Bundled macOS App

Please note that distributing the application to others will require that they enable unidentified developer apps (one-time procedure) to run on any somewhat recent versions of macOS. This can be done by providing those users with the following instructions.

  1. Press โŒ˜ + SPACEBAR.
  2. Type term. When the Terminal.app shows, click it (or hit ENTER).
  3. In the window, type sudo spctl --master-disable (note double hyphens before master), hit ENTER.
  4. Enter password as required, hit ENTER.
  5. Open System Preferences.
  6. Click "Security and Privacy." Make sure you're on the "General" tab.
  7. Click the lock at the bottom left, and enter password.
  8. Under "Allow apps downloaded from," ensure that "Anywhere" is selected.
  9. Close System Preferences and double-click the TimeSlide app to run.

Release Notes

v0.5.1 (2022.04.22)

  • added menu bar
  • added license window
  • added about window

v0.5 (2022.03.31)

  • complete rewrite of gui in pyqt6
  • enable URL loading
  • removed enhancement as implementation was far too slow
  • change license from MIT to GPLv3

v0.4.2 (2022.02.14)

  • updated deoldify models to current urls
  • accepted dependabot PRs for various vulnerabilities

v0.4.1 (2021.07.29)

  • updated several module versions for security and compatibility

v0.4 (2020.08.28)

  • default window width enlarged for better viewing
  • image now maintains aspect ratio correctly in canvas
  • resizing window now resizes canvas and image
  • dropdown menus now have correct background color
  • removed many unncessary python modules from bundle
  • window now will start in center of the screen
  • app will no longer fail when user cancels load file

v0.3 (2020.08.17)

  • new enhancement frame (including tooltips)
  • enhancement allows for 4 models, 3 multiplicative factors each

v0.2 (2020.07.05)

  • .jpg now default when saving
  • status updates now provided during procedure
  • tooltips now help guide user
  • blurry text in macOS resolved
  • dedicated icon
  • stable model + artistic model both included
  • app can now be fully bundled for macOS

v0.1 (2020.06.08)

  • first working version
  • colorize-capable (and optional)
  • render factor selection on colorize
  • load from local file or url
  • gui layout to guide user

Useful Links

If you just want to test out TimeSlide but don't have black-and-white photos available, here are some nice resources:

timeslide's People

Contributors

bpops avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

zententacles

timeslide's Issues

optional colorize

Colorize is not the only intended method for this project. Allow for optional enabling/disabling colorizing.

include stable model

currently only have artistic model; should also include stable that might help with zombie limbs

Batch mode

batch mode to do all files with specified parameters from a folder, or multi-file selection.

URL loading

URLs always correctly load as the old photo in the canvas, but often the url is rejected when colorized. Do not know reason, but issue is probably somewhere in deoldify's visualize.py?

widen window

current window is too small; even before we get window scaling implemented, the window should at least be wider to allow for easier analysis of the result.

Rewrite GUI from scratch in PyQt6

I'm aware that Tkinter shows just a black window on macOS Monterey (possibly Bug Sur). I'm tired of this issue and will be converting over to PyQT instead.

Reorganize GUI layout

propose:
step 1: load old photo

  • URL or local file
    step 2: parameters
  • colorize?
  • render factor
  • super resolution?
  • resolution factor
    step 3: Time slide!
    step 4; save as

Symlink deoldify

Current bootstrap copies the deoldify module from the cloned repo, but better to simply symlink it.

Image Comparison Slider

Instead of new image simply replacing old image.

Image comparison slider so that user can slide between old and new images. I can't find any examples of this being done in python. Could prove difficult. Might have to use tkinter lines drawn to the canvas, and in realtime crop top image.

Crash on replace existing file

If try to save to a file that exists, and select "Replace," python will crash. E.g.,

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'ROSP: sandbox extension failure: nil result or wrong class type ((null)) for finalURL (file:///Users/<username>/Desktop/Untitled, /Users/<username>/Desktop/Untitled)!'

tooltips

require tooltips for things that necessitate explanation, e.g., render factor

Ubuntu 22.04: _pickle.UnpicklingError: invalid load key, '<'.

Hello all,

I am unfortunately not a programmer and was happy to find this program to colorize my old photos.

The installation worked without a problem under Ubuntu 22.04 and the program also starts.

But during the execution it crashes. The following is the message from the console:

 timeslide$ python timeslide.py
NumExpr defaulting to 8 threads.
/home/joern/Github/timeslide/venv/lib/python3.9/site-packages/fastai/data_block.py:442: UserWarning: Your training set is empty. If this is by design, pass `ignore_empty=True` to remove this warning.
  warn("Your training set is empty. If this is by design, pass `ignore_empty=True` to remove this warning.")
/home/joern/Github/timeslide/venv/lib/python3.9/site-packages/fastai/data_block.py:444: UserWarning: Your validation set is empty. If this is by design, use `split_none()`
                 or pass `ignore_empty=True` when labelling to remove this warning.
  warn("""Your validation set is empty. If this is by design, use `split_none()`
Traceback (most recent call last):
  File "/home/joern/Github/timeslide/timeslide.py", line 317, in slideTime
    colorizer = get_image_colorizer(artistic=artistic)
  File "/home/joern/Github/timeslide/deoldify/visualize.py", line 444, in get_image_colorizer
    return get_stable_image_colorizer(root_folder=root_folder, render_factor=render_factor)
  File "/home/joern/Github/timeslide/deoldify/visualize.py", line 453, in get_stable_image_colorizer
    learn = gen_inference_wide(root_folder=root_folder, weights_name=weights_name)
  File "/home/joern/Github/timeslide/deoldify/generators.py", line 19, in gen_inference_wide
    learn.load(weights_name)
  File "/home/joern/Github/timeslide/venv/lib/python3.9/site-packages/fastai/basic_train.py", line 265, in load
    state = torch.load(source, map_location=device)
  File "/home/joern/Github/timeslide/venv/lib/python3.9/site-packages/torch/serialization.py", line 713, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/home/joern/Github/timeslide/venv/lib/python3.9/site-packages/torch/serialization.py", line 920, in _legacy_load
    magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: invalid load key, '<'.

Any tips on what I can try?

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.