Code Monkey home page Code Monkey logo

stable-fashion's Introduction

Stable Fashion

Hugging Face Spaces

drawing

How would you look like in a gray jacket or a pink striped t-shirt?

Decisions like this are very important when you are buying apparels from various e-commerce websits like Amazon, Myntra etc. More often than not, we end up returning these ordered items, because they don't look like you had imagined. Why don't we ease the stress we put on our imagination by using state of the art generative modeling to help us.

Introducing Stable Fashion, a prompt-based on try-on app (well, only code for now), where you can write prompts such as "A pink t shirt" or "A yellow adidas shirt with black stripes" and it would edit to put those clothing items on a full length picture of yours.

NEW

Now you can try out the demo on Huggingface Spaces: Hugging Face Spaces

Instructions to Run

  1. Please ensure anaconda is installed in your system. If not, you can follow the instructions here.
  2. Run the following command
conda create -n sf python=3.9
conda activate sf
cat requirements.txt | xargs -n 1 pip install
  1. To run the pipeline, use this sample command
python main.py --image ../../assets/stockimage.jpeg --resolution 512  --prompt "yellow shirt"  --part upper  --num_steps 25   --output stock_yellow.jpg

Other available options are

Stable Fashion API, allows you to picture yourself in any cloth your imagination can think of!

optional arguments:
  -h, --help            show this help message and exit
  --image IMAGE         path to image
  --part {upper,lower}
  --resolution {256,512,1024,2048}
  --prompt PROMPT
  --num_steps NUM_STEPS
  --guidance_scale GUIDANCE_SCALE
  --rembg
  --output OUTPUT
  1. The image will be saved as whatever name you provide with --output. The default is output.jpg. in the root directory of the project.

Things to Keep in Mind

  1. Please ensure you only describe the clothing item in your prompt. Any other information throws off the model for the time being.

โœ… A green hoodie

โŒ A green hoodie wrapped around the waist

  1. Currently, the code relies on a GPU. Please ensure you have an NVIDIA GPU with the appropiate CUDA kernel. Now you can run the pipeline on CPU as well, although it will take considerably more time.

  2. Please ensure your full length picture is taken from front, with a whitish background. It helps the model to isolate you in the picture. NEW: now you can use the rembg option to turn a normal in-the-wild picture into a picture with white background.

  3. You can mention which part of the picture you want to dress up, upper (torso) or lower (pants, trousers etc)

Models Used

For this app, first we segment the human out of the image. For this we use rembg. Then we segment the upper and lower clothes using the cloth segmentation repository. On top of this we run the stable diffusion inpainting pipeline from huggingface.

Results

These are some of the results of the prompts on a stock full length image.

Original Image Prompt: a yellow shirt Prompt: A pink shirt
image info image info image info

Next Steps

  • Converting this to a single read, single write code-base.
  • Adding CPU support
  • Wrapping this up in an API and hosting it
  • Making an UI (put on HF spaces for now)

Acknowledgments

Thanks to huggingface, runway-ml and @levindabhi for their wonderful codebases.

Feedback

This is a hobby project and has some pretty gaping holes. I am very happy to recieve feedback and PRs. You can reach out to me on twitter: @o_v_shake or open an issue in this repository.

stable-fashion's People

Contributors

ovshake avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

stable-fashion's Issues

Face data

This ai changes the face data. But even if it is not masked pixel on the face is changing.

Huggingfaces spaces returns runtime error

Following the link to the Huggingfaces spaces gives the following error:

Runtime error

  File "/home/user/.pyenv/versions/3.8.9/bin/streamlit", line 5, in <module>
    from streamlit.cli import main
  File "/home/user/.pyenv/versions/3.8.9/lib/python3.8/site-packages/streamlit/__init__.py", line 70, in <module>
    from streamlit.delta_generator import DeltaGenerator as _DeltaGenerator
  File "/home/user/.pyenv/versions/3.8.9/lib/python3.8/site-packages/streamlit/delta_generator.py", line 90, in <module>
    from streamlit.elements.arrow_altair import ArrowAltairMixin
  File "/home/user/.pyenv/versions/3.8.9/lib/python3.8/site-packages/streamlit/elements/arrow_altair.py", line 27, in <module>
    from altair.vegalite.v4.api import Chart
ModuleNotFoundError: No module named 'altair.vegalite.v4'```

with Container logs:

===== Application Startup at 2023-07-07 08:46:14 =====

Traceback (most recent call last):
File "/home/user/.pyenv/versions/3.8.9/bin/streamlit", line 5, in
from streamlit.cli import main
File "/home/user/.pyenv/versions/3.8.9/lib/python3.8/site-packages/streamlit/init.py", line 70, in
from streamlit.delta_generator import DeltaGenerator as _DeltaGenerator
File "/home/user/.pyenv/versions/3.8.9/lib/python3.8/site-packages/streamlit/delta_generator.py", line 90, in
from streamlit.elements.arrow_altair import ArrowAltairMixin
File "/home/user/.pyenv/versions/3.8.9/lib/python3.8/site-packages/streamlit/elements/arrow_altair.py", line 27, in
from altair.vegalite.v4.api import Chart
ModuleNotFoundError: No module named 'altair.vegalite.v4'

Doesn't work

I cannot elaborate more than just saying that it brings up a black screen as "Mask" and stays there forever, no progress.

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.