VoxelCubes / PanelCleaner

An AI-powered tool to clean manga panels.
GNU General Public License v3.0
202 stars 16 forks source link

[Windows] RuntimeError: context has already been set when setting Concurent Model to more than 1 in Text Detector #91

Closed arihid closed 3 months ago

arihid commented 3 months ago

Describe the bug I'm working with 97 images. As per Concurrent Model's description suggests, I tried to run 2 simultaneous Concurrent Models. I'm pretty confident with my hardware (running on Intel i7-11800H, 32GB RAM, RTX 3070 Laptop).

To Reproduce Steps to reproduce the behavior:

  1. Set "Concurrent Model" in "Text Detection" for anything above 1.

Expected behavior It should run text detection as in "Concurrent Model" is set to 1.

Session Log

2024-05-02 18:33:38.405 | DEBUG    | pcleaner.gui.mainwindow_driver:apply_profile:1089 - Applying profile.
2024-05-02 18:33:39.711 | INFO     | pcleaner.gui.mainwindow_driver:start_cleaning:1275 - Requested outputs: [<Output.inpainted_mask: 19>, <Output.write_output: 21>]
2024-05-02 18:33:39.714 | INFO     | pcleaner.gui.processing:generate_output:175 - Running text detection AI model for 97 images...
2024-05-02 18:33:39.715 | CRITICAL | pcleaner.gui.mainwindow_driver:output_worker_error:1433 - Encountered an error while processing files.
Traceback (most recent call last):

> File "C:\Users\<username>\AppData\Local\Programs\Python\Python312\Lib\site-packages\pcleaner\gui\worker_thread.py", line 141, in run
    result = self.fn(*self.args, **self.kwargs)
             │    │   │    │       │    └ {'progress_callback': <PySide6.QtCore.SignalInstance progress(PyObject) at 0x00000166B8C661F0>, 'abort_flag': <pcleaner.gui.w...
             │    │   │    │       └ <pcleaner.gui.worker_thread.Worker object at 0x000001670BD9FE40>
             │    │   │    └ ([<Output.inpainted_mask: 19>, <Output.write_output: 21>], WindowsPath('cleaned'), [<pcleaner.gui.image_file.ImageFile object...
             │    │   └ <pcleaner.gui.worker_thread.Worker object at 0x000001670BD9FE40>
             │    └ <bound method MainWindow.generate_output of <pcleaner.gui.mainwindow_driver.MainWindow(0x1664b1e6ff0, name="MainWindow") at 0...
             └ <pcleaner.gui.worker_thread.Worker object at 0x000001670BD9FE40>
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python312\Lib\site-packages\pcleaner\gui\mainwindow_driver.py", line 1315, in generate_output
    prc.generate_output(
    │   └ <function generate_output at 0x000001664DDEF6A0>
    └ <module 'pcleaner.gui.processing' from 'C:\\Users\\<username>\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\pc...
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python312\Lib\site-packages\pcleaner\gui\processing.py", line 179, in generate_output
    ctm.model2annotations_gui(
    │   └ <function model2annotations_gui at 0x00000166540C7560>
    └ <module 'pcleaner.gui.ctd_interface_gui' from 'C:\\Users\\<username>\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packa...
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python312\Lib\site-packages\pcleaner\gui\ctd_interface_gui.py", line 81, in model2annotations_gui
    mp.set_start_method("spawn")
    │  └ <bound method DefaultContext.set_start_method of <multiprocessing.context.DefaultContext object at 0x000001662161D100>>
    └ <module 'multiprocessing' from 'C:\\Users\\<username>\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\multiprocessing\\__init__...
  File "C:\Users\<username>\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\context.py", line 247, in set_start_method
    raise RuntimeError('context has already been set')

RuntimeError: context has already been set
VoxelCubes commented 3 months ago

Ah, that doesn't look good. I should probably just remove that feature from the gui already, it's been nothing but trouble for hardly any speed up.

VoxelCubes commented 3 months ago

Yeah, I added an extra warning that this isn't guaranteed to work, so unfortunately won't fix. Last time I tried it worked with CPU, but cuda like here appears to break it.