https://github.com/mrhan1993/Fooocus-API
API文档:
之前的镜像打包介绍:https://www.dong-blog.fun/post/548
直接跑起来服务:
bashdocker run --gpus device=0 -p 7881:7860 -d kevinchina/deeplearning:fooocusapi-office-v3
一个完整的请求:
pythonimport json
import requests
class Config:
"""
Configuration for local Fooocus API.
"""
fooocus_host = 'http://101.136.22.140:7881'
text2image = '/v1/generation/text-to-image'
def text2image(params: dict) -> dict:
"""
Text to image function
Args:
params (dict): Dictionary with prompt and other parameters
Returns:
dict: Response from API
"""
data = json.dumps(params)
response = requests.post(
url=f"{Config.fooocus_host}{Config.text2image}",
data=data,
headers={"Content-Type": "application/json"},
timeout=300
)
return response.json()
# Corrected parameters
t2i_params = {
"prompt": "a beautiful landscape with mountains and rivers", # 描述词
"negative_prompt": "", # 反向描述词
"style_selections": ["Fooocus V2", "Fooocus Enhance"], # 风格列表 (可以通过样式接口获取)
"performance_selection": "Speed", # 性能选择: Speed, Quality, Extreme Speed, Lightning
"aspect_ratios_selection": "1152*896", # 分辨率选择
"image_number": 1, # 生成图片数量
"image_seed": -1, # 图片种子,整数 -1 表示随机生成
"sharpness": 3.0, # 锐度,范围 0-30
# "sharpness": 10.0, # 锐度,范围 0-30
"guidance_scale": 5.0, # 引导比例,范围 1-30
# "guidance_scale": 13.0, # 引导比例,范围 1-30
"base_model_name": "juggernautXL_v8Rundiffusion.safetensors", # 基础模型名称
"refiner_model_name": "None", # 优化模型名称,字符串形式 "None"
"refiner_switch": 0.5, # 优化模型切换时机,范围 0-1
"loras": [
{
"enabled": True,
"model_name": "sd_xl_offset_example-lora_1.0.safetensors", # 使用的 Lora 模型名称
"weight": 0.1 # Lora 模型的权重,可以根据需要调整
}
], # lora 模型列表,包含已启用的模型
"advanced_params": {}, # 高级参数,可以为空
"save_meta": True, # 是否保存元数据
"meta_scheme": "fooocus", # 元数据方案
"save_extension": "png", # 保存文件扩展名
"save_name": "", # 保存文件名,可以为空字符串
"read_wildcards_in_order": False, # 是否按顺序读取通配符
"require_base64": False, # 是否返回 base64 编码
"async_process": False, # 是否异步处理
}
# Make the request
t2i_result = text2image(params=t2i_params)
# Print the result in a formatted JSON style
print(json.dumps(t2i_result, indent=2))
风格选择:
bash[
"Fooocus V2",
"Random Style",
"Fooocus Enhance",
"Fooocus Semi Realistic",
"Fooocus Sharp",
"Fooocus Masterpiece",
"Fooocus Photograph",
"Fooocus Negative",
"Fooocus Cinematic",
"SAI 3D Model",
"SAI Analog Film",
"SAI Anime",
"SAI Cinematic",
"SAI Comic Book",
"SAI Craft Clay",
"SAI Digital Art",
"SAI Enhance",
"SAI Fantasy Art",
"SAI Isometric",
"SAI Line Art",
"SAI Lowpoly",
"SAI Neonpunk",
"SAI Origami",
"SAI Photographic",
"SAI Pixel Art",
"SAI Texture",
"MRE Cinematic Dynamic",
"MRE Spontaneous Picture",
"MRE Artistic Vision",
"MRE Dark Dream",
"MRE Gloomy Art",
"MRE Bad Dream",
"MRE Underground",
"MRE Surreal Painting",
"MRE Dynamic Illustration",
"MRE Undead Art",
"MRE Elemental Art",
"MRE Space Art",
"MRE Ancient Illustration",
"MRE Brave Art",
"MRE Heroic Fantasy",
"MRE Dark Cyberpunk",
"MRE Lyrical Geometry",
"MRE Sumi E Symbolic",
"MRE Sumi E Detailed",
"MRE Manga",
"MRE Anime",
"MRE Comic",
"Ads Advertising",
"Ads Automotive",
"Ads Corporate",
"Ads Fashion Editorial",
"Ads Food Photography",
"Ads Gourmet Food Photography",
"Ads Luxury",
"Ads Real Estate",
"Ads Retail",
"Artstyle Abstract",
"Artstyle Abstract Expressionism",
"Artstyle Art Deco",
"Artstyle Art Nouveau",
"Artstyle Constructivist",
"Artstyle Cubist",
"Artstyle Expressionist",
"Artstyle Graffiti",
"Artstyle Hyperrealism",
"Artstyle Impressionist",
"Artstyle Pointillism",
"Artstyle Pop Art",
"Artstyle Psychedelic",
"Artstyle Renaissance",
"Artstyle Steampunk",
"Artstyle Surrealist",
"Artstyle Typography",
"Artstyle Watercolor",
"Futuristic Biomechanical",
"Futuristic Biomechanical Cyberpunk",
"Futuristic Cybernetic",
"Futuristic Cybernetic Robot",
"Futuristic Cyberpunk Cityscape",
"Futuristic Futuristic",
"Futuristic Retro Cyberpunk",
"Futuristic Retro Futurism",
"Futuristic Sci Fi",
"Futuristic Vaporwave",
"Game Bubble Bobble",
"Game Cyberpunk Game",
"Game Fighting Game",
"Game Gta",
"Game Mario",
"Game Minecraft",
"Game Pokemon",
"Game Retro Arcade",
"Game Retro Game",
"Game Rpg Fantasy Game",
"Game Strategy Game",
"Game Streetfighter",
"Game Zelda",
"Misc Architectural",
"Misc Disco",
"Misc Dreamscape",
"Misc Dystopian",
"Misc Fairy Tale",
"Misc Gothic",
"Misc Grunge",
"Misc Horror",
"Misc Kawaii",
"Misc Lovecraftian",
"Misc Macabre",
"Misc Manga",
"Misc Metropolis",
"Misc Minimalist",
"Misc Monochrome",
"Misc Nautical",
"Misc Space",
"Misc Stained Glass",
"Misc Techwear Fashion",
"Misc Tribal",
"Misc Zentangle",
"Papercraft Collage",
"Papercraft Flat Papercut",
"Papercraft Kirigami",
"Papercraft Paper Mache",
"Papercraft Paper Quilling",
"Papercraft Papercut Collage",
"Papercraft Papercut Shadow Box",
"Papercraft Stacked Papercut",
"Papercraft Thick Layered Papercut",
"Photo Alien",
"Photo Film Noir",
"Photo Glamour",
"Photo Hdr",
"Photo Iphone Photographic",
"Photo Long Exposure",
"Photo Neon Noir",
"Photo Silhouette",
"Photo Tilt Shift",
"Cinematic Diva",
"Abstract Expressionism",
"Academia",
"Action Figure",
"Adorable 3D Character",
"Adorable Kawaii",
"Art Deco",
"Art Nouveau",
"Astral Aura",
"Avant Garde",
"Baroque",
"Bauhaus Style Poster",
"Blueprint Schematic Drawing",
"Caricature",
"Cel Shaded Art",
"Character Design Sheet",
"Classicism Art",
"Color Field Painting",
"Colored Pencil Art",
"Conceptual Art",
"Constructivism",
"Cubism",
"Dadaism",
"Dark Fantasy",
"Dark Moody Atmosphere",
"Dmt Art Style",
"Doodle Art",
"Double Exposure",
"Dripping Paint Splatter Art",
"Expressionism",
"Faded Polaroid Photo",
"Fauvism",
"Flat 2d Art",
"Fortnite Art Style",
"Futurism",
"Glitchcore",
"Glo Fi",
"Googie Art Style",
"Graffiti Art",
"Harlem Renaissance Art",
"High Fashion",
"Idyllic",
"Impressionism",
"Infographic Drawing",
"Ink Dripping Drawing",
"Japanese Ink Drawing",
"Knolling Photography",
"Light Cheery Atmosphere",
"Logo Design",
"Luxurious Elegance",
"Macro Photography",
"Mandola Art",
"Marker Drawing",
"Medievalism",
"Minimalism",
"Neo Baroque",
"Neo Byzantine",
"Neo Futurism",
"Neo Impressionism",
"Neo Rococo",
"Neoclassicism",
"Op Art",
"Ornate And Intricate",
"Pencil Sketch Drawing",
"Pop Art 2",
"Rococo",
"Silhouette Art",
"Simple Vector Art",
"Sketchup",
"Steampunk 2",
"Surrealism",
"Suprematism",
"Terragen",
"Tranquil Relaxing Atmosphere",
"Sticker Designs",
"Vibrant Rim Light",
"Volumetric Lighting",
"Watercolor 2",
"Whimsical And Playful",
"Mk Chromolithography",
"Mk Cross Processing Print",
"Mk Dufaycolor Photograph",
"Mk Herbarium",
"Mk Punk Collage",
"Mk Mosaic",
"Mk Van Gogh",
"Mk Coloring Book",
"Mk Singer Sargent",
"Mk Pollock",
"Mk Basquiat",
"Mk Andy Warhol",
"Mk Halftone Print",
"Mk Gond Painting",
"Mk Albumen Print",
"Mk Aquatint Print",
"Mk Anthotype Print",
"Mk Inuit Carving",
"Mk Bromoil Print",
"Mk Calotype Print",
"Mk Color Sketchnote",
"Mk Cibulak Porcelain",
"Mk Alcohol Ink Art",
"Mk One Line Art",
"Mk Blacklight Paint",
"Mk Carnival Glass",
"Mk Cyanotype Print",
"Mk Cross Stitching",
"Mk Encaustic Paint",
"Mk Embroidery",
"Mk Gyotaku",
"Mk Luminogram",
"Mk Lite Brite Art",
"Mk Mokume Gane",
"Pebble Art",
"Mk Palekh",
"Mk Suminagashi",
"Mk Scrimshaw",
"Mk Shibori",
"Mk Vitreous Enamel",
"Mk Ukiyo E",
"Mk Vintage Airline Poster",
"Mk Vintage Travel Poster",
"Mk Bauhaus Style",
"Mk Afrofuturism",
"Mk Atompunk",
"Mk Constructivism",
"Mk Chicano Art",
"Mk De Stijl",
"Mk Dayak Art",
"Mk Fayum Portrait",
"Mk Illuminated Manuscript",
"Mk Kalighat Painting",
"Mk Madhubani Painting",
"Mk Pictorialism",
"Mk Pichwai Painting",
"Mk Patachitra Painting",
"Mk Samoan Art Inspired",
"Mk Tlingit Art",
"Mk Adnate Style",
"Mk Ron English Style",
"Mk Shepard Fairey Style"
]
base model路径例子:
/app/repositories/Fooocus/models/checkpoints/juggernautXL_v8Rundiffusion.safetensors
lora model路径例子:
/app/repositories/Fooocus/models/loras/sd_xl_offset_example-lora_1.0.safetensors
civita模型下载:https://civitai.com/models/133005/juggernaut-xl?modelVersionId=782002
这样挂外部宿主机模型进去,宿主机这样:
直接跑起来服务:
bashdocker run --rm --gpus device=0 -p 7881:7860 -d -v /root/xiedong/sd_models/checkpoints:/app/repositories/Fooocus/models/checkpoints -v /root/xiedong/sd_models/loras:/app/repositories/Fooocus/models/loras kevinchina/deeplearning:fooocusapi-office-v3
本文作者:Dong
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC。本作品采用《知识共享署名-非商业性使用 4.0 国际许可协议》进行许可。您可以在非商业用途下自由转载和修改,但必须注明出处并提供原作者链接。 许可协议。转载请注明出处!