Skip to content

Commit

Permalink
Merge pull request #48 from edenartlab/stage
Browse files Browse the repository at this point in the history
Stage
  • Loading branch information
genekogan authored Apr 11, 2024
2 parents 9e999e5 + f97cbe1 commit e77e29e
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 21 deletions.
18 changes: 7 additions & 11 deletions logos/creation_interfaces/kojii_chebel.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,20 @@ class KojiiChebelRequest(BaseModel):


def kojii_chebel(request: KojiiChebelRequest, callback=None):
lora_scale = request.abstract
lora_scale = 0.44 + 0.52 * request.abstract
seed = request.seed if request.seed else random.randint(0, 1000000)

if request.color == ColorType.color:
color_mode = "soft pastel color palette"
negative_prompt = "saturated"
else:
color_mode = "black and white"
negative_prompt = (
"color, colors, yellow, orange, red, pink, purple, blue, green"
)
negative_prompt = "yellow, blue"

if request.number == Number.one:
prompt = f"in the style of <concept>, oil paint, {color_mode}, woman, dance, brush strokes"
prompt = f"oil painting in the style of <concept>, oil paint, {color_mode}, woman, dance, expressive brushstrokes"
elif request.number == Number.many:
prompt = f"in the style of <concept>, oil paint, {color_mode}, women, dance, brush strokes"
prompt = f"oil painting in the style of <concept>, oil paint, {color_mode}, many women, dance, expressive brushstrokes"

if request.aspect_ratio == AspectRatio.portrait:
w, h = 1024, 1536
Expand All @@ -62,16 +60,14 @@ def kojii_chebel(request: KojiiChebelRequest, callback=None):

control_image_strength = 0.84
guidance_scale = 8
negative_prompt += (
", ugly, watermark, text, tiling, blurred, grainy, signature, cut off, draft"
)
negative_prompt += ", watermark, text, tiling, out of frame, blurry, blurred, grainy, signature, cut off, draft"

config = {
"mode": "controlnet",
"controlnet_type": "canny-edge",
"text_input": prompt,
"uc_text": negative_prompt,
"lora": "https://edenartlab-prod-data.s3.us-east-1.amazonaws.com/431ff8fb8edf1fcf8d1bc1ddcc2662479ced491c6b98784cdb4b0aa6d70cd09c.tar",
"lora": "https://edenartlab-prod-data.s3.us-east-1.amazonaws.com/d93ba7c3b642816c3ab2f5c1755539e222e902d52c6a63064feb57a6cd2c5ba7.tar",
"lora_scale": lora_scale,
"control_image": f"https://edenartlab-prod-data.s3.us-east-1.amazonaws.com/{control_image}",
"control_image_strength": control_image_strength,
Expand All @@ -80,7 +76,7 @@ def kojii_chebel(request: KojiiChebelRequest, callback=None):
"adopt_aspect_from_init_img": True,
"guidance_scale": guidance_scale,
"sampler": "euler",
"steps": 42,
"steps": 50,
"seed": seed,
}

Expand Down
30 changes: 25 additions & 5 deletions logos/creation_interfaces/kojii_untitledxyz.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ class KojiiUntitledxyzRequest(BaseModel):
seed: Optional[int] = Field(default=None, description="Random seed")


# def kojii_untitledxyz(request: KojiiUntitledxyzRequest, callback=None):
# import requests
# from ..creation_interfaces import KojiiUntitledxyzRequest
# for h in [0.0, 0.01, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.333333, 0.4, 0.45, 0.5, 0.55, 0.6, 0.666667, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 0.99, 1.0]:
# for s in [Type.column]: #, Type.context]:
# req = KojiiUntitledxyzRequest(
# human_machine_nature=h,
# type=s,
# seed=5
# )
# image_url, thumbnail_url, config = kojii_untitledxyz1(req)
# print("\n\n\n\n\n\n\n\n\n================")
# print("DO ", s, h)
# print(f'images/bbb_{s.value}_{h}.jpg')
# with open(f'images/bbb_{s.value}_{h}.jpg', 'wb') as f:
# f.write(requests.get(image_url).content)


def kojii_untitledxyz(request: KojiiUntitledxyzRequest, callback=None):
seed = request.seed if request.seed else random.randint(0, 1000000)

Expand Down Expand Up @@ -60,8 +78,8 @@ def kojii_untitledxyz(request: KojiiUntitledxyzRequest, callback=None):
"close up of a single column, highly detailed, pen and ink, stone drawn with light yellow, orange, light brown, solid white background, sharpness, noise.",
]
text_inputs_to_interpolate_weights = [
1 - 2 * (request.human_machine_nature - 2 / 3),
2 * (request.human_machine_nature - 2 / 3),
1 - 3 * (request.human_machine_nature - 2 / 3),
3 * (request.human_machine_nature - 2 / 3),
]

elif request.type == Type.context:
Expand Down Expand Up @@ -110,9 +128,11 @@ def kojii_untitledxyz(request: KojiiUntitledxyzRequest, callback=None):
}

print("CONFIG")
print(config)
print("=======")
print(request.human_machine_nature)
print(config["text_inputs_to_interpolate"])
print(config["text_inputs_to_interpolate_weights"])
print("=======\n\n\n")

image_url, thumbnail_url = replicate.sdxl(config)

return image_url, thumbnail_url
return image_url, thumbnail_url, config
24 changes: 21 additions & 3 deletions logos/creation_interfaces/kojii_violetforest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ class KojiiVioletforestRequest(BaseModel):


def kojii_violetforest(request: KojiiVioletforestRequest, callback=None):
import requests
from ..creation_interfaces import KojiiVioletforestRequest

for c in [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]:
for s in [Style.Kawaii, Style.Stars, Style.Lace, Style.Flowers]:
req = KojiiVioletforestRequest(
cybertwee_cyberpunk=float(c),
style=s,
seed=5,
)
image_url, thumbnail_url = kojii_violetforest1(req)
with open(f"images/{s.value}_{c}.jpg", "wb") as f:
f.write(requests.get(image_url).content)


def kojii_violetforest1(request: KojiiVioletforestRequest, callback=None):
seed = request.seed if request.seed else random.randint(0, 1000000)

if request.style == Style.Kawaii:
Expand All @@ -44,6 +60,7 @@ def kojii_violetforest(request: KojiiVioletforestRequest, callback=None):
f"a stunning image of a cute cybertwee girl, {modifiers}",
f"a stunning image of an Aston Martin sportscar, {modifiers}",
]
print(request)
text_inputs_to_interpolate_weights = [
request.cybertwee_cyberpunk,
1 - request.cybertwee_cyberpunk,
Expand All @@ -56,11 +73,12 @@ def kojii_violetforest(request: KojiiVioletforestRequest, callback=None):
"text_inputs_to_interpolate_weights": " | ".join(
[str(t) for t in text_inputs_to_interpolate_weights],
),
"lora": "https://edenartlab-prod-data.s3.us-east-1.amazonaws.com/e3b036c0a9949de0a5433cb6c7e54b540c47535ce7ae252948177304542ca4da.tar",
"lora_scale": 0.7,
# "lora": "https://edenartlab-prod-data.s3.us-east-1.amazonaws.com/e3b036c0a9949de0a5433cb6c7e54b540c47535ce7ae252948177304542ca4da.tar",
# "lora_scale": 0.7,
"seed": seed,
}

print("CONFIG")
print(config)
image_url, thumbnail_url = replicate.sdxl(config)

return image_url, thumbnail_url
2 changes: 0 additions & 2 deletions tests/test_creation_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ 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())

Expand Down

0 comments on commit e77e29e

Please sign in to comment.