当前位置:   article > 正文

windows系统 Fooocus 图片生成模型 ,4-6GB显存即可玩,27S/p_fooocus模型下载

fooocus模型下载

安装步骤

1.下载程序代码框架,大小2GB ,下载  ​​​​​​https://github.com/lllyasviel/Fooocus/releases/download/1.0.35/Fooocus_win64_1-1-1035.7z

2.下载模型文件sd_xl_base_1.0_0.9vae.safetensors ,大小6GBhttps://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0_0.9vae.safetensorsicon-default.png?t=N7T8https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0_0.9vae.safetensors

3下载模型文件 sd_xl_refiner_1.0_0.9vae.safetensors  ,大小6GB

https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0/resolve/main/sd_xl_refiner_1.0_0.9vae.safetensorsicon-default.png?t=N7T8https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0/resolve/main/sd_xl_refiner_1.0_0.9vae.safetensors

4.把下载的模型放到model目录

sd_xl_base_1.0_0.9vae.safetensors   放到 “Fooocus\models\checkpoints\sd_xl_base_1.0_0.9 vae.saftensors”。

sd_xl_refiner_1.0_0.9vae.safetensors,放到“Fooocus\models\checkpoints\sd_xl_refiner_1.0,0.9vae.secetensors”。

5.  打开cmd 输入命令安装一个库 ,这步也许可以省去

pip install pygit2

6. 运行 代码框架 Fooocus_win64_1-1-1035 文件夹内的 run.bat 就会打开一个网页运行生成了

生成效果

以下都是AI生成的图片,用中文提示词翻译成英文复制然后生成

 

不检查更新版代码

不在检查更新 ,不在联网

run.bat 修改为
 

  1. ​​​​​​​.\python_embeded\python.exe -s Fooocus\webui_new.py
  2. pause

webui_new.py

  1. import os
  2. import sys
  3. root = os.path.dirname(os.path.abspath(__file__))
  4. sys.path.append(root)
  5. print('root=',root)
  6. os.chdir(root)
  7. import platform
  8. import fooocus_version
  9. os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1"
  10. from modules.launch_util import is_installed, run, python, \
  11. run_pip, repo_dir, git_clone, requirements_met, script_path, dir_repos
  12. from modules.model_loader import load_file_from_url
  13. from modules.path import modelfile_path, lorafile_path, vae_approx_path, fooocus_expansion_path, upscale_models_path
  14. #Comfy_path =r'\Fooocus_win64_1-1-1035\Fooocus\repositories\ComfyUI-from-StabilityAI-Official'
  15. comfyui_name = 'ComfyUI-from-StabilityAI-Official'
  16. Comfy_path = os.path.join(root, dir_repos,comfyui_name)
  17. print('Comfy_path =',Comfy_path)
  18. print('dir_repos =',dir_repos)
  19. # 添加到 Python 的模块搜索路径中
  20. sys.path.append(Comfy_path)
  21. def clear_comfy_args():
  22. argv = sys.argv
  23. sys.argv = [sys.argv[0]]
  24. from comfy.cli_args import args as comfy_args
  25. comfy_args.disable_cuda_malloc = True
  26. sys.argv = argv
  27. clear_comfy_args()
  28. import gradio as gr
  29. import random
  30. import time
  31. import shared
  32. import argparse
  33. import modules.path
  34. import fooocus_version
  35. import modules.html
  36. import modules.async_worker as worker
  37. import modules.flags as flags
  38. import modules.gradio_hijack as grh
  39. import comfy.model_management as model_management
  40. from modules.sdxl_styles import style_keys, aspect_ratios, fooocus_expansion, default_styles
  41. def generate_clicked(*args):
  42. execution_start_time = time.perf_counter()
  43. yield gr.update(visible=True, value=modules.html.make_progress_html(1, 'Initializing ...')), \
  44. gr.update(visible=True, value=None), \
  45. gr.update(visible=False)
  46. worker.buffer.append(list(args))
  47. finished = False
  48. while not finished:
  49. time.sleep(0.01)
  50. if len(worker.outputs) > 0:
  51. flag, product = worker.outputs.pop(0)
  52. if flag == 'preview':
  53. percentage, title, image = product
  54. yield gr.update(visible=True, value=modules.html.make_progress_html(percentage, title)), \
  55. gr.update(visible=True, value=image) if image is not None else gr.update(), \
  56. gr.update(visible=False)
  57. if flag == 'results':
  58. yield gr.update(visible=False), \
  59. gr.update(visible=False), \
  60. gr.update(visible=True, value=product)
  61. finished = True
  62. execution_time = time.perf_counter() - execution_start_time
  63. print(f'Total time: {execution_time:.2f} seconds')
  64. return
  65. shared.gradio_root = gr.Blocks(title='Fooocus ' + fooocus_version.version, css=modules.html.css).queue()
  66. with shared.gradio_root:
  67. with gr.Row():
  68. with gr.Column():
  69. progress_window = grh.Image(label='Preview', show_label=True, height=640, visible=False)
  70. progress_html = gr.HTML(value=modules.html.make_progress_html(32, 'Progress 32%'), visible=False, elem_id='progress-bar', elem_classes='progress-bar')
  71. gallery = gr.Gallery(label='Gallery', show_label=False, object_fit='contain', height=720, visible=True)
  72. with gr.Row(elem_classes='type_row'):
  73. with gr.Column(scale=0.85):
  74. prompt = gr.Textbox(show_label=False, placeholder="Type prompt here.", container=False, autofocus=True, elem_classes='type_row', lines=1024)
  75. with gr.Column(scale=0.15, min_width=0):
  76. run_button = gr.Button(label="Generate", value="Generate", elem_classes='type_row', visible=True)
  77. stop_button = gr.Button(label="Stop", value="Stop", elem_classes='type_row', visible=False)
  78. def stop_clicked():
  79. model_management.interrupt_current_processing()
  80. return gr.update(interactive=False)
  81. stop_button.click(stop_clicked, outputs=stop_button, queue=False)
  82. with gr.Row(elem_classes='advanced_check_row'):
  83. input_image_checkbox = gr.Checkbox(label='Input Image', value=False, container=False, elem_classes='min_check')
  84. advanced_checkbox = gr.Checkbox(label='Advanced', value=False, container=False, elem_classes='min_check')
  85. with gr.Row(visible=False) as image_input_panel:
  86. with gr.Tabs():
  87. with gr.TabItem(label='Upscale or Variation') as uov_tab:
  88. with gr.Row():
  89. with gr.Column():
  90. uov_input_image = grh.Image(label='Drag above image to here', source='upload', type='numpy')
  91. with gr.Column():
  92. uov_method = gr.Radio(label='Upscale or Variation:', choices=flags.uov_list, value=flags.disabled)
  93. gr.HTML('<a href="https://github.com/lllyasviel/Fooocus/discussions/390">\U0001F4D4 Document</a>')
  94. with gr.TabItem(label='Inpaint or Outpaint (beta)') as inpaint_tab:
  95. inpaint_input_image = grh.Image(label='Drag above image to here', source='upload', type='numpy', tool='sketch', height=500, brush_color="#FFFFFF")
  96. gr.HTML('Outpaint Expansion (<a href="https://github.com/lllyasviel/Fooocus/discussions/414">\U0001F4D4 Document</a>):')
  97. outpaint_selections = gr.CheckboxGroup(choices=['Left', 'Right', 'Top', 'Bottom'], value=[], label='Outpaint', show_label=False, container=False)
  98. gr.HTML('* \"Inpaint or Outpaint\" is powered by the sampler \"DPMPP Fooocus Seamless 2M SDE Karras Inpaint Sampler\" (beta)')
  99. input_image_checkbox.change(lambda x: gr.update(visible=x), inputs=input_image_checkbox, outputs=image_input_panel, queue=False,
  100. _js="(x) => {if(x){setTimeout(() => window.scrollTo({ top: window.scrollY + 500, behavior: 'smooth' }), 50);}else{setTimeout(() => window.scrollTo({ top: 0, behavior: 'smooth' }), 50);} return x}")
  101. current_tab = gr.Textbox(value='uov', visible=False)
  102. default_image = None
  103. def update_default_image(x):
  104. global default_image
  105. if isinstance(x, dict):
  106. default_image = x['image']
  107. else:
  108. default_image = x
  109. return
  110. def clear_default_image():
  111. global default_image
  112. default_image = None
  113. return
  114. uov_input_image.upload(update_default_image, inputs=uov_input_image, queue=False)
  115. inpaint_input_image.upload(update_default_image, inputs=inpaint_input_image, queue=False)
  116. uov_input_image.clear(clear_default_image, queue=False)
  117. inpaint_input_image.clear(clear_default_image, queue=False)
  118. uov_tab.select(lambda: ['uov', default_image], outputs=[current_tab, uov_input_image], queue=False)
  119. inpaint_tab.select(lambda: ['inpaint', default_image], outputs=[current_tab, inpaint_input_image], queue=False)
  120. with gr.Column(scale=0.5, visible=False) as right_col:
  121. with gr.Tab(label='Setting'):
  122. performance_selction = gr.Radio(label='Performance', choices=['Speed', 'Quality'], value='Speed')
  123. aspect_ratios_selction = gr.Radio(label='Aspect Ratios', choices=list(aspect_ratios.keys()),
  124. value='1152×896', info='width × height')
  125. image_number = gr.Slider(label='Image Number', minimum=1, maximum=32, step=1, value=2)
  126. negative_prompt = gr.Textbox(label='Negative Prompt', show_label=True, placeholder="Type prompt here.",
  127. info='Describing objects that you do not want to see.')
  128. seed_random = gr.Checkbox(label='Random', value=True)
  129. image_seed = gr.Number(label='Seed', value=0, precision=0, visible=False)
  130. def random_checked(r):
  131. return gr.update(visible=not r)
  132. def refresh_seed(r, s):
  133. if r:
  134. return random.randint(1, 1024*1024*1024)
  135. else:
  136. return s
  137. seed_random.change(random_checked, inputs=[seed_random], outputs=[image_seed], queue=False)
  138. with gr.Tab(label='Style'):
  139. style_selections = gr.CheckboxGroup(show_label=False, container=False,
  140. choices=[fooocus_expansion] + style_keys,
  141. value=[fooocus_expansion] + default_styles,
  142. label='Image Style')
  143. with gr.Tab(label='Advanced'):
  144. with gr.Row():
  145. base_model = gr.Dropdown(label='SDXL Base Model', choices=modules.path.model_filenames, value=modules.path.default_base_model_name, show_label=True)
  146. refiner_model = gr.Dropdown(label='SDXL Refiner', choices=['None'] + modules.path.model_filenames, value=modules.path.default_refiner_model_name, show_label=True)
  147. with gr.Accordion(label='LoRAs', open=True):
  148. lora_ctrls = []
  149. for i in range(5):
  150. with gr.Row():
  151. lora_model = gr.Dropdown(label=f'SDXL LoRA {i+1}', choices=['None'] + modules.path.lora_filenames, value=modules.path.default_lora_name if i == 0 else 'None')
  152. lora_weight = gr.Slider(label='Weight', minimum=-2, maximum=2, step=0.01, value=modules.path.default_lora_weight)
  153. lora_ctrls += [lora_model, lora_weight]
  154. with gr.Row():
  155. model_refresh = gr.Button(label='Refresh', value='\U0001f504 Refresh All Files', variant='secondary', elem_classes='refresh_button')
  156. with gr.Accordion(label='Advanced', open=False):
  157. sharpness = gr.Slider(label='Sampling Sharpness', minimum=0.0, maximum=30.0, step=0.01, value=2.0)
  158. gr.HTML('<a href="https://github.com/lllyasviel/Fooocus/discussions/117">\U0001F4D4 Document</a>')
  159. def model_refresh_clicked():
  160. modules.path.update_all_model_names()
  161. results = []
  162. results += [gr.update(choices=modules.path.model_filenames), gr.update(choices=['None'] + modules.path.model_filenames)]
  163. for i in range(5):
  164. results += [gr.update(choices=['None'] + modules.path.lora_filenames), gr.update()]
  165. return results
  166. model_refresh.click(model_refresh_clicked, [], [base_model, refiner_model] + lora_ctrls, queue=False)
  167. advanced_checkbox.change(lambda x: gr.update(visible=x), advanced_checkbox, right_col, queue=False)
  168. ctrls = [
  169. prompt, negative_prompt, style_selections,
  170. performance_selction, aspect_ratios_selction, image_number, image_seed, sharpness
  171. ]
  172. ctrls += [base_model, refiner_model] + lora_ctrls
  173. ctrls += [input_image_checkbox, current_tab]
  174. ctrls += [uov_method, uov_input_image]
  175. ctrls += [outpaint_selections, inpaint_input_image]
  176. run_button.click(lambda: (gr.update(visible=True, interactive=True), gr.update(visible=False), []), outputs=[stop_button, run_button, gallery])\
  177. .then(fn=refresh_seed, inputs=[seed_random, image_seed], outputs=image_seed)\
  178. .then(fn=generate_clicked, inputs=ctrls, outputs=[progress_html, progress_window, gallery])\
  179. .then(lambda: (gr.update(visible=True), gr.update(visible=False)), outputs=[run_button, stop_button])
  180. parser = argparse.ArgumentParser()
  181. parser.add_argument("--port", type=int, default=None, help="Set the listen port.")
  182. parser.add_argument("--share", action='store_true', default=False,help="Set whether to share on Gradio.")
  183. parser.add_argument("--listen", type=str, default=None, metavar="IP", nargs="?", const="0.0.0.0", help="Set the listen interface.")
  184. args = parser.parse_args()
  185. shared.gradio_root.launch(inbrowser=True, server_name=args.listen, server_port=args.port, share=args.share)

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号