Bing-su / adetailer

Auto detecting, masking and inpainting with detection model.
GNU Affero General Public License v3.0
4.08k stars 316 forks source link

[Bug]:"KeyError: 14" when using person_yolo to txt2image, hand_yolo and face_yolo is work will #354

Closed MKC-Mankii closed 10 months ago

MKC-Mankii commented 11 months ago

Describe the bug

Great extesion! hand_yolo and face_yolo is work will. But when i use person_yolo, it occurred the error.

refer the follow error information. thanks!

Screenshots

No response

Console logs, from start to end.

*** Error running postprocess_image: E:\novelai\novelai-webui-aki-v2\extensions\adetailer\scripts\!adetailer.py
    Traceback (most recent call last):
      File "E:\novelai\novelai-webui-aki-v2\modules\scripts.py", line 675, in postprocess_image
        script.postprocess_image(p, pp, *script_args)
      File "E:\novelai\novelai-webui-aki-v2\extensions\adetailer\adetailer\traceback.py", line 159, in wrapper
        raise error from None
    KeyError: '
┌─────────────────────────────────────────────────────────────────────────┐
│                               System info                               │
│ ┌─────────────┬───────────────────────────────────────────────────────┐ │
│ │             │ Value                                                 │ │
│ ├─────────────┼───────────────────────────────────────────────────────┤ │
│ │    Platform │ Windows-10-10.0.22621-SP0                             │ │
│ │      Python │ 3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:50:30)  │ │
│ │             │ [MSC v.1933 64 bit (AMD64)]                           │ │
│ │     Version │ v1.6.0                                                │ │
│ │      Commit │ 5ef669de080814067961f28357256e8fe27544f4              │ │
│ │ Commandline │ [\'E:\\\\novelai\\\\novelai-webui-aki-v2\\\\launch.py\',      │ │
│ │             │ \'--medvram-sdxl\', \'--theme\', \'dark\', \'--xformers\',    │ │
│ │             │ \'--api\', \'--autolaunch\']                              │ │
│ │   Libraries │ {\'torch\': \'2.0.1+cu118\', \'torchvision\':               │ │
│ │             │ \'0.15.2+cu118\', \'ultralytics\': \'8.0.194\',             │ │
│ │             │ \'mediapipe\': \'0.10.5\'}                                │ │
│ └─────────────┴───────────────────────────────────────────────────────┘ │
│                                 Inputs                                  │
│ ┌─────────────────┬───────────────────────────────────────────────────┐ │
│ │                 │ Value                                             │ │
│ ├─────────────────┼───────────────────────────────────────────────────┤ │
│ │          prompt │ ((Best quality)), (masterpiece:1.5), (8k cg       │ │
│ │                 │ wallpaper),((high resolution)) ((pure dark        │ │
│ │                 │ skin)),(glowing hair), ((Character boundary       │ │
│ │                 │ line)) Theme: Minimalism, Movement, Atmosphere    │ │
│ │                 │ Artistic Style: ((Minimalism)), focus on          │ │
│ │                 │ simplicity and essence Painting Style: ((Digital  │ │
│ │                 │ Art)), sharp and glowing elements Special Lens:   │ │
│ │                 │ None, emphasis on abstract and flowing lines      │ │
│ │                 │ Elements: Background: ((Pure black to emphasize   │ │
│ │                 │ neon elements)) Objects: ((Flowing, glowing neon  │ │
│ │                 │ lines to represent a floating skirt)) Light &     │ │
│ │                 │ Shadow: ((Glowing neon lines casting soft glows)) │ │
│ │                 │ Depth of Field: ((Flat, to maintain focus on neon │ │
│ │                 │ lines)) Allowed Unreal Elements: Floating skirt   │ │
│ │                 │ made entirely of neon lines Occasional sparkles   │ │
│ │                 │ around the neon lines Perspective and Distance:   │ │
│ │                 │ Straight on, close enough to see detail in the    │ │
│ │                 │ neon lines but far enough to appreciate the       │ │
│ │                 │ overall shape Elements to Emphasize: ((The        │ │
│ │                 │ fluidity and glow of the neon lines)) Remember,   │ │
│ │                 │ the goal is to capture the essence of movement in │ │
│ │                 │ a void, using only neon lines to represent a      │ │
│ │                 │ skirt,Anime Lineart                               │ │
│ │ negative_prompt │ ng_deepnegative_v1_75t,(EasyNegative:1.2), (worst │ │
│ │                 │ quality, low quality:1.4), (blurry:1.4)           │ │
│ │          n_iter │ 1                                                 │ │
│ │      batch_size │ 1                                                 │ │
│ │           width │ 1280                                              │ │
│ │          height │ 720                                               │ │
│ │    sampler_name │ DPM++ 2M Karras                                   │ │
│ │       enable_hr │ False                                             │ │
│ │     hr_upscaler │ Latent                                            │ │
│ │      checkpoint │ meinamix_meinaV11.safetensors [54ef3e3610]        │ │
│ │             vae │ Automatic                                         │ │
│ │            unet │ Automatic                                         │ │
│ └─────────────────┴───────────────────────────────────────────────────┘ │
│                    ADetailer                                            │
│ ┌─────────────────────┬───────────────────────┐                         │
│ │                     │ Value                 │                         │
│ ├─────────────────────┼───────────────────────┤                         │
│ │             version │ 23.9.3                │                         │
│ │            ad_model │ person_yolov8n-seg.pt │                         │
│ │           ad_prompt │ detailed person       │                         │
│ │  ad_negative_prompt │                       │                         │
│ │ ad_controlnet_model │ None                  │                         │
│ │              is_api │ False                 │                         │
│ └─────────────────────┴───────────────────────┘                         │
│ ┌───────────────── Traceback (most recent call last) ─────────────────┐ │
│ │ E:\\novelai\\novelai-webui-aki-v2\\extensions\\adetailer\\adetailer\\trac │ │
│ │ eback.py:139 in wrapper                                             │ │
│ │                                                                     │ │
│ │   136 │   │   width = width - 4 if width > 4 else None              │ │
│ │   137 │   │   console = Console(file=string, width=width)           │ │
│ │   138 │   │   try:                                                  │ │
│ │ > 139 │   │   │   return func(*args, **kwargs)                      │ │
│ │   140 │   │   except Exception as e:                                │ │
│ │   141 │   │   │   tables = [                                        │ │
│ │   142 │   │   │   │   get_table(title, data)                        │ │
│ │                                                                     │ │
│ │ E:\\novelai\\novelai-webui-aki-v2\\extensions\\adetailer\\scripts\\!adeta │ │
│ │ iler.py:656 in postprocess_image                                    │ │
│ │                                                                     │ │
│ │   653 │   │   │   for n, args in enumerate(arg_list):               │ │
│ │   654 │   │   │   │   if args.ad_model == "None":                   │ │
│ │   655 │   │   │   │   │   continue                                  │ │
│ │ > 656 │   │   │   │   is_processed |= self._postprocess_image_inner │ │
│ │   657 │   │                                                         │ │
│ │   658 │   │   if is_processed:                                      │ │
│ │   659 │   │   │   self.save_image(                                  │ │
│ │                                                                     │ │
│ │ E:\\novelai\\novelai-webui-aki-v2\\extensions\\adetailer\\scripts\\!adeta │ │
│ │ iler.py:579 in _postprocess_image_inner                             │ │
│ │                                                                     │ │
│ │   576 │   │   │   kwargs["device"] = self.ultralytics_device        │ │
│ │   577 │   │                                                         │ │
│ │   578 │   │   with change_torch_load():                             │ │
│ │ > 579 │   │   │   pred = predictor(ad_model, pp.image, args.ad_conf │ │
│ │   580 │   │                                                         │ │
│ │   581 │   │   masks = self.pred_preprocessing(pred, args)           │ │
│ │   582                                                               │ │
│ │                                                                     │ │
│ │ E:\\novelai\\novelai-webui-aki-v2\\extensions\\adetailer\\adetailer\\ultr │ │
│ │ alytics.py:22 in ultralytics_predict                                │ │
│ │                                                                     │ │
│ │   19 │   from ultralytics import YOLO                               │ │
│ │   20 │                                                              │ │
│ │   21 │   model = YOLO(model_path)                                   │ │
│ │ > 22 │   pred = model(image, conf=confidence, device=device)        │ │
│ │   23 │                                                              │ │
│ │   24 │   bboxes = pred[0].boxes.xyxy.cpu().numpy()                  │ │
│ │   25 │   if bboxes.size == 0:                                       │ │
│ │                                                                     │ │
│ │ E:\\novelai\\novelai-webui-aki-v2\\py310\\lib\\site-packages\\ultralytics │ │
│ │ \\engine\\model.py:95 in __call__                                     │ │
│ │                                                                     │ │
│ │    92 │                                                             │ │
│ │    93 │   def __call__(self, source=None, stream=False, **kwargs):  │ │
│ │    94 │   │   """Calls the \'predict\' function with given arguments  │ │
│ │ >  95 │   │   return self.predict(source, stream, **kwargs)         │ │
│ │    96 │                                                             │ │
│ │    97 │   @staticmethod                                             │ │
│ │    98 │   def is_hub_model(model):                                  │ │
│ │                                                                     │ │
│ │ E:\\novelai\\novelai-webui-aki-v2\\py310\\lib\\site-packages\\ultralytics │ │
│ │ \\engine\\model.py:235 in predict                                     │ │
│ │                                                                     │ │
│ │   232 │   │   │   │   self.predictor.save_dir = get_save_dir(self.p │ │
│ │   233 │   │   if prompts and hasattr(self.predictor, \'set_prompts\') │ │
│ │   234 │   │   │   self.predictor.set_prompts(prompts)               │ │
│ │ > 235 │   │   return self.predictor.predict_cli(source=source) if i │ │
│ │   236 │                                                             │ │
│ │   237 │   def track(self, source=None, stream=False, persist=False, │ │
│ │   238 │   │   """                                                   │ │
│ │                                                                     │ │
│ │ E:\\novelai\\novelai-webui-aki-v2\\py310\\lib\\site-packages\\ultralytics │ │
│ │ \\engine\\predictor.py:194 in __call__                                │ │
│ │                                                                     │ │
│ │   191 │   │   if stream:                                            │ │
│ │   192 │   │   │   return self.stream_inference(source, model, *args │ │
│ │   193 │   │   else:                                                 │ │
│ │ > 194 │   │   │   return list(self.stream_inference(source, model,  │ │
│ │   195 │                                                             │ │
│ │   196 │   def predict_cli(self, source=None, model=None):           │ │
│ │   197 │   │   """Method used for CLI prediction. It uses always gen │ │
│ │                                                                     │ │
│ │ E:\\novelai\\novelai-webui-aki-v2\\py310\\lib\\site-packages\\torch\\utils │ │
│ │ \\_contextlib.py:35 in generator_context                             │ │
│ │                                                                     │ │
│ │    32 │   │   try:                                                  │ │
│ │    33 │   │   │   # Issuing `None` to a generator fires it up       │ │
│ │    34 │   │   │   with ctx_factory():                               │ │
│ │ >  35 │   │   │   │   response = gen.send(None)                     │ │
│ │    36 │   │   │                                                     │ │
│ │    37 │   │   │   while True:                                       │ │
│ │    38 │   │   │   │   try:                                          │ │
│ │                                                                     │ │
│ │ E:\\novelai\\novelai-webui-aki-v2\\py310\\lib\\site-packages\\ultralytics │ │
│ │ \\engine\\predictor.py:272 in stream_inference                        │ │
│ │                                                                     │ │
│ │   269 │   │   │   │   p = Path(p)                                   │ │
│ │   270 │   │   │   │                                                 │ │
│ │   271 │   │   │   │   if self.args.verbose or self.args.save or sel │ │
│ │ > 272 │   │   │   │   │   s += self.write_results(i, self.results,  │ │
│ │   273 │   │   │   │   if self.args.save or self.args.save_txt:      │ │
│ │   274 │   │   │   │   │   self.results[i].save_dir = self.save_dir. │ │
│ │   275 │   │   │   │   if self.args.show and self.plotted_img is not │ │
│ │                                                                     │ │
│ │ E:\\novelai\\novelai-webui-aki-v2\\py310\\lib\\site-packages\\ultralytics │ │
│ │ \\engine\\predictor.py:164 in write_results                           │ │
│ │                                                                     │ │
│ │   161 │   │   self.txt_path = str(self.save_dir / \'labels\' / p.stem │ │
│ │   162 │   │   log_string += \'%gx%g \' % im.shape[2:]  # print string │ │
│ │   163 │   │   result = results[idx]                                 │ │
│ │ > 164 │   │   log_string += result.verbose()                        │ │
│ │   165 │   │                                                         │ │
│ │   166 │   │   if self.args.save or self.args.show:  # Add bbox to i │ │
│ │   167 │   │   │   plot_args = {                                     │ │
│ │                                                                     │ │
│ │ E:\\novelai\\novelai-webui-aki-v2\\py310\\lib\\site-packages\\ultralytics │ │
│ │ \\engine\\results.py:266 in verbose                                   │ │
│ │                                                                     │ │
│ │   263 │   │   if boxes:                                             │ │
│ │   264 │   │   │   for c in boxes.cls.unique():                      │ │
│ │   265 │   │   │   │   n = (boxes.cls == c).sum()  # detections per  │ │
│ │ > 266 │   │   │   │   log_string += f"{n} {self.names[int(c)]}{\'s\'  │ │
│ │   267 │   │   return log_string                                     │ │
│ │   268 │                                                             │ │
│ │   269 │   def save_txt(self, txt_file, save_conf=False):            │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ KeyError: 14                                                            │
└─────────────────────────────────────────────────────────────────────────┘
'
提示:Python 运行时抛出了一个异常。请检查疑难解答页面。

---

List of installed extensions

image

MKC-Mankii commented 11 months ago

updated:

person_yolov8m-seg.pt run success.

person_yolov8n-seg.pt and person_yolov8s-seg.pt well get error.

Bing-su commented 11 months ago
0: 640x448 1 person, 7.8ms
Speed: 1.0ms preprocess, 7.8ms inference, 1.0ms postprocess per image at shape (1, 3, 640, 448)
100%|████████████████████████████████████████████████████████████████████████████████████| 9/9 [00:01<00:00,  6.99it/s]
100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:04<00:00,  4.04it/s]
Total progress: 100%|██████████████████████████████████████████████████████████████████| 40/40 [00:14<00:00,  4.01it/s]
0: 640x448 1 person, 8.5ms
Speed: 2.0ms preprocess, 8.5ms inference, 1.0ms postprocess per image at shape (1, 3, 640, 448)
100%|████████████████████████████████████████████████████████████████████████████████████| 9/9 [00:01<00:00,  7.12it/s]

0: 640x448 1 person, 6.5ms
Speed: 1.0ms preprocess, 6.5ms inference, 2.0ms postprocess per image at shape (1, 3, 640, 448)
100%|████████████████████████████████████████████████████████████████████████████████████| 9/9 [00:01<00:00,  6.87it/s]
Total progress: 100%|██████████████████████████████████████████████████████████████████| 40/40 [00:20<00:00,  1.99it/s]
Total progress: 100%|██████████████████████████████████████████████████████████████████| 40/40 [00:20<00:00,  4.01it/s] 

Thank you for the report. But it works fine in my environment, so I think it's a matter of the model file. Try deleting the model file and running it. (C:\Users\USERNAME\.cache\huggingface\hub\models--Bingsu--adetailer)