Datadolittle / Photo_Mosaic

A repository to create photo mosaics using python3
MIT License
88 stars 34 forks source link

did'nt change anything just cloned and run ValueError: not enough values to unpack (expected 3, got 2) #1

Closed Hardik-G1 closed 4 years ago

Hardik-G1 commented 4 years ago

starting photomosaic creation... resizing images... max tile dims: (12, 15) Traceback (most recent call last): File "scripts/Mosaic_Creator.py", line 153, in mosaic_image = createPhotomosaic(target_image, input_images, grid_size, reuse_images) File "scripts/Mosaic_Creator.py", line 85, in createPhotomosaic avgs.append(getAverageRGB(img)) File "scripts/Mosaic_Creator.py", line 33, in getAverageRGB w, h, d = im.shape ValueError: not enough values to unpack (expected 3, got 2)

glickmac commented 4 years ago

Hi Hardik! This error is from the background images not having 3 channels (Red, Blue, Green values). Only .jpeg or .jpg images will work with this script. The Image_Tester.py function should move background images not usable in the photo mosaic creator. Let me know if that solves the issue.

Hardik-G1 commented 4 years ago

Hi Hardik! This error is from the background images not having 3 channels (Red, Blue, Green values). Only .jpeg or .jpg images will work with this script. The Image_Tester.py function should move background images not usable in the photo mosaic creator. Let me know if that solves the issue.

i am using the stock images that were extracted but still the same error

glickmac commented 4 years ago

Hi Hardik, there seems to be a .DS_Store file in the Trees/ folder, remove that store with

‘’’ rm Trees/.DS_Store ‘’’

Let me know if that and the png file are removed from the Trees folder and if you are still getting an error

Hardik-G1 commented 4 years ago

rm Trees/.DS_Store I have not changed any image file, all are jpg/jpeg from the data\Trees folder. C:\Users\i\Downloads\Compressed\Photo_Mosaic-master\Photo_Mosaic-master>python3 scripts/Image_Tester.py --images data/Trees

C:\Users\i\Downloads\Compressed\Photo_Mosaic-master\Photo_Mosaic-master>python3 scripts/Mosaic_Creator.py --target data/Tree.jpg --images data/Trees/ --grid 100 100 --output data/Mosaic.jpeg reading input folder... starting photomosaic creation... resizing images... max tile dims: (12, 15) Traceback (most recent call last): File "scripts/Mosaic_Creator.py", line 153, in mosaic_image = createPhotomosaic(target_image, input_images, grid_size, reuse_images) File "scripts/Mosaic_Creator.py", line 85, in createPhotomosaic avgs.append(getAverageRGB(img)) File "scripts/Mosaic_Creator.py", line 33, in getAverageRGB w, h, d = im.shape ValueError: not enough values to unpack (expected 3, got 2)

Hardik-G1 commented 4 years ago

i used this and somehow it worked

import os
import os,os.path
import glob
os.chdir('C:\\Users\\i\\Downloads\\Compressed\\Photo_Mosaic-master\\Photo_Mosaic-master\\data\\Trees')
i=0
dir = sorted(os.listdir(os.getcwd()), key=len)
for file in dir:
    src=file
    dst=str(i)+".jpeg"
    os.rename(src,dst)
    i+=1