Skip to content

Commit

Permalink
Merge for Fooocus v2.1.741
Browse files Browse the repository at this point in the history
  • Loading branch information
konieshadow committed Oct 26, 2023
1 parent 441cb96 commit ba57955
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

FastAPI powered API for [Fooocus](https://github.com/lllyasviel/Fooocus)

Currently loaded Fooocus version: 2.1.728
Currently loaded Fooocus version: 2.1.741

### Run with Replicate
Now you can use Fooocus-API by Replicate, the model is in [konieshadow/fooocus-api](https://replicate.com/konieshadow/fooocus-api).
Expand Down
2 changes: 1 addition & 1 deletion fooocus_api_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = '0.3.0'
version = '0.3.1'
2 changes: 1 addition & 1 deletion fooocusapi/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
inpaint_model_version = 'v1'


defualt_styles = ['Fooocus V2', 'Default (Slightly Cinematic)']
defualt_styles = ['Fooocus V2', 'Fooocus Enhance', 'Fooocus Sharp']


aspect_ratios = [
Expand Down
4 changes: 2 additions & 2 deletions fooocusapi/repositories_versions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os

fooocus_version = '2.1.728'
fooocus_version = '2.1.741'
fooocus_commit_hash = os.environ.get(
'FOOOCUS_COMMIT_HASH', "4cf0c778da33fb91d591771bbe90123a45c54d3c")
'FOOOCUS_COMMIT_HASH', "01b1e98d378e7ceed08171c0397b2e5d89ea0047")
36 changes: 24 additions & 12 deletions fooocusapi/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,31 @@ def process_generate(queue_task: QueueTask, params: ImageGenerationParams) -> Li
import modules.core as core
import modules.inpaint_worker as inpaint_worker
import modules.path as path
import fcbh.model_management as model_management
import modules.advanced_parameters as advanced_parameters
import modules.constants as constants
import fcbh.model_management as model_management
import fooocus_extras.preprocessors as preprocessors
import fooocus_extras.ip_adapter as ip_adapter
from modules.util import join_prompts, remove_empty_str, resize_image, HWC3, set_image_shape_ceil, get_image_shape_ceil, get_shape_ceil
from modules.private_logger import log
from modules.upscaler import perform_upscale
from modules.expansion import safe_str
from modules.sdxl_styles import apply_style, fooocus_expansion, aspect_ratios, apply_wildcards
from modules.sdxl_styles import apply_style, fooocus_expansion, apply_wildcards

outputs = []

def refresh_seed(r, seed_string):
if r:
return random.randint(constants.MIN_SEED, constants.MAX_SEED)
else:
try:
seed_value = int(seed_string)
if constants.MIN_SEED <= seed_value <= constants.MAX_SEED:
return seed_value
except ValueError:
pass
return random.randint(constants.MIN_SEED, constants.MAX_SEED)

def progressbar(number, text):
print(f'[Fooocus] {text}')
outputs.append(['preview', (number, text, None)])
Expand Down Expand Up @@ -93,6 +106,8 @@ def make_results_from_outputs():
outpaint_selections = params.outpaint_selections
inpaint_input_image = params.inpaint_input_image

image_seed = refresh_seed(image_seed is None, image_seed)

cn_tasks = {flags.cn_ip: [], flags.cn_canny: [], flags.cn_cpds: []}
for img_prompt in params.image_prompts:
cn_img, cn_stop, cn_weight, cn_type = img_prompt
Expand Down Expand Up @@ -163,7 +178,10 @@ def build_advanced_parameters():
denoising_strength = 1.0
tiled = False
inpaint_worker.current_task = None
width, height = aspect_ratios[aspect_ratios_selection]

width, height = aspect_ratios_selection.split('×')
width, height = int(width), int(height)

skip_prompt_processing = False
refiner_swap_method = advanced_parameters.refiner_swap_method

Expand All @@ -174,13 +192,8 @@ def build_advanced_parameters():
controlnet_cpds_path = None
clip_vision_path, ip_negative_path, ip_adapter_path = None, None, None

seed = image_seed
max_seed = int(1024 * 1024 * 1024)
if not isinstance(seed, int):
seed = random.randint(1, max_seed)
if seed < 0:
seed = - seed
seed = seed % max_seed
seed = int(image_seed)
print(f'[Parameters] Seed = {seed}')

if performance_selection == 'Speed':
steps = 30
Expand Down Expand Up @@ -226,7 +239,6 @@ def build_advanced_parameters():
loras += [(inpaint_patch_model_path, 1.0)]
print(f'[Inpaint] Current inpaint model is {inpaint_patch_model_path}')
goals.append('inpaint')
sampler_name = 'dpmpp_2m_sde_gpu' # only support the patched dpmpp_2m_sde_gpu
if current_tab == 'ip' or \
advanced_parameters.mixing_image_prompt_and_inpaint or \
advanced_parameters.mixing_image_prompt_and_vary_upscale:
Expand Down Expand Up @@ -278,7 +290,7 @@ def build_advanced_parameters():
progressbar(3, 'Processing prompts ...')
tasks = []
for i in range(image_number):
task_seed = seed + i
task_seed = (seed + i) % (constants.MAX_SEED + 1) # randint is inclusive, % is not
task_rng = random.Random(task_seed) # may bind to inpaint noise in the future

task_prompt = apply_wildcards(prompt, task_rng)
Expand Down

0 comments on commit ba57955

Please sign in to comment.