diff --git a/fooocus_api_version.py b/fooocus_api_version.py index eb63f27..68f9d21 100644 --- a/fooocus_api_version.py +++ b/fooocus_api_version.py @@ -1 +1 @@ -version = '0.1.19' \ No newline at end of file +version = '0.1.20' \ No newline at end of file diff --git a/fooocusapi/api_utils.py b/fooocusapi/api_utils.py index fb782bc..d1cf2ad 100644 --- a/fooocusapi/api_utils.py +++ b/fooocusapi/api_utils.py @@ -9,6 +9,7 @@ from fooocusapi.models import GeneratedImageBase64, GenerationFinishReason, ImgInpaintOrOutpaintRequest, ImgPromptRequest, ImgUpscaleOrVaryRequest, Text2ImgRequest from fooocusapi.parameters import ImageGenerationParams, ImageGenerationResult import modules.flags as flags +from modules.sdxl_styles import legal_style_names def narray_to_base64img(narray: np.ndarray) -> str: @@ -44,7 +45,7 @@ def read_input_image(input_image: UploadFile) -> np.ndarray: def req_to_params(req: Text2ImgRequest) -> ImageGenerationParams: prompt = req.prompt negative_prompt = req.negative_prompt - style_selections = [s.value for s in req.style_selections] + style_selections = [s for s in req.style_selections if s in legal_style_names] performance_selection = req.performance_selection.value aspect_ratios_selection = req.aspect_ratios_selection.value image_number = req.image_number diff --git a/fooocusapi/models.py b/fooocusapi/models.py index a5d8096..0a9b97e 100644 --- a/fooocusapi/models.py +++ b/fooocusapi/models.py @@ -6,7 +6,7 @@ from enum import Enum from pydantic_core import InitErrorDetails -from fooocusapi.parameters import GenerationFinishReason +from fooocusapi.parameters import GenerationFinishReason, defualt_styles import modules.flags as flags @@ -24,196 +24,6 @@ class PerfomanceSelection(str, Enum): quality = 'Quality' -class FooocusStyle(str, Enum): - fooocus_expansion = 'Fooocus V2' - default = 'Default (Slightly Cinematic)' - fooocus_anime = 'Fooocus Anime' - fooocus_realistic = 'Fooocus Realistic' - fooocus_strong_negative = 'Fooocus Strong Negative' - sai_3d_model = 'SAI 3D Model' - sai_analog_film = 'SAI Analog Film' - sai_anime = 'SAI Anime' - sai_cinematic = 'SAI Cinematic' - sai_comic_book = 'SAI Comic Book' - sai_ccraft_clay = 'SAI Craft Clay' - sai_digital_art = 'SAI Digital Art' - sai_enhance = 'SAI Enhance' - sai_fantasy_art = 'SAI Fantasy Art' - sai_isometric = 'SAI Isometric' - sai_line_art = 'SAI Line Art' - sai_lowpoly = 'SAI Lowpoly' - sai_neonpunk = 'SAI Neonpunk' - sai_origami = 'SAI Prigami' - sai_photographic = 'SAI Photographic' - sai_pixel_art = 'SAI Pixel Art' - sai_texture = 'SAI Texture' - ads_advertising = 'Ads Advertising' - ads_automotive = 'Ads Automotive' - ads_corporate = 'Ads Corporate' - ads_fashion_editorial = 'Ads Fashion Editorial' - adsfood_photography = 'Ads Food Photography' - ads_luxury = 'Ads Luxury' - ads_real_estate = 'Ads Real Estate' - ads_retail = 'Ads Retail' - artstyle_abstract = 'Artstyle Abstract' - artstyle_abstract_expressionism = 'Artstyle Abstract Expressionism' - artstyle_art_deco = 'Artstyle Art Deco' - artstyle_art_nouveau = 'Artstyle Art Nouveau' - artstyle_constructivist = 'Artstyle Constructivist' - artstyle_cubist = 'Artstyle Cubist' - artstyle_expressionist = 'Artstyle Expressionist' - artstyle_graffiti = 'Artstyle Graffiti' - artstyle_hyperrealism = 'Artstyle Hyperrealism' - artstyle_impressionist = 'Artstyle Impressionist' - artstyle_pointillism = 'Artstyle Pointillism' - artstyle_pop_art = 'Artstyle Pop Art' - artstyle_psychedelic = 'Artstyle Psychedelic' - artstyle_renaissance = 'Artstyle Renaissance' - artstyle_steampunk = 'Artstyle Steampunk' - artstyle_surrealist = 'Artstyle Surrealist' - artstyle_typography = 'Artstyle Typography' - artstyle_watercolor = 'Artstyle Watercolor' - futuristic_biomechanical = 'Futuristic Biomechanical' - futuristic_biomechanical_cyberpunk = 'Futuristic Biomechanical Cyberpunk' - futuristic_cybernetic = 'Futuristic Cybernetic' - futuristic_cybernetic_robot = 'Futuristic Cybernetic Robot' - futuristic_cyberpunk_cityscape = 'Futuristic Cyberpunk Cityscape' - futuristic_futuristic = 'Futuristic Futuristic' - futuristic_retro_cyberpunk = 'Futuristic Retro Cyberpunk' - futuristic_retro_futurism = 'Futuristic Retro Futurism' - futuristic_sci_fi = 'Futuristic Sci Fi' - futuristic_vaporwave = 'Futuristic Vaporwave' - game_bubble_bobble = 'Game Bubble Bobble' - game_cyberpunk_game = 'Game Cyberpunk Game' - game_fighting_game = 'Game Fighting Game' - game_gta = 'Game Gta' - game_mario = 'Game Mario' - game_minecraft = 'Game Minecraft' - game_pokemon = 'Game Pokemon' - game_retro_arcade = 'Game Retro Arcade' - game_retro_game = 'Game Retro Game' - game_rpg_fantasy_game = 'Game Rpg Fantasy Game' - game_strategy_game = 'Game Strategy Game' - game_streetfighter = 'Game Streetfighter' - game_zelda = 'Game Zelda' - misc_architectural = 'Misc Architectural' - misc_disco = 'Misc Disco' - misc_dreamscape = 'Misc Dreamscape' - misc_dystopian = 'Misc Dystopian' - misc_fairy_tale = 'Misc Fairy Tale' - misc_gothic = 'Misc Gothic' - misc_grunge = 'Misc Grunge' - misc_horror = 'Misc Horror' - misc_kawaii = 'Misc Kawaii' - misc_lovecraftian = 'Misc Lovecraftian' - misc_macabre = 'Misc Macabre' - misc_manga = 'Misc Manga' - misc_metropolis = 'Misc Metropolis' - misc_minimalist = 'Misc Minimalist' - misc_monochrome = 'Misc Monochrome' - misc_nautical = 'Misc Nautical' - misc_space = 'Misc Space' - misc_stained_glass = 'Misc Stained Glass' - misc_techwear_fashion = 'Misc Techwear Fashion' - misc_tribal = 'Misc Tribal' - misc_zentangle = 'Misc Zentangle' - papercraft_collage = 'Papercraft Collage' - papercraft_flat_papercut = 'Papercraft Flat Papercut' - papercraft_kirigami = 'Papercraft Kirigami' - papercraft_paper_mache = 'Papercraft Paper Mache' - papercraft_paper_quilling = 'Papercraft Paper Quilling' - papercraft_papercut_collage = 'Papercraft Papercut Collage' - papercraft_papercut_shadow_box = 'Papercraft Papercut Shadow Box' - papercraft_stacked_papercut = 'Papercraft Stacked Papercut' - papercraft_thick_layered_papercut = 'Papercraft Thick Layered Papercut' - photo_alien = 'Photo Alien' - photo_film_noir = 'Photo Film Noir' - photo_hdr = 'Photo Hdr' - photo_long_exposure = 'Photo Long Exposure' - photo_neon_noir = 'Photo Neon Noir' - photo_silhouette = 'Photo Silhouette' - photo_tilt_shift = 'Photo Tilt Shift' - cinematic_diva = 'Cinematic Diva' - abstract_expressionism = 'Abstract Expressionism' - academia = 'Academia' - action_figure = 'Action Figure' - adorable_3d_character = 'Adorable 3D Character' - adorable_kawaii = 'Adorable Kawaii' - art_deco = 'Art Deco' - art_nouveau = 'Art Nouveau' - astral_aura = 'Astral Aura' - avant_garde = 'Avant Garde' - baroque = 'Baroque' - bauhaus_style_poster = 'Bauhaus Style Poster' - blueprint_schematic_drawing = 'Blueprint Schematic Drawing' - caricature = 'Caricature' - cel_shaded_art = 'Cel Shaded Art' - character_design_sheet = 'Character Design Sheet' - classicism_art = 'Classicism Art' - color_field_painting = 'Color Field Painting' - colored_pencil_art = 'Colored Pencil Art' - conceptual_art = 'Conceptual Art' - constructivism = 'Constructivism' - cubism = 'Cubism' - dadaism = 'Dadaism' - dark_fantasy = 'Dark Fantasy' - dark_moody_atmosphere = 'Dark Moody Atmosphere' - dmt_art_style = 'DMT Art Style' - doodle_art = 'Doodle Art' - double_exposure = 'Double Exposure' - dripping_paint_splatter_art = 'Dripping Paint Splatter Art' - expressionism = 'Expressionism' - faded_polaroid_Photo = 'Faded Polaroid Photo' - fauvism = 'Fauvism' - flat_2d_art = 'Flat 2D Art' - fortnite_art_style = 'Fortnite Art Style' - futurism = 'Futurism' - glitchcore = 'Glitchcore' - glo_fi = 'Glo Fi' - googie_art_style = 'Googie Art Style' - graffiti_art = 'Graffiti Art' - harlem_renaissance_art = 'Harlem Renaissance Art' - high_fashion = 'High Fashion' - idyllic = 'Idyllic' - impressionism = 'Impressionism' - infographic_drawing = 'Infographic Drawing' - ink_dripping_drawing = 'Ink Dripping Drawing' - japanese_ink_drawing = 'Japanese Ink Drawing' - knolling_photography = 'Knolling Photography' - light_cheery_atmosphere = 'Light Cheery Atmosphere' - logo_design = 'Logo Design' - luxurious_elegance = 'Luxurious Elegance' - macro_photography = 'Macro Photography' - mandola_art = 'Mandola Art' - marker_drawing = 'Marker Drawing' - medievalism = 'Medievalism' - minimalism = 'Minimalism' - neo_baroque = 'Neo Baroque' - neo_byzantine = 'Neo Byzantine' - neo_futurism = 'Neo Futurism' - neo_impressionism = 'Neo Impressionism' - neo_rococo = 'Neo Rococo' - neoclassicism = 'Neoclassicism' - op_art = 'Op Art' - ornate_and_intricate = 'Ornate And Intricate' - pencil_sketch_drawing = 'Pencil Sketch Drawing' - pop_art_2 = 'Pop Art 2' - rococo = 'Rococo' - silhouette_art = 'Silhouette Art' - simple_vector_art = 'Simple Vector Art' - sketchup = 'Sketchup' - steampunk_2 = 'Steampunk 2' - surrealism = 'Surrealism' - suprematism = 'Suprematism' - terragen = 'Terragen' - tranquil_relaxing_atmosphere = 'Tranquil Relaxing Atmosphere' - sticker_designs = 'Sticker Designs' - vibrant_rim_light = 'Vibrant Rim Light' - volumetric_lighting = 'Volumetric Lighting' - watercolor_2 = 'Watercolor 2' - whimsical_and_playful = 'Whimsical And Playful' - - class AspectRatio(str, Enum): a_0_5 = '704×1408' a_0_52 = '704×1344' @@ -275,8 +85,7 @@ class ImagePrompt(BaseModel): class Text2ImgRequest(BaseModel): prompt: str = '' negative_prompt: str = '' - style_selections: List[FooocusStyle] = [ - FooocusStyle.fooocus_expansion, FooocusStyle.default] + style_selections: List[str] = defualt_styles performance_selection: PerfomanceSelection = PerfomanceSelection.speed aspect_ratios_selection: AspectRatio = AspectRatio.a_1_29 image_number: int = Field( @@ -299,8 +108,7 @@ def as_form(cls, input_image: UploadFile = Form(description="Init image for upsa uov_method: UpscaleOrVaryMethod = Form(), prompt: str = Form(''), negative_prompt: str = Form(''), - style_selections: List[str] = Form([ - FooocusStyle.fooocus_expansion, FooocusStyle.default], description="Fooocus style selections, seperated by comma"), + style_selections: List[str] = Form(defualt_styles, description="Fooocus style selections, seperated by comma"), performance_selection: PerfomanceSelection = Form( PerfomanceSelection.speed), aspect_ratios_selection: AspectRatio = Form( @@ -326,17 +134,11 @@ def as_form(cls, input_image: UploadFile = Form(description="Init image for upsa l5: str | None = Form(None), w5: float = Form(default=0.5, ge=-2, le=2), ): - style_selection_arr: List[FooocusStyle] = [] + style_selection_arr: List[str] = [] for part in style_selections: if len(part) > 0: for s in part.split(','): - try: - style = FooocusStyle(s) - style_selection_arr.append(style) - except ValueError as ve: - err = InitErrorDetails(type='enum', loc=['style_selections'], input=style_selections, ctx={ - 'expected': 'Valid fooocus styles seperated by comma'}) - raise RequestValidationError(errors=[err]) + style_selection_arr.append(s) loras: List[Lora] = [] lora_config = [(l1, w1), (l2, w2), (l3, w3), (l4, w4), (l5, w5)] @@ -365,8 +167,7 @@ def as_form(cls, input_image: UploadFile = Form(description="Init image for inpa [], description="Outpaint expansion selections, literal 'Left', 'Right', 'Top', 'Bottom' seperated by comma"), prompt: str = Form(''), negative_prompt: str = Form(''), - style_selections: List[str] = Form([ - FooocusStyle.fooocus_expansion, FooocusStyle.default], description="Fooocus style selections, seperated by comma"), + style_selections: List[str] = Form(defualt_styles, description="Fooocus style selections, seperated by comma"), performance_selection: PerfomanceSelection = Form( PerfomanceSelection.speed), aspect_ratios_selection: AspectRatio = Form( @@ -408,17 +209,11 @@ def as_form(cls, input_image: UploadFile = Form(description="Init image for inpa 'expected': "Literal 'Left', 'Right', 'Top', 'Bottom' seperated by comma"}) raise RequestValidationError(errors=[err]) - style_selection_arr: List[FooocusStyle] = [] + style_selection_arr: List[str] = [] for part in style_selections: if len(part) > 0: for s in part.split(','): - try: - expansion = FooocusStyle(s) - style_selection_arr.append(expansion) - except ValueError as ve: - err = InitErrorDetails(type='enum', loc=['style_selections'], input=style_selections, ctx={ - 'expected': 'Valid fooocus styles seperated by comma'}) - raise RequestValidationError(errors=[err]) + style_selection_arr.append(s) loras: List[Lora] = [] lora_config = [(l1, w1), (l2, w2), (l3, w3), (l4, w4), (l5, w5)] @@ -471,8 +266,7 @@ def as_form(cls, cn_img1: UploadFile = Form(File(None), description="Input image default=ControlNetType.cn_ip, description="ControlNet type for image prompt"), prompt: str = Form(''), negative_prompt: str = Form(''), - style_selections: List[str] = Form([ - FooocusStyle.fooocus_expansion, FooocusStyle.default], description="Fooocus style selections, seperated by comma"), + style_selections: List[str] = Form(defualt_styles, description="Fooocus style selections, seperated by comma"), performance_selection: PerfomanceSelection = Form( PerfomanceSelection.speed), aspect_ratios_selection: AspectRatio = Form( @@ -519,17 +313,11 @@ def as_form(cls, cn_img1: UploadFile = Form(File(None), description="Input image image_prompts.append(ImagePrompt( cn_img=cn_img, cn_stop=cn_stop, cn_weight=cn_weight, cn_type=cn_type)) - style_selection_arr: List[FooocusStyle] = [] + style_selection_arr: List[str] = [] for part in style_selections: if len(part) > 0: for s in part.split(','): - try: - expansion = FooocusStyle(s) - style_selection_arr.append(expansion) - except ValueError as ve: - err = InitErrorDetails(type='enum', loc=['style_selections'], input=style_selections, ctx={ - 'expected': 'Valid fooocus styles seperated by comma'}) - raise RequestValidationError(errors=[err]) + style_selection_arr.append(s) loras: List[Lora] = [] lora_config = [(l1, w1), (l2, w2), (l3, w3), (l4, w4), (l5, w5)] diff --git a/fooocusapi/parameters.py b/fooocusapi/parameters.py index 57aed13..b8b0f2f 100644 --- a/fooocusapi/parameters.py +++ b/fooocusapi/parameters.py @@ -6,12 +6,15 @@ inpaint_model_version = 'v1' +defualt_styles = ['Fooocus V2', 'Default (Slightly Cinematic)'] + + fooocus_styles = [ 'Fooocus V2', 'Default (Slightly Cinematic)', - 'Fooocus Anime', - 'Fooocus Realistic', - 'Fooocus Strong Negative', + 'Fooocus Masterpiece', + 'Fooocus Photograph', + 'Fooocus Negative', 'SAI 3D Model', 'SAI Analog Film', 'SAI Anime', @@ -25,15 +28,38 @@ 'SAI Line Art', 'SAI Lowpoly', 'SAI Neonpunk', - 'SAI Prigami', + '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', @@ -110,7 +136,9 @@ 'Papercraft Thick Layered Papercut', 'Photo Alien', 'Photo Film Noir', + 'Photo Glamour', 'Photo Hdr', + 'Photo Iphone Photographic', 'Photo Long Exposure', 'Photo Neon Noir', 'Photo Silhouette', @@ -140,14 +168,14 @@ 'Dadaism', 'Dark Fantasy', 'Dark Moody Atmosphere', - 'DMT Art Style', + 'Dmt Art Style', 'Doodle Art', 'Double Exposure', 'Dripping Paint Splatter Art', 'Expressionism', 'Faded Polaroid Photo', 'Fauvism', - 'Flat 2D Art', + 'Flat 2d Art', 'Fortnite Art Style', 'Futurism', 'Glitchcore', @@ -193,7 +221,7 @@ 'Vibrant Rim Light', 'Volumetric Lighting', 'Watercolor 2', - 'Whimsical And Playful', + 'Whimsical And Playful' ]