diff --git a/Tenacious/architecture_diagram.png b/Tenacious/architecture_diagram.png new file mode 100644 index 00000000..1c2fb378 Binary files /dev/null and b/Tenacious/architecture_diagram.png differ diff --git a/Tenacious/car.jpg b/Tenacious/car.jpg new file mode 100644 index 00000000..9447456b Binary files /dev/null and b/Tenacious/car.jpg differ diff --git a/Tenacious/main.py b/Tenacious/main.py new file mode 100644 index 00000000..5e7ded44 --- /dev/null +++ b/Tenacious/main.py @@ -0,0 +1,52 @@ +import numpy as np + +from PIL import Image +import cv2 + +import torch + +import ultralytics +from ultralytics import YOLO +from diffusers import StableDiffusionInpaintPipeline + +model = YOLO('yolov8m-seg.pt') + +img= cv2.imread('car.jpg') +image = cv2.resize(img,(640,384)) + +results = model.predict(source=img.copy(), save=True, save_txt=False, stream=True) + +for result in results: + # get array results + masks = result.masks.data + boxes = result.boxes.data + # extract classes + clss = boxes[:, 5] + # get indices of results where class is 0 (people in COCO) + car_indices = torch.where(clss == 2) + # use these indices to extract the relevant masks + car_masks = masks[car_indices] + # scale for visualizing results + car_mask = torch.any(car_masks, dim=0).int() * 255 + + mask_image = car_mask.cpu().numpy() + +image = Image.fromarray(image.astype('uint8'), 'RGB') +mask_image = Image.fromarray(cv2.bitwise_not(mask_image).astype('uint8')) + +pipe = StableDiffusionInpaintPipeline.from_pretrained( + "runwayml/stable-diffusion-inpainting", + revision="fp16", + torch_dtype=torch.float32, +) + +prompt = str(input("Enter the prompt: ")) #"high resolution, car on beach" + +out_image = pipe(prompt=prompt, image=image, mask_image=mask_image).images[0] + +output_image = np.array(out_image) +output_image = cv2.resize(output_image,image.size) + +cv2.imshow("Product Image",ouput_image) +cv2.waitkey(0) + diff --git a/Tenacious/readme.md b/Tenacious/readme.md new file mode 100644 index 00000000..08ed12d5 --- /dev/null +++ b/Tenacious/readme.md @@ -0,0 +1,38 @@ +**Team Name** - Tenacious
+**Problem Statement** - Revolutionary AI-Infused Retail Platform
+**Team Leader Email** - dhiman.anushka@gmail.com
+# A Brief of the Prototype +GenAI Product Shots, will generate professional studio equivalent images of products. +GenAI Product Shots will cut the photography time, cost and resource. +We will mask the object from the image, then original image and masked image will be given as an input. +Stable diffusion will produce desirable results based on the input and prompt. +Multiple variant of these images with different colours and backgrounds can be used for product catalogue. + +![Architecture Diagram](architecture_diagram.png) + + +# Tech Stack +- Intel Extension for PyTorch +- PyTorch-GPU +- OpenCV +- Numpy +- Pillow +- YOLO +- Stable Diffusion + +# Step-by-Step Code Execution Instructions + +``git clone https://github.com/akkmr1996/oneAPI-GenAI-Hackathon-2023.git`` + +``cd Tenacious`` + +``pip install -r requirements.txt`` + +``python main.py`` +
+ +# Future Scope +- We will develop a user friendly web application using Flask. +- In this we have only used a car as a product, but in future we will use different product like food product, beauty and fashion products. +- Then we need to train a segmentation model for these products and then deployed it on Intel Cloud and hence use the Intel OneAPI Toolkit. + diff --git a/Tenacious/requirements.txt b/Tenacious/requirements.txt new file mode 100644 index 00000000..eec0e445 --- /dev/null +++ b/Tenacious/requirements.txt @@ -0,0 +1,128 @@ +asn1crypto @ file:///home/conda/feedstock_root/build_artifacts/asn1crypto_1647369152656/work +asttokens @ file:///opt/conda/conda-bld/asttokens_1646925590279/work +backcall @ file:///home/ktietz/src/ci/backcall_1611930011877/work +Bottleneck @ file:///opt/conda/conda-bld/bottleneck_1657175564434/work +brotlipy @ file:///home/conda/feedstock_root/build_artifacts/brotlipy_1666764672617/work +certifi @ file:///croot/certifi_1690232220950/work/certifi +cffi @ file:///home/conda/feedstock_root/build_artifacts/cffi_1671179360775/work +chardet @ file:///home/conda/feedstock_root/build_artifacts/chardet_1669990273997/work +charset-normalizer @ file:///home/conda/feedstock_root/build_artifacts/charset-normalizer_1678108872112/work +colorama @ file:///home/conda/feedstock_root/build_artifacts/colorama_1666700638685/work +comm @ file:///croot/comm_1671231121260/work +conda==23.3.1 +conda-package-handling @ file:///home/conda/feedstock_root/build_artifacts/conda-package-handling_1669907009957/work +conda_package_streaming @ file:///home/conda/feedstock_root/build_artifacts/conda-package-streaming_1685101166527/work +contourpy @ file:///opt/conda/conda-bld/contourpy_1663827406301/work +cryptography @ file:///home/conda/feedstock_root/build_artifacts/cryptography-split_1685659424938/work +cycler @ file:///home/conda/feedstock_root/build_artifacts/cycler_1635519461629/work +Cython @ file:///home/conda/feedstock_root/build_artifacts/cython_1685025003072/work +debugpy @ file:///croot/debugpy_1690905042057/work +decorator @ file:///opt/conda/conda-bld/decorator_1643638310831/work +dpcpp-llvm-spirv==0.0.0 +dpctl==0.14.4+27.ga3cde67f7 +dpnp==0.12.0 +exceptiongroup @ file:///croot/exceptiongroup_1668714342571/work +executing @ file:///opt/conda/conda-bld/executing_1646925071911/work +filelock==3.13.1 +fonttools==4.25.0 +fsspec==2023.12.0 +funcsigs==1.0.2 +future @ file:///home/conda/feedstock_root/build_artifacts/future_1673596611778/work +idna @ file:///home/conda/feedstock_root/build_artifacts/idna_1663625384323/work +importlib-metadata @ file:///croot/importlib-metadata_1678997070253/work +ipykernel @ file:///croot/ipykernel_1691121631942/work +ipython @ file:///croot/ipython_1694181358621/work +ipywidgets @ file:///croot/ipywidgets_1679394798311/work +jedi @ file:///tmp/build/80754af9/jedi_1644297102865/work +Jinja2==3.1.2 +joblib @ file:///home/conda/feedstock_root/build_artifacts/joblib_1663332044897/work +jsonpatch @ file:///home/conda/feedstock_root/build_artifacts/jsonpatch_1632759296524/work +jsonpointer==2.0 +jupyter_client @ file:///croot/jupyter_client_1680171862562/work +jupyter_core @ file:///croot/jupyter_core_1679906564508/work +jupyterlab-widgets @ file:///croot/jupyterlab_widgets_1679055282532/work +kiwisolver @ file:///home/conda/feedstock_root/build_artifacts/kiwisolver_1666805784128/work +libarchive-c @ file:///home/conda/feedstock_root/build_artifacts/python-libarchive-c_1666852475034/work +llvmlite==0.40.0 +MarkupSafe==2.1.3 +matplotlib @ file:///croot/matplotlib-suite_1670466153205/work +matplotlib-inline @ file:///opt/conda/conda-bld/matplotlib-inline_1662014470464/work +mkl-fft==1.3.6 +mkl-random==1.2.2 +mkl-service==2.4.0 +mkl-umath==0.1.1 +mpmath==1.3.0 +munkres==1.1.4 +nest-asyncio @ file:///croot/nest-asyncio_1672387112409/work +networkx==3.2.1 +numba @ file:///home/conda/feedstock_root/build_artifacts/numba_1686793463639/work +numba-dpex==0.21.0 +numexpr @ file:///croot/numexpr_1696515281613/work +numpy==1.24.3 +nvidia-cublas-cu12==12.1.3.1 +nvidia-cuda-cupti-cu12==12.1.105 +nvidia-cuda-nvrtc-cu12==12.1.105 +nvidia-cuda-runtime-cu12==12.1.105 +nvidia-cudnn-cu12==8.9.2.26 +nvidia-cufft-cu12==11.0.2.54 +nvidia-curand-cu12==10.3.2.106 +nvidia-cusolver-cu12==11.4.5.107 +nvidia-cusparse-cu12==12.1.0.106 +nvidia-nccl-cu12==2.18.1 +nvidia-nvjitlink-cu12==12.3.101 +nvidia-nvtx-cu12==12.1.105 +opencv-python==4.8.1.78 +packaging @ file:///home/conda/feedstock_root/build_artifacts/packaging_1681337016113/work +pandas @ file:///croot/pandas_1692289311655/work +parso @ file:///opt/conda/conda-bld/parso_1641458642106/work +pexpect @ file:///tmp/build/80754af9/pexpect_1605563209008/work +pickleshare @ file:///tmp/build/80754af9/pickleshare_1606932040724/work +Pillow @ file:///home/conda/feedstock_root/build_artifacts/pillow_1688255839723/work +platformdirs @ file:///home/conda/feedstock_root/build_artifacts/platformdirs_1687097136512/work +pluggy @ file:///home/conda/feedstock_root/build_artifacts/pluggy_1667232663820/work +pooch @ file:///home/conda/feedstock_root/build_artifacts/pooch_1679580333621/work +prompt-toolkit @ file:///croot/prompt-toolkit_1672387306916/work +psutil @ file:///opt/conda/conda-bld/psutil_1656431268089/work +ptyprocess @ file:///tmp/build/80754af9/ptyprocess_1609355006118/work/dist/ptyprocess-0.7.0-py2.py3-none-any.whl +pure-eval @ file:///opt/conda/conda-bld/pure_eval_1646925070566/work +py-cpuinfo==9.0.0 +pycosat @ file:///home/conda/feedstock_root/build_artifacts/pycosat_1666836642684/work +pycparser @ file:///home/conda/feedstock_root/build_artifacts/pycparser_1636257122734/work +pyeditline==2.0.1 +Pygments @ file:///croot/pygments_1684279966437/work +pyOpenSSL @ file:///home/conda/feedstock_root/build_artifacts/pyopenssl_1685514481738/work +pyparsing @ file:///home/conda/feedstock_root/build_artifacts/pyparsing_1687132014935/work +PySocks @ file:///home/conda/feedstock_root/build_artifacts/pysocks_1648857263093/work +python-dateutil @ file:///home/conda/feedstock_root/build_artifacts/python-dateutil_1626286286081/work +pytz @ file:///home/conda/feedstock_root/build_artifacts/pytz_1680088766131/work +PyYAML @ file:///home/conda/feedstock_root/build_artifacts/pyyaml_1666772387118/work +pyzmq @ file:///croot/pyzmq_1686601365461/work +requests @ file:///home/conda/feedstock_root/build_artifacts/requests_1684774241324/work +ruamel.yaml @ file:///home/conda/feedstock_root/build_artifacts/ruamel.yaml_1686993888032/work +ruamel.yaml.clib @ file:///home/conda/feedstock_root/build_artifacts/ruamel.yaml.clib_1670412733608/work +scikit-learn @ file:///home/conda/feedstock_root/build_artifacts/scikit-learn_1685023709438/work +scipy==1.10.1 +seaborn @ file:///croot/seaborn_1673479180098/work +six @ file:///home/conda/feedstock_root/build_artifacts/six_1620240208055/work +SMP==0.1.4 +stack-data @ file:///opt/conda/conda-bld/stack_data_1646927590127/work +sympy==1.12 +TBB==0.2 +thop==0.1.1.post2209072238 +threadpoolctl @ file:///home/conda/feedstock_root/build_artifacts/threadpoolctl_1643647933166/work +toolz @ file:///home/conda/feedstock_root/build_artifacts/toolz_1657485559105/work +torch==2.1.1 +torchvision==0.16.1 +tornado @ file:///croot/tornado_1690848263220/work +tqdm @ file:///home/conda/feedstock_root/build_artifacts/tqdm_1677948868469/work +traitlets @ file:///croot/traitlets_1671143879854/work +triton==2.1.0 +typing_extensions @ file:///home/conda/feedstock_root/build_artifacts/typing_extensions_1685704949284/work +tzdata @ file:///croot/python-tzdata_1690578112552/work +ultralytics==8.0.222 +urllib3 @ file:///home/conda/feedstock_root/build_artifacts/urllib3_1686156552494/work +wcwidth @ file:///Users/ktietz/demo/mc3/conda-bld/wcwidth_1629357192024/work +widgetsnbextension @ file:///croot/widgetsnbextension_1679313860248/work +xgboost==1.7.3 +zipp @ file:///croot/zipp_1672387121353/work +zstandard==0.19.0