Giter Site home page Giter Site logo

aldente0630 / musinsaigo Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 47.6 MB

Using SageMaker and LoRA to fine-tune the Stable Diffusion model and generate fashion images

Home Page: https://huggingface.co/youngmki/musinsaigo-2.0

License: Other

Python 32.56% Shell 0.20% Dockerfile 0.15% Jupyter Notebook 67.09%
huggingface-accelerate huggingface-diffusers lora sagemaker stable-diffusion

musinsaigo's Introduction

MUSINSA-IGO (MUSINSA fashion Image Generative Operator)


MUSINSA-IGO 3.0 is a text-to-image generative model that fine-tuned Stable Diffusion XL 1.0 with LoRA using street snaps downloaded from the website of Musinsa, a Korean fashion commerce company. This is very useful for generating fashion images.

Examples


assets-01 assets-02

Notes


  • For example, the recommended prompt template is shown below.

Prompt: RAW photo, fashion photo of subject, (high detailed skin:1.2), 8k uhd, dslr, soft lighting, high quality, film grain, Fujifilm XT3

Negative Prompt: (deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime:1.4), text, close up, cropped, out of frame, the worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck

Usage


import torch
from diffusers import DiffusionPipeline


def make_prompt(prompt: str) -> str:
    prompt_prefix = "RAW photo"
    prompt_suffix = "(high detailed skin:1.2), 8k uhd, dslr, soft lighting, high quality, film grain, Fujifilm XT3"
    return ", ".join([prompt_prefix, prompt, prompt_suffix]).strip()


def make_negative_prompt(negative_prompt: str) -> str:
    negative_prefix = "(deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime:1.4), \
    text, close up, cropped, out of frame, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, \
    extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, \
    bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, \
    extra arms, extra legs, fused fingers, too many fingers, long neck"

    return (
        ", ".join([negative_prefix, negative_prompt]).strip()
        if len(negative_prompt) > 0
        else negative_prefix
    )


device = "cuda" if torch.cuda.is_available() else "cpu"

model_id = "aldente0630/musinsaigo-3.0"
pipe = DiffusionPipeline.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16
)
pipe = pipe.to(device)
pipe.load_lora_weights(model_id)

# Write your prompt here.
PROMPT = "a korean woman wearing a white t - shirt and black pants with a bear on it"  
NEGATIVE_PROMPT = ""

# If you're not using a refiner
image = pipe(
    prompt=make_prompt(PROMPT),
    height=1024,
    width=768,
    num_inference_steps=50,
    guidance_scale=7.5,
    negative_prompt=make_negative_prompt(NEGATIVE_PROMPT),
    cross_attention_kwargs={"scale": 0.75},
).images[0]

# If you're using a refiner
refiner = DiffusionPipeline.from_pretrained(
    "stabilityai/stable-diffusion-xl-refiner-1.0",
    text_encoder_2=pipe.text_encoder_2,
    vae=pipe.vae,
    torch_dtype=torch.float16,
)
refiner = refiner.to(device)

image = pipe(
    prompt=make_prompt(PROMPT),
    height=1024,
    width=768,
    num_inference_steps=50,
    guidance_scale=7.5,
    negative_prompt=make_negative_prompt(NEGATIVE_PROMPT),
    output_type="latent",
    cross_attention_kwargs={"scale": 0.75},
)["images"]

generated_images = refiner(
    prompt=make_prompt(PROMPT),
    image=image,
    num_inference_steps=50,
)["images"]

image.save("test.png")

test

References


musinsaigo's People

Contributors

aldente0630 avatar jahn-ksb avatar

Watchers

 avatar

musinsaigo's Issues

adjustments and environment for working with this project

Hi, I saw your repo it looks very clean! :D nice work.
I would like to use it on AWS aswell but I don't know how you use it since there seems to be no documentation about the setup.
I run the main.py script on an EC2 instance and and run into some errors since I am in eu.
There has to be some adjustments regarding the docker containers you are using if someone wants to use it from different region. The config should be used in Dockerfile aswell.

https://github.com/aldente0630/musinsaigo/blob/main/containers/data_prep/Dockerfile#L1
https://github.com/aldente0630/musinsaigo/blob/main/containers/model_train/Dockerfile#L1

then here there is a typo:
https://github.com/aldente0630/musinsaigo/blob/main/containers/model_train/Dockerfile#L27
its configs. not config ๐Ÿ‘ฏ

some informations regarding the docker containers :
when build both are โ‰ˆ 11 GB and require more than 25 gb storage. I had only 22 Gb free and run into a storage problem.

maybe you could give me more information about how you run it. Are you running the script from ec2? or SageMaker?
where are you using the lifecycle script?

Best Regard
Jahn

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.