()
| 166 | |
| 167 | |
| 168 | def worker(): |
| 169 | global async_tasks |
| 170 | |
| 171 | import os |
| 172 | import traceback |
| 173 | import math |
| 174 | import numpy as np |
| 175 | import torch |
| 176 | import time |
| 177 | import shared |
| 178 | import random |
| 179 | import copy |
| 180 | import cv2 |
| 181 | import modules.default_pipeline as pipeline |
| 182 | import modules.core as core |
| 183 | import modules.flags as flags |
| 184 | import modules.patch |
| 185 | import ldm_patched.modules.model_management |
| 186 | import extras.preprocessors as preprocessors |
| 187 | import modules.inpaint_worker as inpaint_worker |
| 188 | import modules.constants as constants |
| 189 | import extras.ip_adapter as ip_adapter |
| 190 | import extras.face_crop |
| 191 | import fooocus_version |
| 192 | |
| 193 | from extras.censor import default_censor |
| 194 | from modules.sdxl_styles import apply_style, get_random_style, fooocus_expansion, apply_arrays, random_style_name |
| 195 | from modules.private_logger import log |
| 196 | from extras.expansion import safe_str |
| 197 | from modules.util import (remove_empty_str, HWC3, resize_image, get_image_shape_ceil, set_image_shape_ceil, |
| 198 | get_shape_ceil, resample_image, erode_or_dilate, parse_lora_references_from_prompt, |
| 199 | apply_wildcards) |
| 200 | from modules.upscaler import perform_upscale |
| 201 | from modules.flags import Performance |
| 202 | from modules.meta_parser import get_metadata_parser |
| 203 | |
| 204 | pid = os.getpid() |
| 205 | print(f'Started worker with PID {pid}') |
| 206 | |
| 207 | try: |
| 208 | async_gradio_app = shared.gradio_root |
| 209 | flag = f'''App started successful. Use the app with {str(async_gradio_app.local_url)} or {str(async_gradio_app.server_name)}:{str(async_gradio_app.server_port)}''' |
| 210 | if async_gradio_app.share: |
| 211 | flag += f''' or {async_gradio_app.share_url}''' |
| 212 | print(flag) |
| 213 | except Exception as e: |
| 214 | print(e) |
| 215 | |
| 216 | def progressbar(async_task, number, text): |
| 217 | print(f'[Fooocus] {text}') |
| 218 | async_task.yields.append(['preview', (number, text, None)]) |
| 219 | |
| 220 | def yield_result(async_task, imgs, progressbar_index, black_out_nsfw, censor=True, do_not_show_finished_images=False): |
| 221 | if not isinstance(imgs, list): |
| 222 | imgs = [imgs] |
| 223 | |
| 224 | if censor and (modules.config.default_black_out_nsfw or black_out_nsfw): |
| 225 | progressbar(async_task, progressbar_index, 'Checking for NSFW content ...') |
nothing calls this directly
no test coverage detected