hanzhi713 / image-collage-maker Goto Github PK
View Code? Open in Web Editor NEWA photo mosaic (pixel collage) maker. Use all your friends' profile pictures to approximate your profile picture! 如何用 Python 制作一个炫酷的微信好友图
License: MIT License
A photo mosaic (pixel collage) maker. Use all your friends' profile pictures to approximate your profile picture! 如何用 Python 制作一个炫酷的微信好友图
License: MIT License
Hi,
I'm trying to create a collage with a destination image that contains a transparent area (I have a .png file), but when I load it the transparent area is converted into black area (or white). Is it possible to handle a transparent area where no tiles are added?
GUI fails to generate photomosaic, citing:
ERROR
Traceback (most recent call last):
File "gui.py", line 556, in wrapper
File "gui.py", line 543, in action
File "make_img.py", line 589, in process_dest_img
File "make_img.py", line 410, in __call__
File "make_img.py", line 371, in _euclidean
numpy.core._exceptions._ArrayMemoryError: Unable to allocate 8.82 TiB for an array with shape (1557204, 1557204) and data type float 32
I can see why it wouldn't find space for a 8.82 TiB array- guessing a mem_limit variable in the GUI would prevent this?
The [Computing Assignments] phase does not seem to be engaging my GPU on the current branch, while the old stale branch of csv utilized the GPU exceptionally well. I know cupy is running appropriately...
The environment I'm using is:
Name Version Build Channel
altgraph 0.17.3 pypi_0 pypi
blas 1.0 mkl
brotlipy 0.7.0 pypi_0 pypi
bzip2 1.0.8 he774522_0
ca-certificates 2022.10.11 haa95532_0
certifi 2022.9.24 py310haa95532_0
cffi 1.15.1 pypi_0 pypi
charset-normalizer 2.0.4 pypi_0 pypi
colorama 0.4.6 pypi_0 pypi
cryptography 38.0.1 pypi_0 pypi
cudatoolkit 11.7.0 ha6f8bbd_10 conda-forge
cupy 11.2.0 py310h782d1bb_0 conda-forge
fastrlock 0.8 py310h8a704f9_2 conda-forge
future 0.18.2 pypi_0 pypi
idna 3.4 pypi_0 pypi
imagesize 1.3.0 pypi_0 pypi
intel-openmp 2021.4.0 haa95532_3556
lapjv 1.3.1 pypi_0 pypi
libffi 3.4.2 hd77b12b_4
mkl 2021.4.0 haa95532_640
mkl-service 2.4.0 py310h2bbff1b_0
mkl_fft 1.3.1 py310ha0764ea_0
mkl_random 1.2.2 py310h4ed8f06_0
numpy 1.23.4 pypi_0 pypi
numpy-base 1.23.3 py310h04254f7_0
opencv-contrib-python 4.5.5.62 pypi_0 pypi
openssl 1.1.1s h2bbff1b_0
pefile 2022.5.30 pypi_0 pypi
pip 22.2.2 py310haa95532_0
pycparser 2.21 pypi_0 pypi
pyinstaller 4.8 pypi_0 pypi
pyinstaller-hooks-contrib 2022.12 pypi_0 pypi
pyopenssl 22.0.0 pypi_0 pypi
pysocks 1.7.1 pypi_0 pypi
python 3.10.6 hbb2ffb3_1
python_abi 3.10 2_cp310 conda-forge
pywin32-ctypes 0.2.0 pypi_0 pypi
requests 2.28.1 pypi_0 pypi
setuptools 65.5.0 py310haa95532_0
six 1.16.0 pyhd3eb1b0_1
sqlite 3.39.3 h2bbff1b_0
tk 8.6.12 h2bbff1b_0
tqdm 4.64.1 pypi_0 pypi
tzdata 2022f h04d1e81_0
urllib3 1.26.12 pypi_0 pypi
vc 14.2 h21ff451_1
vs2015_runtime 14.27.29016 h5e58377_2
wheel 0.37.1 pyhd3eb1b0_0
win-inet-pton 1.1.0 pypi_0 pypi
wincertstore 0.2 py310haa95532_2
xz 5.2.6 h8cc25b3_0
zlib 1.2.13 h8cc25b3_0
could you provide an idea for that ?
Imagine there are 20 images.
You set the collage to be 2x2
Is it possible to address the folder (that includes all 20 images) and results in 5 collage photos? (each has 4 images on it)
Hi,
Is it possible to have additional features added:
Load PNG images which include transparent backgrounds as the tiles.
The tiles are not specifically preset in the constraint of a set X/Y dimension but are based on the above construct of however the foreground object is in the PNG file. For example a long point leaf (and a transparent background in the PNG), only the leaf is utilized to make the mosaic and the transparent background is not included.
Each PNG like the leaf can be rotated in a 360 degree fashion.
Thanks this is a great project.
Jag
The anticipated behavior for the CSV output is that the software would record each tile used- so if 987 tiles are loaded in to generate a 10x10 collage, 100 rows would be created (101 with the header)
Instead, the CSV implementation writes out 987 rows (988 with the header).
Successfully installed altgraph-0.17.2 lapjv-1.3.1 macholib-1.15.2 opencv-contrib-python-4.5.3.56 pyinstaller-4.6 pyinstaller-hooks-contrib-2021.5 tqdm-4.62.3
➜ image-collage-maker git:(master) python gui.py
File "gui.py", line 20
def limit_wh(w: int, h: int, max_width: int, max_height: int):
^
SyntaxError: invalid syntax
Upon clicking "Save tile info" in the GUI, a window pops up:
Error
Traceback (most recent call last):
File "C:\Resources\image-collage-maker-csv\gui.py", line 679, in save_tile_info
f.write(result_tile_info)
File "C:\ Program Files\WindowsApps\PythonSoftware Foundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib\encodings\cp1252.py".
line 19, in encode
return
codecs.charmap_encode(input, self.errors, encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters
in position 1839074-1839079: character maps to <undefined>
Could this be an illegal character in my filenames? The mosaic graphic generated and saved just fine.
Imagine there are 20 photos in total.
Is it possible to output 5 photos.jpg (2x2 collage photo) as result?
For most directories (with very few exceptions), if "infer height" is checked, the [Inferring size]: bar jumps immediately to 100% and an error message appears. This occurs in 48/53 directories, cannot isolate what traits make this happen:
Traceback (most recent call last):
File "E:\MosaicEnv\gui.py", line 270, in load_img_action
imgs = mkg.read_images(fp, sizes, recursive.get(), mp.Pool(cpu_count() // 2), resize_opt.get(), auto_rotate.get())
File "E:\MosaicEnv\make_img.py", line 795, in read_images
most_freq_ratio = 1 / sizes[-1][1]
IndexError: list index out of range
Environment is Python 3.10.3 with the following libraries:
altgraph==0.17.2
certifi==2021.10.8
charset-normalizer==2.0.12
cloudscraper==1.2.60
colorama==0.4.4
cycler==0.11.0
fonttools==4.32.0
future==0.18.2
idna==3.3
imagesize==1.3.0
kiwisolver==1.4.2
lapjv==1.3.1
matplotlib==3.5.1
numpy==1.22.3
opencv-contrib-python==4.5.5.62
opencv-python==4.5.5.64
packaging==21.3
pefile==2021.9.3
Pillow==9.1.0
pyinstaller==4.8
pyinstaller-hooks-contrib==2022.3
pyparsing==3.0.8
python-dateutil==2.8.2
pywin32-ctypes==0.2.0
random-user-agent==1.0.1
requests==2.27.1
requests-toolbelt==0.9.1
six==1.16.0
tqdm==4.64.0
typing==3.7.4.3
urllib3==1.26.9
This seems new to the recent version- over a certain size tile, the GUI does not seem to want to allow "Photomosaic" to be clicked, hanging and becoming unresponsive (Windows) but does not outright crash.
This seems to happen at some point just above 100px (perhaps 125) with a tileset of 300,000 tiles.
It also seems this problem has something to do with the continuous display of the resulting PNG, I suspect displaying a 105570x66015 image (for 135px tiles on a 782x489 grid) might be causing something akin to a memory leak.
Each version of this is exponentially more stable and useful, I have to commend you developers!
Context:
I'm trying to work with 100+ images, And I want the tiles to be squared. But the option that was referred for my expected result is not working nor doesn't do its functionality. (BTW, I'm running it in Ubuntu 18). And also I'm using the latest version of this tool.
Based on your readme guide of --resize_opt
:
How to resize each tile so they become square images.
Center: crop a square in the center.
Stretch: stretch the tile (default: center)
My options:
...
--path ../imgs \
--dest_img img.jpg \
--size 50 \
--dup 1 \
--blending alpha \
--blending_level 0.25 \
--resize_opt center \
--freq_mul 0.1 \
--max_width 85 \
--unfair \
--deterministic \
--out out.png
here is the command.
python3 make_img.py --path ~/Documents/photo/resize --dest_img ~/Documents/photo/20190607_131053.jpg --size 200 --dup 4 --unfair --freq_mul 100.0 --blending alpha --blending_level 0.1 --resize_opt center --out ~/Documents/photo/result_unfair-dup-4-freq-100-alpha-0_1_cen_200.png
the result is each tile does not crop the center, but stretch to fit the square
Would love an option output CSV log of each tile used!
(on latest ea6c45753122135dc21cfd71b3b3edefe1a70fd2
from 2022-11-26
).
I encountered one more undeclared dependency:
ModuleNotFoundError: No module named 'numpy'
I solved this issue by installing numpy with pip install numpy
.
Thank you for image-collage-maker and keep up the great work!
Hello,
I'm on MacOs 13.4.1/Intel and Python 3.8.0. pip'ed requirements.txt and run gui.py. The Gui is opening and I can select an image folder. After clicking on "choose" while processing, the error "UnboundLocalError: local variable 'w' referenced before assignment" appears.
Thanks
There is a notable lag in the process when loading tiles (Windows GUI) after "Aligning images on the grid...
Note: ### transparent tiles will be added to the grid"
Perhaps a progress bar would help in indicating if the process was frozen?
Additionally, could CuPy/CUDA acceleration be used in this phase?
➜ image-collage-maker git:(master) python make_img.py --path AllImages --recursive --resize_opt stretch --sort rand
File "make_img.py", line 30
def __init__(self, type: Any, help: str, default=None, nargs=None, choices: List[Any]=None) -> None:
^
SyntaxError: invalid syntax
I have a 100 images I ran this command
!python3 make_img.py --path /inpath --out /outpath/collage.jpg --sort pca_bgr --size 200
looking to get a 2000x2000px image
I got a 2600x1400px image which is collage and it has 13 images across and height of 7 images so possible some images not there.
How can I get 2000x2000px collage image with 100 images input and 10 images across width and 10 images height?
Using
hanzhi713/image-collage-maker
in version v5.1
python3 gui.py
Traceback (most recent call last):
File "/root/git/image-collage-maker/gui.py", line 1, in <module>
import tkinter as tk
ModuleNotFoundError: No module named 'tkinter'
I was able to fix this problem with installing python3-tk
:
apt install python3-tk
I guess this is good to document.
Cheers
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.