nuno-faria / tiler Goto Github PK
View Code? Open in Web Editor NEWπ· Build images with images
License: MIT License
π· Build images with images
License: MIT License
Hello there and thanks for this awesome repo.
I am trying to manipulate the config parameters to get the awesome results in the readme ,but I can not make that happen.
Can you provide details config for each example ?
I'm working with a 960 * 960 pixel image with circle_100 tile, it takes me about 20 mins. Is it because of the poor performance of my computer? Can I accelerate it with GPU? Looking forward your reply.
β tiler git:(master) python gen_tiles.py ../tiles/Glitch_Purple_RGB.png ../tiles/glitch_tiles
File "gen_tiles.py", line 42
f'{out_folder}/{img_name}{round(r,1)}{round(g,1)}_{round(b,1)}_r{rotation}.{ext}',
^
SyntaxError: invalid syntax
File "tiler.py", line 1, in
import cv2
ImportError: No module named cv2
The tiler.py fails with the following error:
Creating tiled image
0%| | 0/999990 [00:00<?, ?it/s]
Traceback (most recent call last):
File "tiler.py", line 225, in <module>
File "tiler.py", line 220, in main
if __name__ == "__main__":
File "tiler.py", line 190, in create_tiled_image
File "tiler.py", line 175, in place_tile
mask = mask[:img_box.shape[0], :img_box.shape[1]]
TypeError: flip() missing 1 required positional argument: 'axis'
Hello, I just install all requirements into virtualenv with py3 on the board and tried to run tiller.py
(with raw config from master branch) on the png image from the sample images dir and nothing happen:
$ mkdir result
$ virtualenv -p python3 .env
...
$ source .env/bin/activate
(.env) $ pip install -r requirements.txt
...
(.env) $ python3 tiler.py images/cake_lego.png ./result/
Loading tiles
0it [00:00, ?it/s]
Gettting and processing boxes
0it [00:00, ?it/s]
Creating tiled image
0it [00:00, ?it/s]
(.env) $ ls ./result/
(.env) $
what's wrong with me?
I want to batch convert several images instead of selecting them one by one, and I don't know how to do it.
When trying to generate tiles I receive this with a standard image.
Traceback (most recent call last):
File "tiler.py", line 221, in
main()
File "tiler.py", line 216, in main
img = create_tiled_image(boxes, original_res, render=conf.RENDER)
File "tiler.py", line 186, in create_tiled_image
place_tile(img, box)
File "tiler.py", line 173, in place_tile
mask = box['tile'][:, :, 3] != 0
IndexError: index 3 is out of bounds for axis 2 with size 3
WHEN I RUN :"python tiler.py images/gypsophila.png tiles/at/gen_at" , GET:
File "tiler.py", line 188, in create_tiled_image
place_tile(img,box)
File "tiler.py", line 173, in place_tile
p1 = np.flip(box['pos'])
TypeError: flip() missing 1 required positional argument: 'axis'
Traceback (most recent call last):
File "tiler.py", line 223, in
main()
File "tiler.py", line 206, in main
tiles_paths = conf.TILES_FOLDER.split(' ')
AttributeError: 'NoneType' object has no attribute 'split'
Certain images seem to work, but most fail with a very similar message to the example below
All commands run from tiler's root directory (tiler/
)
Run command with .jpg
version of image
python3 gen_tiles.py images/test2/test2.jpg
Output
0%| | 0/5 [00:00<?, ?it/s]
Traceback (most recent call last):
File "gen_tiles.py", line 31, in <module>
new_img = img * [b, g, r, 1]
ValueError: operands could not be broadcast together with shapes (1360,1000,3) (4,)
Convert image to .png
, run command again
python3 gen_tiles.py images/test2/test2.png
Output:
Traceback (most recent call last):
File "gen_tiles.py", line 23, in <module>
img = img.astype('float')
AttributeError: 'NoneType' object has no attribute 'astype'
System information:
Python 3.7.2
pip 18.1 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)
Mac OS X 10.14.5
@nuno-faria I am creating my own tiler and while i have not copied any of your code I have used some of your tiles but I wanted to get permission to do this before I continue on. If you say no i will remove the tiles I have copied so far. Thanks
$ python tiler.py path/to/image path/to/tiles_folder/
0it [00:00, ?it/s]
Loading tiles
Gettting and processing boxes
Traceback (most recent call last):
File "tiler.py", line 221, in
main()
File "tiler.py", line 215, in main
boxes, original_res = get_processed_image_boxes(image_path, tiles)
File "tiler.py", line 149, in get_processed_image_boxes
img = read_image(image_path)
File "tiler.py", line 34, in read_image
img = color_quantization(img.astype('float'), COLOR_DEPTH)
AttributeError: 'NoneType' object has no attribute 'astype'
how to deal thanks!
when I run python tiler.py path/to/image path/to/tiles_folder/
, stuck at "Getting and processing boxes".
Loading tiles
100%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 125/125 [00:03<00:00, 32.19it/s]
Getting and processing boxes
0%|
Running on VirtualBox. LinuxMint w/ Python 3.7.4
typing
python tiler.py images/myimage.png tiles/lines/gen_line_h
gives me the following:
Loading tiles 100%|ββββββββββ| 125/125 [00:00<00:00, 285.37it/s] Gettting and processing boxes 0%| | 0/5 [00:00<?, ?it/s]Traceback (most recent call last): File "tiler.py", line 223, in <module> main() File "tiler.py", line 217, in main boxes, original_res = get_processed_image_boxes(image_path, tiles) File "tiler.py", line 158, in get_processed_image_boxes most_similar_tiles = pool.starmap(most_similar_tile, zip(modes, [ts for x in range(len(modes))])) AttributeError: 'Pool' object has no attribute 'starmap' 0%| | 0/5 [00:33<?, ?it/s]
Hi, I can't get your program to work. Indeed,
if I try
D:\Programs\Tiler\tiler-master>python tiler.py images/cake/cake.png tiles/circles/gen_circle_100
I get the message:
Loading tiles
100%|##########| 125/125 [00:02<00:00, 59.44it/s]
Gettting and processing boxes
0%| | 0/5 [00:00<?, ?it/s]Traceback (most recent call last):
File "tiler.py", line 223, in <module>
main()
File "tiler.py", line 217, in main
boxes, original_res = get_processed_image_boxes(image_path, tiles)
File "tiler.py", line 158, in get_processed_image_boxes
most_similar_tiles = pool.starmap(most_similar_tile, zip(modes, [ts for x in range(len(modes))]))
AttributeError: 'Pool' object has no attribute 'starmap'
0%| | 0/5 [00:17<?, ?it/s]
and if i try D:\Programmes\Tiler\tiler-master>python gen_tiles.py images/cake/cake.png
i get
File "gen_tiles.py", line 45
f'{out_folder}/{img_name}_{round(r,1)}_{round(g,1)}_{round(b,1)}_r{rotation}.{ext}',
^
SyntaxError: invalid syntax
It's a bug or I didn't understand the instructions?
If working on a large image it's possible you won't have enough ram to load, but you have to find this out after the tiles load (which can take a bit). Maybe allocate the buffer first to ensure we have space?
tiler.py:150lines
"Getting" was wrong
Thank you for your job!
Could you share the different args with the examples?
Looking forward to your reply.
Get this when I tried to run my first time tiler
Error message:
Loading tiles
0%| | 0/13 [00:00<?, ?it/s]
Traceback (most recent call last):
File "tiler.py", line 223, in <module>
main()
File "tiler.py", line 216, in main
tiles = load_tiles(tiles_paths)
File "tiler.py", line 85, in load_tiles
tile = read_image(os.path.join(path, tile_name))
File "tiler.py", line 34, in read_image
if img.shape[2] == 3:
AttributeError: 'NoneType' object has no attribute 'shape'
My settings are all correct, they look like this:
# GEN TILES CONFS
# number of divisions per color (R, G and B)
# DEPTH = 4 -> 4 * 4 * 4 = 64 colors
DEPTH = 4
# list of rotations, in degrees, to apply over the original image
ROTATIONS = [0]
#############################
# TILER CONFS
# number of colors per image
COLOR_DEPTH = 32
# tiles scales (1 = default resolution)
RESIZING_SCALES = [0.5, 0.4, 0.3, 0.2, 0.1]
# number of pixels shifted to create each box (tuple with (x,y))
# if value is None, shift will be done accordingly to tiles dimensions
PIXEL_SHIFT = (5, 5)
# if tiles can overlap
OVERLAP_TILES = False
# render image as its being built
RENDER = False
# multiprocessing pool size
POOL_SIZE = 8
# out file name
OUT = 'out.png'
# image to tile (ignored if passed as the 1st arg)
IMAGE_TO_TILE = '/home/orion545/Pictures/57570276_p00.jpg'
# folder with tiles (ignored if passed as the 2nd arg)
TILES_FOLDER = '/home/orion545/BT/tiler/'
I'm using Python3, all dependencies are correctly installed
Keep getting this error
Traceback (most recent call last):
File "tiler.py", line 1, in
import cv2
ImportError: No module named cv2
I am not able to create mosaic using human faces. I am using human faces as tiles. it is generating something else not as the main cover image. can you please guide me regarding this ?
Traceback (most recent call last):
File "tiler.py", line 223, in
main()
File "tiler.py", line 216, in main
tiles = load_tiles(tiles_paths)
File "tiler.py", line 85, in load_tiles
tile = read_image(os.path.join(path, tile_name))
File "tiler.py", line 34, in read_image
if img.shape[2] == 3:
Hi !
I find this project very attractive artisticly-wise, and I was wondering how big of a deal it would be to use SVGs images as an input in order to have scalable vector graphics at the output.
I know it might sound far-fetched, but are you (or can you) consider it ?
Thanks for your great work,
Cheers !
This is the error
python tiler.py
./images/logo.png ./tiles/minecraft
Loading tiles
99%|βββββββββββββββββββββββββββββββββ| 150/151 [00:52<00:00, 2.96it/s]Traceback (most recent call last):
File "tiler.py", line 223, in
main()
File "tiler.py", line 216, in main
tiles = load_tiles(tiles_paths)
File "tiler.py", line 85, in load_tiles
tile = read_image(os.path.join(path, tile_name))
File "tiler.py", line 34, in read_image
if img.shape[2] == 3:
AttributeError: 'NoneType' object has no attribute 'shape'
99%|βββββββββββββββββββββββββββββββββ| 150/151 [00:52<00:00, 2.85it/s]
Hello
I am following the usage instructions, but get some trouble.
Firstly, I download the image "https://www.flaticon.com/free-icon/cake_1102780", then use the script:
$ python tiler.py ~/Downloads/1102780.svg ~/Downloads
Loading tiles
0%| | 0/7 [00:00<?, ?it/s]
Traceback (most recent call last):
File "tiler.py", line 221, in <module>
main()
File "tiler.py", line 214, in main
tiles = load_tiles(tiles_paths)
File "tiler.py", line 83, in load_tiles
tile = read_image(os.path.join(path, tile_name))
File "tiler.py", line 34, in read_image
img = color_quantization(img.astype('float'), COLOR_DEPTH)
And my env:
$ pip freeze
numpy==1.17.2
opencv-python==4.1.1.26
tqdm==4.35.0
Thanks @nuno-fariaοΌI got it
Here is the solution
python tiler.py ~/Downloads/tmp/cake.png tiles/circles/gen_circle_100/
I though the first parameter is my input image, and second parameter as output directory. But it is not, the second parameter is also input, as basic element.
I run it in a MacBook Pro. It is very slowly!
Traceback (most recent call last):
File "/home/kali/tiler/tiler.py", line 223, in
main()
File "/home/kali/tiler/tiler.py", line 217, in main
boxes, original_res = get_processed_image_boxes(image_path, tiles)
File "/home/kali/tiler/tiler.py", line 151, in get_processed_image_boxes
img = read_image(image_path)
File "/home/kali/tiler/tiler.py", line 34, in read_image
if img.shape[2] == 3:
IndexError: tuple index out of range
How do I count the number of each color block used in each picture?
Just wondering whether the algorithm would still work if you use let's say paperclips and minecraft blocks, that would give a lot more creative freedom, but not sure how the algorithm would hold up with many different shapes.
Get the following error. Missing anything in my usage?
`
python tiler.py images/cake_lego.png ./tiles/clips/
Loading tiles
0%| | 0/2 [00:00<?, ?it/s]path
0%| | 0/2 [00:00<?, ?it/s]
Traceback (most recent call last):
File "tiler.py", line 225, in
main()
File "tiler.py", line 218, in main
tiles = load_tiles(tiles_paths)
File "tiler.py", line 87, in load_tiles
tile = read_image(path + tile_name)
File "tiler.py", line 38, in read_image
img = color_quantization(img.astype('float'), COLOR_DEPTH)
AttributeError: 'NoneType' object has no attribute 'astype'
`
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.