mrhan1993 / Fooocus-API

FastAPI powered API for Fooocus
GNU General Public License v3.0
567 stars 152 forks source link

Rendering images very slow seems to load model each time looping 30/30 #395

Open epixia opened 1 month ago

epixia commented 1 month ago

Hi there,

Amazing script thank you for this. Was glad to finally get the API to react the original Fooocus as you described it is near impossible to make Fooocus work via and API. Was really glad I got yours to work but the only issue I am having is that it take a long time to render and image since it see to load the models and it take literally 15-20 minutes to do so.

What can I do to make it faster? DO I need a 16gb GPU card?

Currently have:

NVIDIA GeForce RTX 4070 SUPER with 12 gig of ram

Loading juggernautXL_v8Rundiffusion.safetensors

Loading the model took the longest.. can we not keep this in memory and not have to keep reloading 30 times?

[2024-08-07 23:28:50] INFO [Fooocus] Encoding positive #1 ... [2024-08-07 23:28:50] INFO [Fooocus] Encoding positive #2 ... [2024-08-07 23:28:50] INFO [Fooocus] Encoding positive #3 ... [2024-08-07 23:28:50] INFO [Fooocus] Encoding positive #4 ... [2024-08-07 23:28:51] INFO [Fooocus] Encoding positive #5 ... [2024-08-07 23:28:51] INFO [Fooocus] Encoding positive #6 ... [2024-08-07 23:28:51] INFO [Fooocus] Encoding positive #7 ... [2024-08-07 23:28:51] INFO [Fooocus] Encoding positive #8 ... [2024-08-07 23:28:51] INFO [Fooocus] Encoding positive #9 ... [2024-08-07 23:28:51] INFO [Fooocus] Encoding positive #10 ... [2024-08-07 23:28:51] INFO [Fooocus] Encoding negative #1 ... [2024-08-07 23:28:51] INFO [Fooocus] Encoding negative #2 ... [2024-08-07 23:28:51] INFO [Fooocus] Encoding negative #3 ... [2024-08-07 23:28:51] INFO [Fooocus] Encoding negative #4 ... [2024-08-07 23:28:51] INFO [Fooocus] Encoding negative #5 ... [2024-08-07 23:28:51] INFO [Fooocus] Encoding negative #6 ... [2024-08-07 23:28:51] INFO [Fooocus] Encoding negative #7 ... [2024-08-07 23:28:51] INFO [Fooocus] Encoding negative #8 ... [2024-08-07 23:28:51] INFO [Fooocus] Encoding negative #9 ... [2024-08-07 23:28:51] INFO [Fooocus] Encoding negative #10 ... [2024-08-07 23:28:51] INFO [Parameters] Denoising Strength = 1.0 [2024-08-07 23:28:51] INFO [Parameters] Initial Latent shape: Image Space (896, 1152) [2024-08-07 23:28:51] INFO [Fooocus] Preparation time: 12.27 seconds [Sampler] refiner_swap_method = joint [Sampler] sigma_min = 0.0291671771556139, sigma_max = 14.614643096923828 Requested to load SDXL Loading 1 new model [2024-08-07 23:28:52] INFO [Task Queue] Already waiting for 12.6 seconds, job_id=d0bc2cf1-e4ba-42e6-b4e1-0f99fac9b15f [Fooocus Model Management] Moving model(s) has taken 1.47 seconds 100%|██████████████████████████████████████████████████████████████████████████████| 30/30 [00:09<00:00, 3.11it/s] [Fooocus Model Management] Moving model(s) has taken 1.22 seconds [2024-08-07 23:29:04] INFO [Fooocus] Generating and saving time: 12.70 seconds [Sampler] refiner_swap_method = joint [Sampler] sigma_min = 0.0291671771556139, sigma_max = 14.614643096923828 Requested to load SDXL Loading 1 new model [2024-08-07 23:29:04] INFO [Task Queue] Already waiting for 25.2 seconds, job_id=d0bc2cf1-e4ba-42e6-b4e1-0f99fac9b15f [Fooocus Model Management] Moving model(s) has taken 1.18 seconds 100%|██████████████████████████████████████████████████████████████████████████████| 30/30 [00:09<00:00, 3.32it/s] [2024-08-07 23:29:15] INFO [Fooocus] Generating and saving time: 11.05 seconds [Sampler] refiner_swap_method = joint [Sampler] sigma_min = 0.0291671771556139, sigma_max = 14.614643096923828 17%|█████████████▏ | 5/30 [00:01<00:07, 3.28it/s][2024-08-07 23:29:17] INFO [Task Queue] Already waiting for 37.9 seconds, job_id=d0bc2cf1-e4ba-42e6-b4e1-0f99fac9b15f 100%|██████████████████████████████████████████████████████████████████████████████| 30/30 [00:09<00:00, 3.28it/s] [2024-08-07 23:29:25] INFO [Fooocus] Generating and saving time: 9.55 seconds [Sampler] refiner_swap_method = joint [Sampler] sigma_min = 0.0291671771556139, sigma_max = 14.614643096923828 47%|████████████████████████████████████▍ | 14/30 [00:04<00:05, 3.01it/s][2024-08-07 23:29:30] INFO [Task Queue] Already waiting for 50.5 seconds, job_id=d0bc2cf1-e4ba-42e6-b4e1-0f99fac9b15f 100%|██████████████████████████████████████████████████████████████████████████████| 30/30 [00:09<00:00, 3.02it/s] [2024-08-07 23:29:35] INFO [Fooocus] Generating and saving time: 10.30 seconds [Sampler] refiner_swap_method = joint [Sampler] sigma_min = 0.0291671771556139, sigma_max = 14.614643096923828 77%|███████████████████████████████████████████████████████████▊ | 23/30 [00:07<00:02, 3.28it/s][2024-08-07 23:29:42] INFO [Task Queue] Already waiting for 63.1 seconds, job_id=d0bc2cf1-e4ba-42e6-b4e1-0f99fac9b15f 100%|██████████████████████████████████████████████████████████████████████████████| 30/30 [00:09<00:00, 3.28it/s] [2024-08-07 23:29:45] INFO [Fooocus] Generating and saving time: 9.61 seconds [Sampler] refiner_swap_method = joint [Sampler] sigma_min = 0.0291671771556139, sigma_max = 14.614643096923828 100%|██████████████████████████████████████████████████████████████████████████████| 30/30 [00:09<00:00, 3.02it/s] [2024-08-07 23:29:55] INFO [Task Queue] Already waiting for 75.7 seconds, job_id=d0bc2cf1-e4ba-42e6-b4e1-0f99fac9b15f [2024-08-07 23:29:55] INFO [Fooocus] Generating and saving time: 10.32 seconds [Sampler] refiner_swap_method = joint [Sampler] sigma_min = 0.0291671771556139, sigma_max = 14.614643096923828 100%|██████████████████████████████████████████████████████████████████████████████| 30/30 [00:09<00:00, 3.29it/s] [2024-08-07 23:30:05] INFO [Fooocus] Generating and saving time: 9.64 seconds [Sampler] refiner_swap_method = joint [Sampler] sigma_min = 0.0291671771556139, sigma_max = 14.614643096923828 30%|███████████████████████▋ | 9/30 [00:02<00:06, 3.31it/s][2024-08-07 23:30:07] INFO [Task Queue] Already waiting for 88.3 seconds, job_id=d0bc2cf1-e4ba-42e6-b4e1-0f99fac9b15f 100%|██████████████████████████████████████████████████████████████████████████████| 30/30 [00:09<00:00, 3.30it/s] [2024-08-07 23:30:14] INFO [Fooocus] Generating and saving time: 9.50 seconds [Sampler] refiner_swap_method = joint [Sampler] sigma_min = 0.0291671771556139, sigma_max = 14.614643096923828 60%|██████████████████████████████████████████████▊ | 18/30 [00:05<00:03, 3.26it/s][2024-08-07 23:30:20] INFO [Task Queue] Already waiting for 100.9 seconds, job_id=d0bc2cf1-e4ba-42e6-b4e1-0f99fac9b15f 100%|██████████████████████████████████████████████████████████████████████████████| 30/30 [00:09<00:00, 3.25it/s] [2024-08-07 23:30:24] INFO [Fooocus] Generating and saving time: 9.62 seconds [Sampler] refiner_swap_method = joint [Sampler] sigma_min = 0.0291671771556139, sigma_max = 14.614643096923828 93%|████████████████████████████████████████████████████████████████████████▊ | 28/30 [00:08<00:00, 3.28it/s][2024-08-07 23:30:33] INFO [Task Queue] Already waiting for 113.5 seconds, job_id=d0bc2cf1-e4ba-42e6-b4e1-0f99fac9b15f 100%|██████████████████████████████████████████████████████████████████████████████| 30/30 [00:09<00:00, 3.27it/s] [2024-08-07 23:30:33] INFO [Fooocus] Generating and saving time: 9.61 seconds [2024-08-07 23:30:45] INFO [Task Queue] Already waiting for 126.1 seconds, job_id=d0bc2cf1-e4ba-42e6-b4e1-0f99fac9b15f [2024-08-07 23:30:58] INFO [Task Queue] Already waiting for 138.7 seconds, job_id=d0bc2cf1-e4ba-42e6-b4e1-0f99fac9b15f [2024-08-07 23:31:03] INFO [Task Queue] Finish task, job_id=d0bc2cf1-e4ba-42e6-b4e1-0f99fac9b15f Requested to load SDXLClipModel Requested to load GPT2LMHeadModel Loading 2 new models