Closed softyoda closed 1 year ago
Hi! I don't think it has to do with the path (absolute paths should work fine), but more with the parameters in your config.
Could you share your hydra config? Apparently, you have an issue with the value tile_size
which should be an integer only. From the logs, you left tile_size: tile_size_in_pixels 20
. Same for the num_colors: number_of_mosaic_colors 256
Try just tile_size: 20
and num_colors: 256
, and let me know what comes after.
Oh, ok, I have changed, and now it isn't the same error
(you should maybe edit the default yaml from tile_size: tile_size_in_pixels [int]
to tile_size: [tile_size_in_pixels (int)]
)
The new error :
main.py:18: UserWarning:
The version_base parameter is not specified.
Please specify a compatability version level, or None.
Will assume defaults for version 1.1
@hydra.main(config_path="data/configs", config_name="default.yaml")
C:\Users\intel\AppData\Local\Programs\Python\Python311\Lib\site-packages\hydra\_internal\hydra.py:119: UserWarning: Future Hydra versions will no longer change working directory at job runtime by default.
See https://hydra.cc/docs/1.2/upgrades/1.1_to_1.2/changes_to_job_working_dir/ for more information.
ret = run_job(
[2023-07-25 18:20:49,722][__main__][INFO] - Using the following configuration:
[2023-07-25 18:20:49,722][__main__][INFO] - image_path: C:/Users/intel/Desktop/Image_tiling/mosaic_generator/data/in/jesus.jpg
output_folder: C:/Users/intel/Desktop/Image_tiling/mosaic_generator/data/out/
edge_extraction_method: HED
tile_size: 20
coloring_method: original
num_colors: 256
resize_image: false
[2023-07-25 18:20:49,723][__main__][INFO] - Starting MosaicGenerator
[2023-07-25 18:20:49,723][__main__.utils.image_handler][INFO] - Loading image
[2023-07-25 18:20:49,810][__main__.edges.edge_extractor][INFO] - Extracting edges of image
Error executing job with overrides: []
Traceback (most recent call last):
File "C:\Users\intel\Desktop\Image_tiling\mosaic_generator\main.py", line 32, in generate_mosaic
mosaic.generate_mosaic()
File "C:\Users\intel\Desktop\Image_tiling\mosaic_generator\mosaic\mosaic_generator.py", line 79, in generate_mosaic
image_edges = self.edge_extractor.run(image)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\intel\Desktop\Image_tiling\mosaic_generator\edges\edge_extractor.py", line 118, in run
edges = hed.extract_edges(image)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\intel\Desktop\Image_tiling\mosaic_generator\edges\hed.py", line 129, in extract_edges
image_edges = run_hed_network(input_image)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\intel\Desktop\Image_tiling\mosaic_generator\edges\hed.py", line 84, in run_hed_network
network = load_network()
^^^^^^^^^^^^^^
File "C:\Users\intel\Desktop\Image_tiling\mosaic_generator\edges\hed.py", line 51, in load_network
assert os.path.isfile(
AssertionError: C:\Users\intel\Desktop\Image_tiling\mosaic_generator\edges\hed_pretrained_bsds.caffemodel does not exist, download from source https://github.com/s9xie/hed
I haven't found how set HYDRA_FULL_ERROR=1
in windows
I had the error missing deploy.prototxt
that I download from but I don't know where is this hed_pretrained_bsds.caffemodel
file.
I have found a working version of hed_pretrained_bsds.caffemodel
here
My new issue is:
[2023-07-25 19:29:39,854][__main__][INFO] - Starting MosaicGenerator
[2023-07-25 19:29:39,854][__main__.utils.image_handler][INFO] - Loading image
[2023-07-25 19:29:39,940][__main__.edges.edge_extractor][INFO] - Extracting edges of image
Error executing job with overrides: []
Traceback (most recent call last):
File "C:\Users\intel\Desktop\Image_tiling\mosaic_generator\main.py", line 32, in generate_mosaic
mosaic.generate_mosaic()
File "C:\Users\intel\Desktop\Image_tiling\mosaic_generator\mosaic\mosaic_generator.py", line 79, in generate_mosaic
image_edges = self.edge_extractor.run(image)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\intel\Desktop\Image_tiling\mosaic_generator\edges\edge_extractor.py", line 118, in run
edges = hed.extract_edges(image)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\intel\Desktop\Image_tiling\mosaic_generator\edges\hed.py", line 129, in extract_edges
image_edges = run_hed_network(input_image)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\intel\Desktop\Image_tiling\mosaic_generator\edges\hed.py", line 86, in run_hed_network
output = network.forward()
^^^^^^^^^^^^^^^^^
cv2.error: Unknown C++ exception from OpenCV code
Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.
Yes, good suggestion. I've already modified the default yaml configs.
As it is indicated in the AssertionError
, you can get the files from the repo source. Here are the links as well for the pre-trained model and the prototxt file.
The new issue is an opencv error. Check your opencv-python
version with pip list
, it should be opencv-python==4.6.0.66
Hello, I am not a programmer and know very little about python. Tried to run the files on Pycharm, and for some reason it stops at the edge detection. Here is what I see when I run main.py:
import sys; print('Python %s on %s' % (sys.version, sys.platform)) C:\Users\Name\AppData\Local\Programs\Python\Python311\python.exe "C:/Program Files/JetBrains/PyCharm Community Edition 2023.2/plugins/python-ce/helpers/pydev/pydevd.py" --multiprocess --qt-support=auto --client 127.0.0.1 --port 64234 --file C:\Users\Name\PycharmProjects\mosaic_generator-main\main.py Connected to pydev debugger (build 232.8660.197) C:\Users\Name\PycharmProjects\mosaic_generator-main\main.py:18: UserWarning: The version_base parameter is not specified. Please specify a compatability version level, or None. Will assume defaults for version 1.1 @hydra.main(config_path="data/configs", config_name="default.yaml") C:\Users\Name\AppData\Local\Programs\Python\Python311\Lib\site-packages\hydra_internal\hydra.py:119: UserWarning: Future Hydra versions will no longer change working directory at job runtime by default. See https://hydra.cc/docs/1.2/upgrades/1.1_to_1.2/changes_to_job_working_dir/ for more information. ret = run_job( [2023-08-23 22:47:17,225][main][INFO] - Using the following configuration: [2023-08-23 22:47:17,231][main][INFO] - image_path: /path/to/image.jpg output_folder: /path/to/folder edge_extraction_method: HED tile_size: 10 coloring_method: kmeans num_colors: 5 resize_image: false mosaic_height: 10 mosaic_width: 10 interactive_edge_modification: true save_intermediate_steps: false edges_path: null [2023-08-23 22:47:17,232][main][INFO] - Starting MosaicGenerator [2023-08-23 22:47:17,236][main.utils.image_handler][INFO] - Loading image [2023-08-23 22:47:17,275][main.edges.edge_extractor][INFO] - Extracting edges of image [2023-08-23 22:47:24,715][main.edges.edge_extractor][INFO] - Launching interactive edge correction
Any advice?
Hi @tawfar,
It seems you are using a default.yaml
instead of a modified one with your input parameters.
You can look here to check how to run the script with a .yaml
file with your desired parameters.
If you have further questions, you can ask them on this issue, or open a new one.
Not sure that this is the issue, I get the following when I run the program, and I see the original image appearing with some blue edges, but nothing further happens, it just stays there: C:\Users\Tawfiq\AppData\Local\Programs\Python\Python311\python.exe C:\Users\Tawfiq\PycharmProjects\mosaic_generator-main\main.py C:\Users\Tawfiq\PycharmProjects\mosaic_generator-main\main.py:18: UserWarning: The version_base parameter is not specified. Please specify a compatability version level, or None. Will assume defaults for version 1.1 @hydra.main(config_path="data/configs", config_name="default.yaml") C:\Users\Tawfiq\AppData\Local\Programs\Python\Python311\Lib\site-packages\hydra_internal\hydra.py:119: UserWarning: Future Hydra versions will no longer change working directory at job runtime by default. See https://hydra.cc/docs/1.2/upgrades/1.1_to_1.2/changes_to_job_working_dir/ for more information. ret = run_job( [2023-08-27 11:31:37,733][main][INFO] - Using the following configuration: [2023-08-27 11:31:37,734][main][INFO] - image_path: /path/to/image.jpg output_folder: /path/to/folder edge_extraction_method: HED tile_size: 10 coloring_method: kmeans num_colors: 5 resize_image: false mosaic_height: 10 mosaic_width: 10 interactive_edge_modification: true save_intermediate_steps: false edges_path: null
[2023-08-27 11:31:37,734][main][INFO] - Starting MosaicGenerator [2023-08-27 11:31:37,787][main.utils.image_handler][INFO] - Loading image [2023-08-27 11:31:38,208][main.edges.edge_extractor][INFO] - Extracting edges of image [2023-08-27 11:32:23,245][main.edges.edge_extractor][INFO] - Launching interactive edge correction
Hi @tawfar,
Could you paste here your parameters.yaml
file to have a look?
From the error code you pasted:
@hydra.main(config_path="data/configs", config_name="default.yaml")
...
[2023-08-27 11:31:37,733][main][INFO] - Using the following configuration:
[2023-08-27 11:31:37,734][main][INFO] - image_path: /path/to/image.jpg
output_folder: /path/to/folder
I see you are using the default configuration and not yours. Please get the latest version of the code and paste here your .yaml
configuration and how you're running it.
Hi Javier, There are three things that I would appreciate if you can look into: First, here is the text for default.yaml: image_path: /path/to/image.jpg # string with absolute or relative path to the image output_folder: /path/to/folder # string with absolute or relative path to the output folder edge_extraction_method: HED # string with any of the options: HED (deep learning method), diblasi or sobel tile_size: 10 # int defining the tile size in pixels coloring_method: kmeans # str with any of the options: original (more colors), kmeans num_colors: 5 # int with number of colors to extract, only applicable when coloring_method: kmeans resize_image: False # bool defining if to resize the image to half the size mosaic_height: 10 # Size in cm of the desired mosaic mosaic_width: 10 # Size in cm of the desired mosaic interactive_edge_modification: True # If set to true it opens an interactive window to modify the edges save_intermediate_steps: False # Defines if to save the intermediate steps (extracted edges, mosaic guides) edges_path : null # You can load extracted edges if they were saved, give the path to the image with the edges
hydra: run: dir: ${output_folder}/${now:%Y.%m.%d-%H-%M-%S}
Second, if I change line 18 as follows: @hydra.main(config_path="data/configs", config_name="default_parallel.yaml") I get the following error message: C:\Users\Tawfiq\AppData\Local\Programs\Python\Python311\python.exe C:\Users\Tawfiq\PycharmProjects\mosaic_generator-main\main.py C:\Users\Tawfiq\PycharmProjects\mosaic_generator-main\main.py:18: UserWarning: The version_base parameter is not specified. Please specify a compatability version level, or None. Will assume defaults for version 1.1 @hydra.main(config_path="data/configs", config_name="default_parallel.yaml") In 'hydra/config': Could not find 'hydra/launcher/joblib'
Available options in 'hydra/launcher': basic Config search path: provider=hydra, path=pkg://hydra.conf provider=main, path=file://C:\Users\Tawfiq\PycharmProjects\mosaic_generator-main\data\configs provider=schema, path=structured://
Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.
Process finished with exit code 1
Third, Here is the text for the default_parallel.yaml file: image_path: /path/to/image.jpg # string with absolute or relative path to the image output_folder: /path/to/folder # string with absolute or relative path to the output folder num_colors: 50 # int with number of colors to extract, only applicable when coloring_method: kmeans resize_image: False # bool defining if to resize the image to half the size mosaic_height: 100 # Size in cm of the desired mosaic mosaic_width: 100 # Size in cm of the desired mosaic interactive_edge_modification: False # If set to true it opens an interactive window to modify the edges, better set to False for parallel running save_intermediate_steps: False # Defines if to save the intermediate steps (extracted edges, mosaic guides) edges_path : null # You can load extracted edges if they were saved, give the path to the image with the edges
defaults:
hydra: run: dir: ${output_folder}/${now:%Y.%m.%d-%H-%M-%S} mode: MULTIRUN sweep: dir: ${outputfolder}/multirun${now:%Y.%m.%d-%H-%M-%S} subdir: run_${hydra.job.num} sweeper: params: +edge_extraction_method: HED,diblasi +tile_size: 4,8,10 +coloring_method: original,kmeans
I appreciate your help in this
Hi @tawfar, I still think you need to have a look at the usage instructions. The current values in default.yaml
are just an example with some comments, you need to change them accordingly to your needs.
First, I would like to know how do you want to use this code. Do you have an image that you want to convert to a mosaic? If so, I would suggest you do the following:
default.yaml
file with the changes:
Hopefully, this time you would get a mosaic after changing the default parameters. Let me know how it goes.
Thanks Javier, this seems to work. I will experiment with it and try different tile sizes. Much appreciated
Glad it worked! Yes, try out the different parameters and keep an eye on the repository for the latest updates. I plan to add more features both for artist and coders ;). I will close this issue now, but feel free to open a new one in case of any question, error or feature request.
Hi, i have edited the yaml config from
to
But I have the following error:
Is it because of windows environment or else ? Is there possibility to directly edit variable with raw string in the python code instead of preasing yaml file making it harder to know what path is compatible (absolute, relative, relative from where, with backslash or not)