diff --git a/app/animations/little_martians.py b/app/animations/little_martians.py index cb9234d..1dc0698 100644 --- a/app/animations/little_martians.py +++ b/app/animations/little_martians.py @@ -33,6 +33,7 @@ def little_martian_poster(request: LittleMartianRequest, callback=None): lora_scale = random_interval(*data["lora_scale"]) init_image = random.choice(data["init_images"]) init_image_strength = random_interval(*data["init_image_strength"]) + seed = request.seed if request.seed else random.randint(0, 1000000) character = EdenCharacter(character_id) @@ -73,6 +74,7 @@ def little_martian_poster(request: LittleMartianRequest, callback=None): "height": height, "adopt_aspect_from_init_img": False, "n_samples": 1, + "seed": seed, } image_url, thumbnail_url = replicate.sdxl(config) diff --git a/app/creation_interfaces/kojii_chebel.py b/app/creation_interfaces/kojii_chebel.py index c0fba97..48722d7 100644 --- a/app/creation_interfaces/kojii_chebel.py +++ b/app/creation_interfaces/kojii_chebel.py @@ -30,10 +30,12 @@ class KojiiChebelRequest(BaseModel): aspect_ratio: AspectRatio abstract: float color: ColorType + seed: Optional[int] = Field(default=None, description="Random seed") def kojii_chebel(request: KojiiChebelRequest, callback=None): lora_scale = request.abstract + seed = request.seed if request.seed else random.randint(0, 1000000) if request.color == ColorType.color: color_mode = "soft pastel color tones" @@ -79,9 +81,12 @@ def kojii_chebel(request: KojiiChebelRequest, callback=None): "guidance_scale": guidance_scale, "sampler": "euler", "steps": 42, - "seed": random.randint(0, 1000000), + "seed": seed, } + print("THE CONFIG") + print(config) + image_url, thumbnail_url = replicate.sdxl( config, model_version="abraham-ai/eden-sd-pipelines-sdxl:a541eb2e611fc66ccd0faac634a7f7c0c7684977b7b54d0eb599ff352f343884", diff --git a/app/creation_interfaces/kojii_huemin.py b/app/creation_interfaces/kojii_huemin.py index 924c9eb..5de69e3 100644 --- a/app/creation_interfaces/kojii_huemin.py +++ b/app/creation_interfaces/kojii_huemin.py @@ -166,6 +166,7 @@ class KojiiHueminRequest(BaseModel): # season: Season # time_of_day: TimeOfDay # color: Color + seed: Optional[int] = Field(default=None, description="Random seed") def generate_prompt(selected_climate, selected_landform, selected_body_of_water): @@ -195,8 +196,14 @@ def kojii_huemin(request: KojiiHueminRequest, callback=None): print("HUMIN REQUEST") print(request) prompt = generate_prompt(request.climate, request.landform, request.body_of_water) + seed = request.seed if request.seed else random.randint(0, 1000000) print(prompt) - config = {"mode": "kojii/huemin", "text_input": prompt} + + config = { + "mode": "kojii/huemin", + "text_input": prompt, + "seed": seed, + } image_url, thumbnail_url = replicate.sdxl(config) diff --git a/app/creation_interfaces/kojii_makeitrad.py b/app/creation_interfaces/kojii_makeitrad.py index 36049f8..4736f38 100644 --- a/app/creation_interfaces/kojii_makeitrad.py +++ b/app/creation_interfaces/kojii_makeitrad.py @@ -54,6 +54,7 @@ class KojiiMakeitradRequest(BaseModel): clouds: bool pool: bool aspect_ratio: AspectRatio + seed: Optional[int] = Field(default=None, description="Random seed") settings = {"inside": "interior", "outside": "exterior"} @@ -95,6 +96,7 @@ def kojii_makeitrad(request: KojiiMakeitradRequest, callback=None): location = locations[request.location.value] time = times[request.time.value] color = colors[request.color.value] + seed = request.seed if request.seed else random.randint(0, 1000000) clouds = "clouds, " if request.clouds else "" pool = "(pool:1.5)," if request.pool else "" @@ -116,7 +118,7 @@ def kojii_makeitrad(request: KojiiMakeitradRequest, callback=None): "n_samples": 1, "negative_prompt": negative_prompt, "guidance_scale": 7, - "seed": random.randint(0, 1000000), + "seed": seed, } output = replicate.run_task(config, model_name="abraham-ai/eden-comfyui") diff --git a/app/creation_interfaces/kojii_untitledxyz.py b/app/creation_interfaces/kojii_untitledxyz.py index 7ff705a..3932c01 100644 --- a/app/creation_interfaces/kojii_untitledxyz.py +++ b/app/creation_interfaces/kojii_untitledxyz.py @@ -23,9 +23,11 @@ class KojiiUntitledxyzRequest(BaseModel): ge=0.0, le=1.0, ) + seed: Optional[int] = Field(default=None, description="Random seed") def kojii_untitledxyz(request: KojiiUntitledxyzRequest, callback=None): + seed = request.seed if request.seed else random.randint(0, 1000000) print("====== UNTITLED =======") print(request) @@ -38,8 +40,8 @@ def kojii_untitledxyz(request: KojiiUntitledxyzRequest, callback=None): "close up of a single column fragment, dense wires and thick electrical cables, computer circuits, corrosion, pen and ink, wires drawn with pale yellow, red, blue, green, solid white background, sharpness, noise.", ] text_inputs_to_interpolate_weights = [ + 1 - 2 * request.human_machine_nature, 2 * request.human_machine_nature, - 2 * (1 - request.human_machine_nature), ] else: @@ -48,8 +50,8 @@ def kojii_untitledxyz(request: KojiiUntitledxyzRequest, callback=None): "close up of a single column fragment, pen and ink, dense vegetation, wrapped in vines emerging from cracks, large leaves, dense lichen, diverse plants drawn with bright green, red, orange, blue, cyan, magenta, yellow, oversaturated, neons, solid white background, sharpness, noise.", ] text_inputs_to_interpolate_weights = [ + 1 - 2 * (request.human_machine_nature - 0.5), 2 * (request.human_machine_nature - 0.5), - 2 * (1 - (request.human_machine_nature - 0.5)), ] elif request.type == Type.context: @@ -60,8 +62,8 @@ def kojii_untitledxyz(request: KojiiUntitledxyzRequest, callback=None): "an isometric architectural drawing, displaying an ultra close up of a modernist building made of computer parts, dodecahedrons, textural details, emphasizing entangled wires with intense precision, the intricate web of wires are seen up close, accentuating the fusion of modern and ancient, the image depicts wires illustrated with vibrant colors, sharpness, noise.", ] text_inputs_to_interpolate_weights = [ + 1 - 2 * request.human_machine_nature, 2 * request.human_machine_nature, - 2 * (1 - request.human_machine_nature), ] else: @@ -70,8 +72,8 @@ def kojii_untitledxyz(request: KojiiUntitledxyzRequest, callback=None): "an isometric architectural drawing, displaying an ultra close up of a modern superstructure, geometric stone blocks, emphasis on dense overwhelming vines with intense precision, plants are shot up close, accentuating the fusion of nature and columns, the image depicts giant leaves illustrated with vibrant colors, solid white background, sharpness, noise.", ] text_inputs_to_interpolate_weights = [ + 1 - 2 * (request.human_machine_nature - 0.5), 2 * (request.human_machine_nature - 0.5), - 2 * (1 - (request.human_machine_nature - 0.5)), ] config = { @@ -83,6 +85,7 @@ def kojii_untitledxyz(request: KojiiUntitledxyzRequest, callback=None): ), "lora": "https://edenartlab-prod-data.s3.us-east-1.amazonaws.com/d2e6d1f8ccfca428ba42fa56a0384a4261d32bf1ee8b0dc952d99da9011daf39.tar", "lora_scale": 0.8, + "seed": seed, } print("CONFIG") diff --git a/app/creation_interfaces/kojii_violetforest.py b/app/creation_interfaces/kojii_violetforest.py index b760684..aa8cc4a 100644 --- a/app/creation_interfaces/kojii_violetforest.py +++ b/app/creation_interfaces/kojii_violetforest.py @@ -25,9 +25,12 @@ class KojiiVioletforestRequest(BaseModel): le=1.0, ) style: Style = Field(default=Style.Kawaii, description="Style") + seed: Optional[int] = Field(default=None, description="Random seed") def kojii_violetforest(request: KojiiVioletforestRequest, callback=None): + seed = request.seed if request.seed else random.randint(0, 1000000) + if request.style == Style.Kawaii: modifiers = "kawaii, kawaii, kawaii, kawaii" elif request.style == Style.Stars: @@ -55,11 +58,9 @@ def kojii_violetforest(request: KojiiVioletforestRequest, callback=None): ), "lora": "https://edenartlab-prod-data.s3.us-east-1.amazonaws.com/e3b036c0a9949de0a5433cb6c7e54b540c47535ce7ae252948177304542ca4da.tar", "lora_scale": 0.7, + "seed": seed, } - print("DO IT!") - print(config) - image_url, thumbnail_url = replicate.sdxl(config) return image_url, thumbnail_url diff --git a/app/models/little_martians.py b/app/models/little_martians.py index 49fd65b..797f915 100644 --- a/app/models/little_martians.py +++ b/app/models/little_martians.py @@ -43,3 +43,4 @@ class LittleMartianRequest(BaseModel): aspect_ratio: AspectRatio model: str = "gpt-4-1106-preview" params: dict = {} + seed: Optional[int] = Field(default=None, description="Random seed") diff --git a/tests/test_creation_interfaces.py b/tests/test_creation_interfaces.py index 5f05f76..457f97e 100644 --- a/tests/test_creation_interfaces.py +++ b/tests/test_creation_interfaces.py @@ -64,6 +64,8 @@ def test_kojii_untitledxyz(): "human_machine_nature": random.uniform(0, 1), } + request = {"type": "column", "human_machine_nature": 0.5} + response = client.post("/kojii/untitledxyz", json=request) print(response.json())