stable-diffusion-webui-depthmap-script icon indicating copy to clipboard operation
stable-diffusion-webui-depthmap-script copied to clipboard

ERROR When Generating 3d Mesh

Open Pwhite95 opened this issue 2 years ago • 20 comments

I'm new to a lot of this stuff so any help would be great and I appreciate anyone's time who can help.

Consul output:

Traceback (most recent call last): File "C:\StableDiffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 284, in run_predict output = await app.blocks.process_api( File "C:\StableDiffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 983, in process_api data = self.postprocess_data(fn_index, result["prediction"], state) File "C:\StableDiffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 930, in postprocess_data prediction_value = block.postprocess(prediction_value) File "C:\StableDiffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\components.py", line 3606, in postprocess "name": processing_utils.create_tmp_copy_of_file(y, dir=self.temp_dir).name, File "C:\StableDiffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\processing_utils.py", line 341, in create_tmp_copy_of_file shutil.copy2(file_path, file_obj.name) File "C:\Users\patri\AppData\Local\Programs\Python\Python310\lib\shutil.py", line 434, in copy2 copyfile(src, dst, follow_symlinks=follow_symlinks) File "C:\Users\patri\AppData\Local\Programs\Python\Python310\lib\shutil.py", line 254, in copyfile with open(src, 'rb') as fsrc: OSError: [Errno 22] Invalid argument: "

OSError: cannot write mode I;16 as JPEG

Time taken: 8.42s

Torch active/reserved: 3082/3358 MiB, Sys VRAM: 5785/12288 MiB (47.08%)

"

Pwhite95 avatar Jun 28 '23 16:06 Pwhite95

Update: The tab has disappeared again. I am not running this on Google Collab either.

For what it's worth my setup is this:

CPU: AMD RYZEN 9 5950 CPU: NVIDIA GeForce RTX 3080

RAM: 2x Crorsair CM64GX4M2D3600C18 DDR4

Pwhite95 avatar Jun 28 '23 17:06 Pwhite95

Please upgrade the extension, last change was today, ~13:30.

What did you do before you got the first console output? Also, please provide the full console output, not only the stacktrace.

For the tab disappearing, could you please share the console output from a time where WebU Itab is not shown?

semjonsona avatar Jun 28 '23 17:06 semjonsona

OSError: cannot write mode I;16 as JPEG

It's trying to save a 16 bit single channel image as jpeg, which does not support this format. This can be due to the option in webui to save a copy as jpg when png size or dimentions exceed a set value..

On Wed, Jun 28, 2023, 19:49 Semjon Kravtšenko @.***> wrote:

What did you do before you got the first console output? Also, please provide the full console output, not only the stacktrace.

For the tab disappearing, could you please share the console output from a time where WebU Itab is not shown?

— Reply to this email directly, view it on GitHub https://github.com/thygate/stable-diffusion-webui-depthmap-script/issues/268#issuecomment-1611841195, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXA4UKVU3K7ELAXPHLJGMYDXNRVCLANCNFSM6AAAAAAZXMP4WE . You are receiving this because you are subscribed to this thread.Message ID: <thygate/stable-diffusion-webui-depthmap-script/issues/268/1611841195@ github.com>

thygate avatar Jun 28 '23 17:06 thygate

@semjon00 Is there any way I can go back and look at the history in my console output?

The only thing I did was upload my photo and when I generated it took some time and then an error came up

The tab disappeared when I updated to the new version and restarted the UI.

Pwhite95 avatar Jun 28 '23 17:06 Pwhite95

@Pwhite95 Sadly, no. A fresh console output would still be very useful, maybe it will have hints about why the tab is not shown.

semjonsona avatar Jun 28 '23 18:06 semjonsona

@thygate I hoped this was bandaid-patched in 0b7d7ef6 and also 1065ec10. Offtopic: thank you for your email, did my response got into your inbox?

semjonsona avatar Jun 28 '23 18:06 semjonsona

@Pwhite95 Sadly, no. A fresh console output would still be very useful, maybe it will have hints about why the tab is not shown.

@semjon00 Let me know if you need more

Error loading script: depthmap.py Traceback (most recent call last): File "C:\StableDiffusion\stable-diffusion-webui\modules\scripts.py", line 195, in load_scripts module = script_loading.load_module(scriptfile.path) File "C:\StableDiffusion\stable-diffusion-webui\modules\script_loading.py", line 13, in load_module exec(compiled, module.dict) File "C:\StableDiffusion\stable-diffusion-webui\extensions\stable-diffusion-webui-depthmap-script\scripts\depthmap.py", line 43, in script_dir = os.path.dirname(os.path.realpath(file)) NameError: name 'file' is not defined

Pwhite95 avatar Jun 28 '23 18:06 Pwhite95

How do you run WebUI?

semjonsona avatar Jun 28 '23 18:06 semjonsona

@semjon00

I run it locally on my c-drive

Pwhite95 avatar Jun 28 '23 18:06 Pwhite95

Huh, this is interesting... Please try the following: Open the depthmap.py and replace this text

script_dir = os.path.dirname(os.path.realpath(__file__))
extension_dir = pathlib.Path(script_dir).parent
sys.path.append(extension_dir)

with this text

sys.path.append(pathlib.Path.cwd().parent)

Restart WebUI and try again. Does this work?

semjonsona avatar Jun 28 '23 18:06 semjonsona

@semjon00

Can't seem to open the script either... I tried a workaround and opened the command console and this is what it said:

C:\StableDiffusion\stable-diffusion-webui\extensions\stable-diffusion-webui-depthmap-script\scripts>python depthmap.py Traceback (most recent call last): File "C:\StableDiffusion\stable-diffusion-webui\extensions\stable-diffusion-webui-depthmap-script\scripts\depthmap.py", line 4, in import modules.scripts as scripts ModuleNotFoundError: No module named 'modules'

Pwhite95 avatar Jun 28 '23 18:06 Pwhite95

Please start Notepad and drag-and-drop the depthmap.py file into the Notepad. Then you can edit it. Please don't forget to save the file.

semjonsona avatar Jun 28 '23 18:06 semjonsona

@semjon00

YES. The tab is back, although my image is still came up with an error when generating:

DepthMap v0.3.12 (685f9631) device: cuda Loading model weights from ./models/leres/res101.pth initialize network with normal loading the model from ./models/pix2pix\latest_net_G.pth Computing depthmap(s) .. 0%| | 0/1 [00:00<?, ?it/s]

wholeImage being processed in : 896 Adjust factor is: 1.3706140350877192 Selecting patches ... Target resolution: (1382, 2456, 3) Resulting depthmap resolution will be : (2160, 3839) patches to process: 5 processing patch 0 / 4 | [ 853 328 1804 1804] processing patch 1 / 4 | [1379 328 1804 1804] processing patch 2 / 4 | [1904 328 1804 1804] processing patch 3 / 4 | [1575 0 1400 1400] processing patch 4 / 4 | [2101 0 1400 1400] 0%| | 0/1 [00:08<?, ?it/s] Error completing request Arguments: (0, <PIL.Image.Image image mode=RGB size=3840x2160 at 0x14307BF9000>, None, '', '', 0, 0, 512, 512, False, True, False, False, 0, 1, False, 1, True, True, False, False, ['left-right', 'red-cyan-anaglyph'], 2.5, 0, 'polylines_sharp', 0, True, False, False, False, False, 'u2net', False, 0, 2, False, None, True, False, True, False) {} Traceback (most recent call last): File "C:\StableDiffusion\stable-diffusion-webui\venv\lib\site-packages\PIL\JpegImagePlugin.py", line 630, in _save rawmode = RAWMODE[im.mode] KeyError: 'I;16'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "C:\StableDiffusion\stable-diffusion-webui\modules\call_queue.py", line 45, in f res = list(func(*args, **kwargs)) File "C:\StableDiffusion\stable-diffusion-webui\modules\call_queue.py", line 28, in f res = func(*args, **kwargs) File "C:\StableDiffusion\stable-diffusion-webui\extensions\stable-diffusion-webui-depthmap-script\scripts\depthmap.py", line 1207, in run_generate outputs, mesh_fi, meshsimple_fi = run_depthmap( File "C:\StableDiffusion\stable-diffusion-webui\extensions\stable-diffusion-webui-depthmap-script\scripts\depthmap.py", line 698, in run_depthmap images.save_image(Image.fromarray(img_output), path=outpath, basename=basename, seed=None, prompt=None, extension=opts.samples_format, info=info, short_filename=True,no_prompt=True, grid=False, pnginfo_section_name="extras", existing_info=None, forced_filename=None) File "C:\StableDiffusion\stable-diffusion-webui\modules\images.py", line 550, in save_image _atomically_save_image(image, fullfn_without_extension, ".jpg") File "C:\StableDiffusion\stable-diffusion-webui\modules\images.py", line 519, in _atomically_save_image image_to_save.save(temp_file_path, format=image_format, quality=opts.jpeg_quality) File "C:\StableDiffusion\stable-diffusion-webui\venv\lib\site-packages\PIL\Image.py", line 2320, in save save_handler(self, fp, filename) File "C:\StableDiffusion\stable-diffusion-webui\venv\lib\site-packages\PIL\JpegImagePlugin.py", line 632, in _save raise OSError(f"cannot write mode {im.mode} as JPEG") from e OSError: cannot write mode I;16 as JPEG

Traceback (most recent call last): File "C:\StableDiffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 284, in run_predict output = await app.blocks.process_api( File "C:\StableDiffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 983, in process_api data = self.postprocess_data(fn_index, result["prediction"], state) File "C:\StableDiffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 930, in postprocess_data prediction_value = block.postprocess(prediction_value) File "C:\StableDiffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\components.py", line 3606, in postprocess "name": processing_utils.create_tmp_copy_of_file(y, dir=self.temp_dir).name, File "C:\StableDiffusion\stable-diffusion-webui\venv\lib\site-packages\gradio\processing_utils.py", line 341, in create_tmp_copy_of_file shutil.copy2(file_path, file_obj.name) File "C:\Users\patri\AppData\Local\Programs\Python\Python310\lib\shutil.py", line 434, in copy2 copyfile(src, dst, follow_symlinks=follow_symlinks) File "C:\Users\patri\AppData\Local\Programs\Python\Python310\lib\shutil.py", line 254, in copyfile with open(src, 'rb') as fsrc: OSError: [Errno 22] Invalid argument: "

OSError: cannot write mode I;16 as JPEG

Time taken: 12.39s

Torch active/reserved: 4736/7180 MiB, Sys VRAM: 11862/12288 MiB (96.53%)

"

p.s thank you for your time and help, seriously.

Pwhite95 avatar Jun 28 '23 19:06 Pwhite95

The code I provided was erroneous, sorry... Still learned from this. I will look at this issue now. I am quite puzzled - everything works on my machine, and apparently nowhere else... 😢

semjonsona avatar Jun 28 '23 19:06 semjonsona

@semjon00

Hmmm I got it to make one mesh... but not sure why it's not working for my other photo... does it need to be a specific size? Am I overlooking something?

Interesting... my outputs have the depth maps for the images I tried earlier but the mesh never got made.

Pwhite95 avatar Jun 28 '23 19:06 Pwhite95

The issue above does not affect mesh generation, thankfully.

semjonsona avatar Jun 28 '23 19:06 semjonsona

Hmmm. It's also not importing into blender ---- WRONG , it did, just as an obj

Pwhite95 avatar Jun 28 '23 19:06 Pwhite95

@thygate I hoped this was bandaid-patched in 0b7d7ef and also 1065ec1. Offtopic: thank you for your email, did my response got into your inbox?

thanks for the email. yeah this one has been coming up for some time, i'm not sure how to catch it, testing takes some time .. Are you using vscode for debugging ?

thygate avatar Jun 28 '23 21:06 thygate

My tool of choice for Python is PyCharm, it debugs nicely I guess :) FYI https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/11492 This would fix at least some of the issues with I;16

semjonsona avatar Jun 29 '23 10:06 semjonsona

My tool of choice for Python is PyCharm, it debugs nicely I guess :) That works too ;)

Hopefully this last fix works, I noticed the other day that controlnet always uses and only accepts RGB images with 8 bit per channel for depth maps .. I wonder ..

thygate avatar Jun 29 '23 13:06 thygate