diff --git a/Background_Removal_and_Change/.gitattributes b/Background_Removal_and_Change/.gitattributes deleted file mode 100644 index ac481c8eb05e4d2496fbe076a38a7b4835dd733d..0000000000000000000000000000000000000000 --- a/Background_Removal_and_Change/.gitattributes +++ /dev/null @@ -1,27 +0,0 @@ -*.7z filter=lfs diff=lfs merge=lfs -text -*.arrow filter=lfs diff=lfs merge=lfs -text -*.bin filter=lfs diff=lfs merge=lfs -text -*.bz2 filter=lfs diff=lfs merge=lfs -text -*.ftz filter=lfs diff=lfs merge=lfs -text -*.gz filter=lfs diff=lfs merge=lfs -text -*.h5 filter=lfs diff=lfs merge=lfs -text -*.joblib filter=lfs diff=lfs merge=lfs -text -*.lfs.* filter=lfs diff=lfs merge=lfs -text -*.model filter=lfs diff=lfs merge=lfs -text -*.msgpack filter=lfs diff=lfs merge=lfs -text -*.onnx filter=lfs diff=lfs merge=lfs -text -*.ot filter=lfs diff=lfs merge=lfs -text -*.parquet filter=lfs diff=lfs merge=lfs -text -*.pb filter=lfs diff=lfs merge=lfs -text -*.pt filter=lfs diff=lfs merge=lfs -text -*.pth filter=lfs diff=lfs merge=lfs -text -*.rar filter=lfs diff=lfs merge=lfs -text -saved_model/**/* filter=lfs diff=lfs merge=lfs -text -*.tar.* filter=lfs diff=lfs merge=lfs -text -*.tflite filter=lfs diff=lfs merge=lfs -text -*.tgz filter=lfs diff=lfs merge=lfs -text -*.wasm filter=lfs diff=lfs merge=lfs -text -*.xz filter=lfs diff=lfs merge=lfs -text -*.zip filter=lfs diff=lfs merge=lfs -text -*.zstandard filter=lfs diff=lfs merge=lfs -text -*tfevents* filter=lfs diff=lfs merge=lfs -text diff --git a/Background_Removal_and_Change/.idea/.gitignore b/Background_Removal_and_Change/.idea/.gitignore deleted file mode 100644 index 13566b81b018ad684f3a35fee301741b2734c8f4..0000000000000000000000000000000000000000 --- a/Background_Removal_and_Change/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/Background_Removal_and_Change/.idea/Background_Removal_and_Change.iml b/Background_Removal_and_Change/.idea/Background_Removal_and_Change.iml deleted file mode 100644 index e82daebc8498e441626b470bdf08582c696557e8..0000000000000000000000000000000000000000 --- a/Background_Removal_and_Change/.idea/Background_Removal_and_Change.iml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/Background_Removal_and_Change/.idea/deployment.xml b/Background_Removal_and_Change/.idea/deployment.xml deleted file mode 100644 index 973c9698d74f030c209975f13a0999f9050d0b17..0000000000000000000000000000000000000000 --- a/Background_Removal_and_Change/.idea/deployment.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Background_Removal_and_Change/.idea/inspectionProfiles/Project_Default.xml b/Background_Removal_and_Change/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 55a9fdb5b3c13dad5ff6d77f3579d8baefb68ecc..0000000000000000000000000000000000000000 --- a/Background_Removal_and_Change/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - \ No newline at end of file diff --git a/Background_Removal_and_Change/.idea/inspectionProfiles/profiles_settings.xml b/Background_Removal_and_Change/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2da2d6447d11dfe32bfb846c3d5b199fc99..0000000000000000000000000000000000000000 --- a/Background_Removal_and_Change/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/Background_Removal_and_Change/.idea/misc.xml b/Background_Removal_and_Change/.idea/misc.xml deleted file mode 100644 index 13fecf304bc8719c038c9a91fd31bec2797d5402..0000000000000000000000000000000000000000 --- a/Background_Removal_and_Change/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Background_Removal_and_Change/.idea/modules.xml b/Background_Removal_and_Change/.idea/modules.xml deleted file mode 100644 index 1ad20121ed2d1528e7b1d2726170ba4e638efabc..0000000000000000000000000000000000000000 --- a/Background_Removal_and_Change/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/Background_Removal_and_Change/.idea/sshConfigs.xml b/Background_Removal_and_Change/.idea/sshConfigs.xml deleted file mode 100644 index c4d89a88ded33f0b1cd0078cfa4be5111037b468..0000000000000000000000000000000000000000 --- a/Background_Removal_and_Change/.idea/sshConfigs.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/Background_Removal_and_Change/.idea/vcs.xml b/Background_Removal_and_Change/.idea/vcs.xml deleted file mode 100644 index 30c80f1c99e518e42d1cd6b96b738fb472b326e0..0000000000000000000000000000000000000000 --- a/Background_Removal_and_Change/.idea/vcs.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/Background_Removal_and_Change/.idea/webServers.xml b/Background_Removal_and_Change/.idea/webServers.xml deleted file mode 100644 index cce5561611c2c04cc103384926bf4cd67ca6b653..0000000000000000000000000000000000000000 --- a/Background_Removal_and_Change/.idea/webServers.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Background_Removal_and_Change/Procfile b/Background_Removal_and_Change/Procfile deleted file mode 100644 index 265de8638b4e9ff83dc0a0495bdbf708ce04dc8b..0000000000000000000000000000000000000000 --- a/Background_Removal_and_Change/Procfile +++ /dev/null @@ -1 +0,0 @@ -web: sh setup.sh && streamlit run app.py diff --git a/Background_Removal_and_Change/README.md b/Background_Removal_and_Change/README.md deleted file mode 100644 index a12b95ae1f0f9638ee15c1c70d954e4be2e5adba..0000000000000000000000000000000000000000 --- a/Background_Removal_and_Change/README.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: ABC- Automatic Background Change -emoji: ⚡ -colorFrom: yellow -colorTo: gray -sdk: streamlit -app_file: app.py -pinned: false ---- \ No newline at end of file diff --git a/Background_Removal_and_Change/__pycache__/libs.cpython-38.pyc b/Background_Removal_and_Change/__pycache__/libs.cpython-38.pyc deleted file mode 100644 index 6c0725581b75b98670798c5773d9f6514b426e0d..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/__pycache__/libs.cpython-38.pyc and /dev/null differ diff --git a/Background_Removal_and_Change/__pycache__/libs.cpython-39.pyc b/Background_Removal_and_Change/__pycache__/libs.cpython-39.pyc deleted file mode 100644 index 78438d876afe86373b0d599b4ff1b0a829540587..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/__pycache__/libs.cpython-39.pyc and /dev/null differ diff --git a/Background_Removal_and_Change/__pycache__/metrics.cpython-310.pyc b/Background_Removal_and_Change/__pycache__/metrics.cpython-310.pyc deleted file mode 100644 index a62e41d1fbea75540a496d721d9a8aa775ab49f4..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/__pycache__/metrics.cpython-310.pyc and /dev/null differ diff --git a/Background_Removal_and_Change/__pycache__/metrics.cpython-38.pyc b/Background_Removal_and_Change/__pycache__/metrics.cpython-38.pyc deleted file mode 100644 index 14532650679e5fa68779a59aeab18d484b12e8a1..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/__pycache__/metrics.cpython-38.pyc and /dev/null differ diff --git a/Background_Removal_and_Change/__pycache__/metrics.cpython-39.pyc b/Background_Removal_and_Change/__pycache__/metrics.cpython-39.pyc deleted file mode 100644 index bd9ad883acd7a18040c240dfbfa821c5761d63f4..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/__pycache__/metrics.cpython-39.pyc and /dev/null differ diff --git a/Background_Removal_and_Change/__pycache__/utils_func.cpython-38.pyc b/Background_Removal_and_Change/__pycache__/utils_func.cpython-38.pyc deleted file mode 100644 index 964f220e38a12b8abbba5b4a13cd34949f83f2ac..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/__pycache__/utils_func.cpython-38.pyc and /dev/null differ diff --git a/Background_Removal_and_Change/__pycache__/utils_func.cpython-39.pyc b/Background_Removal_and_Change/__pycache__/utils_func.cpython-39.pyc deleted file mode 100644 index 4be094aa3d23f26c178068ec62833b2522cb991a..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/__pycache__/utils_func.cpython-39.pyc and /dev/null differ diff --git a/Background_Removal_and_Change/app.py b/Background_Removal_and_Change/app.py deleted file mode 100644 index c21d823242778c253aa05c980f195392eb558531..0000000000000000000000000000000000000000 --- a/Background_Removal_and_Change/app.py +++ /dev/null @@ -1,94 +0,0 @@ -from libs import * -from utils_func import create_dir, main_processing - - - -create_dir("tempDir") - - -def load_image(image_file): - img = Image.open(image_file) - return img - - -def streamlit_app(): - detection_model_path = "weight_files/clothes_detection_model.pt" - background_model_path = "weight_files/model.h5" - save_path = "" - image_file = None - st.title("""WELCOME TO MY APP""") - st.subheader("""FOR BACKGROUND REMOVAL AND CHANGE!""") - col1 = None - col2 = None - final_img = None - with st.spinner("[UPLOAD] Image uploading"): - try: - image_file = st.file_uploader('[UPLOAD] Please upload your image:', type=["png", "jpg", "jpeg"]) - time.sleep(1) - except: - print("[ERROR] Sorry, something went wrong!") - pass - # print(type(image_file)) - - if image_file is not None: - st.success("Load image successfully!...") - image = load_image(image_file) - # print(type(image)) - col1, col2, col3 = st.columns(3) - with col1: - st.image(image, caption="Image before processing") - save_path = "tempDir/"+ image_file.name - image.save(save_path) - - - image_path, details = save_path, image_file - - if details is not None: - with col2: - with st.spinner("[PROCESSING] Image processing"): - final_img_path = main_processing(col1, col2, col3, sport_bg_path=stadium_sport_bg_path, swim_bg_path=beach_swim_bg_path, - office_bg_path=office_bg_path, img_path=image_path, name=details.name, - detection_model_path=detection_model_path, - background_model_path=background_model_path) - time.sleep(1) - - with col1: - if final_img_path is not None: - final_img = load_image(final_img_path) - st.image(final_img, caption="Image after processing") - st.balloons() - with col2: - with open(final_img_path, "rb") as file: - st.write('\n') - st.write('\n') - st.write('\n') - st.write('\n') - st.write('\n') - - file_name = save_path.split("/")[-1].split(".")[-2] +"_from_abc" + ".png" - - if st.download_button( - label="Download postprocessing image", - data=file, - file_name= file_name, - mime="image/png" - ): - st.success('[DOWNLOAD] Download sucessfully!') - - - -if __name__ == '__main__': - np.random.seed(42) - tf.random.set_seed(42) - - bg_path = "" - background_model_path = "weight_files/model.h5" - detection_model_path = "weight_files/clothes_detection_model.pt" - - stadium_sport_bg_path = "backgrounds/camnou_stadium.jpg" - beach_swim_bg_path = "backgrounds/beach.jpg" - office_bg_path = "backgrounds/office-bg.jpg" - - image_path = None - - streamlit_app() diff --git a/Background_Removal_and_Change/backgrounds/beach.jpg b/Background_Removal_and_Change/backgrounds/beach.jpg deleted file mode 100644 index 07de4aee643e3c4506bacf55c5f31b5a0afada3f..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/backgrounds/beach.jpg and /dev/null differ diff --git a/Background_Removal_and_Change/backgrounds/camnou_stadium.jpg b/Background_Removal_and_Change/backgrounds/camnou_stadium.jpg deleted file mode 100644 index c9e16cc104ede301a8db6ef552b3d1acaf03dcc2..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/backgrounds/camnou_stadium.jpg and /dev/null differ diff --git a/Background_Removal_and_Change/backgrounds/office-bg.jpg b/Background_Removal_and_Change/backgrounds/office-bg.jpg deleted file mode 100644 index f03c130f04934d00e696143174bf01bc6abaf937..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/backgrounds/office-bg.jpg and /dev/null differ diff --git a/Background_Removal_and_Change/images/img8.jpg b/Background_Removal_and_Change/images/img8.jpg deleted file mode 100644 index 666d2e753e412a66804d41f6ec07f26f118820cb..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/images/img8.jpg and /dev/null differ diff --git a/Background_Removal_and_Change/images/messi.jpg b/Background_Removal_and_Change/images/messi.jpg deleted file mode 100644 index 85bfba127ee96824cb74b40917dae28093d1e69f..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/images/messi.jpg and /dev/null differ diff --git a/Background_Removal_and_Change/images/office.jpg b/Background_Removal_and_Change/images/office.jpg deleted file mode 100644 index c4683efef08283c38e6ca8f2dd4ef2fca7425631..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/images/office.jpg and /dev/null differ diff --git a/Background_Removal_and_Change/libs.py b/Background_Removal_and_Change/libs.py deleted file mode 100644 index 0bcb0f9c02c2914c336bac33c3058d6577c73f85..0000000000000000000000000000000000000000 --- a/Background_Removal_and_Change/libs.py +++ /dev/null @@ -1,10 +0,0 @@ -import torch -import json -import os -import numpy as np -import cv2 -import tensorflow as tf -import streamlit as st -import time -from PIL import Image -from tensorflow.keras.utils import CustomObjectScope diff --git a/Background_Removal_and_Change/metrics.py b/Background_Removal_and_Change/metrics.py deleted file mode 100644 index b3e5d3d3557a15661934e1c109c9baa2d7e57503..0000000000000000000000000000000000000000 --- a/Background_Removal_and_Change/metrics.py +++ /dev/null @@ -1,25 +0,0 @@ -from libs import * - -smooth = 1e-15 - - -def iou(y_true, y_pred): - def f(y_true, y_pred): - intersection = (y_true * y_pred).sum() - union = y_true.sum() + y_pred.sum() - intersection - x = (intersection + 1e-15) / (union + 1e-15) - x = x.astype(np.float32) - return x - return tf.numpy_function(f, [y_true, y_pred], tf.float32) - - - -def dice_coef(y_true, y_pred): - y_true = tf.keras.layers.Flatten()(y_true) - y_pred = tf.keras.layers.Flatten()(y_pred) - intersection = tf.reduce_sum(y_true * y_pred) - return (2. * intersection + smooth) / (tf.reduce_sum(y_true) + tf.reduce_sum(y_pred) + smooth) - - -def dice_loss(y_true, y_pred): - return 1.0 - dice_coef(y_true, y_pred) diff --git a/Background_Removal_and_Change/remove_bg/R.jpg_1.png b/Background_Removal_and_Change/remove_bg/R.jpg_1.png deleted file mode 100644 index 97ab4bc5404d2e349885717b218818f600543d5b..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/remove_bg/R.jpg_1.png and /dev/null differ diff --git a/Background_Removal_and_Change/remove_bg/R.jpg_2.png b/Background_Removal_and_Change/remove_bg/R.jpg_2.png deleted file mode 100644 index c703e718f35776a27c27d97d9c19a86784d6ed49..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/remove_bg/R.jpg_2.png and /dev/null differ diff --git a/Background_Removal_and_Change/remove_bg/R.jpg_3.png b/Background_Removal_and_Change/remove_bg/R.jpg_3.png deleted file mode 100644 index 198deff89f97e2a03c1d65f726f368f892d3cb4d..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/remove_bg/R.jpg_3.png and /dev/null differ diff --git a/Background_Removal_and_Change/remove_bg/R.jpg_4.png b/Background_Removal_and_Change/remove_bg/R.jpg_4.png deleted file mode 100644 index a4146d9b0ea8b63f658cd810b4d0fd314a428864..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/remove_bg/R.jpg_4.png and /dev/null differ diff --git a/Background_Removal_and_Change/remove_bg/R.jpg_5.png b/Background_Removal_and_Change/remove_bg/R.jpg_5.png deleted file mode 100644 index b5312f1719f03f393c562ab801b38b5684f1118a..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/remove_bg/R.jpg_5.png and /dev/null differ diff --git a/Background_Removal_and_Change/remove_bg/R.jpg_6.png b/Background_Removal_and_Change/remove_bg/R.jpg_6.png deleted file mode 100644 index 28e03628fe353d6f2a7ad9058194fe79e06cba8a..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/remove_bg/R.jpg_6.png and /dev/null differ diff --git a/Background_Removal_and_Change/remove_bg/beach.jpg_1.png b/Background_Removal_and_Change/remove_bg/beach.jpg_1.png deleted file mode 100644 index eb4338c0b71f582952eef2cb6be5277cc97d043a..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/remove_bg/beach.jpg_1.png and /dev/null differ diff --git a/Background_Removal_and_Change/remove_bg/beach.jpg_2.png b/Background_Removal_and_Change/remove_bg/beach.jpg_2.png deleted file mode 100644 index 29c6c2992fc0fd218773be79703a29fd46ba966f..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/remove_bg/beach.jpg_2.png and /dev/null differ diff --git a/Background_Removal_and_Change/remove_bg/beach.jpg_3.png b/Background_Removal_and_Change/remove_bg/beach.jpg_3.png deleted file mode 100644 index a6ba9076ba534e5e545235bd53827ae1bb9be760..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/remove_bg/beach.jpg_3.png and /dev/null differ diff --git a/Background_Removal_and_Change/remove_bg/beach.jpg_4.png b/Background_Removal_and_Change/remove_bg/beach.jpg_4.png deleted file mode 100644 index cb7bb46b2db57098304aa914f3c3906f074d5e20..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/remove_bg/beach.jpg_4.png and /dev/null differ diff --git a/Background_Removal_and_Change/remove_bg/beach.jpg_5.png b/Background_Removal_and_Change/remove_bg/beach.jpg_5.png deleted file mode 100644 index 040d00faf4353918f382fd05fda7f4e1066f1595..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/remove_bg/beach.jpg_5.png and /dev/null differ diff --git a/Background_Removal_and_Change/remove_bg/beach.jpg_6.png b/Background_Removal_and_Change/remove_bg/beach.jpg_6.png deleted file mode 100644 index 2fd83803c5cc60f486e623a8f75e043596c95eb8..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/remove_bg/beach.jpg_6.png and /dev/null differ diff --git a/Background_Removal_and_Change/remove_bg/messi.jpg_1.png b/Background_Removal_and_Change/remove_bg/messi.jpg_1.png deleted file mode 100644 index c9340586188e77249958083c8450f971e4fc4c2e..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/remove_bg/messi.jpg_1.png and /dev/null differ diff --git a/Background_Removal_and_Change/remove_bg/messi.jpg_2.png b/Background_Removal_and_Change/remove_bg/messi.jpg_2.png deleted file mode 100644 index 1ac489e4fffa26d45fae1647f934c1d55bb5a762..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/remove_bg/messi.jpg_2.png and /dev/null differ diff --git a/Background_Removal_and_Change/remove_bg/messi.jpg_3.png b/Background_Removal_and_Change/remove_bg/messi.jpg_3.png deleted file mode 100644 index fb5485f07f8261994c1c5560c9fa7770fafb4985..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/remove_bg/messi.jpg_3.png and /dev/null differ diff --git a/Background_Removal_and_Change/remove_bg/messi.jpg_4.png b/Background_Removal_and_Change/remove_bg/messi.jpg_4.png deleted file mode 100644 index 36c19f39b1775643a3b0ed19f05a1387258a80cf..0000000000000000000000000000000000000000 --- a/Background_Removal_and_Change/remove_bg/messi.jpg_4.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:377ef7b1443a9573bfef12b9dddb90d7345eebb7fd58e440a4340ab6481df09e -size 2057239 diff --git a/Background_Removal_and_Change/remove_bg/messi.jpg_5.png b/Background_Removal_and_Change/remove_bg/messi.jpg_5.png deleted file mode 100644 index bc2d512599e6fca4808378158a9cf831a0951a4f..0000000000000000000000000000000000000000 --- a/Background_Removal_and_Change/remove_bg/messi.jpg_5.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:652ab3fd4a66cc60a4d4fe234613a480939713e2487d6d3caac2497e9807de4c -size 1096458 diff --git a/Background_Removal_and_Change/remove_bg/messi.jpg_6.png b/Background_Removal_and_Change/remove_bg/messi.jpg_6.png deleted file mode 100644 index e212f7a2496c6bb3448d32ee81d6a631b3979eb5..0000000000000000000000000000000000000000 --- a/Background_Removal_and_Change/remove_bg/messi.jpg_6.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d954f831634ff0fe2f22b9ea01fe98dad8891858da42b3e285bd80f1a9b6dc93 -size 1587906 diff --git a/Background_Removal_and_Change/requirements.txt b/Background_Removal_and_Change/requirements.txt deleted file mode 100644 index 3ef8e00426b9cfe51c13e78fac2912794d3b6b0d..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/requirements.txt and /dev/null differ diff --git a/Background_Removal_and_Change/setup.sh b/Background_Removal_and_Change/setup.sh deleted file mode 100644 index c8650a8b74a58d9a5f53b185fd711c5668e1cd52..0000000000000000000000000000000000000000 --- a/Background_Removal_and_Change/setup.sh +++ /dev/null @@ -1,13 +0,0 @@ -mkdir -p ~/.streamlit/ - -echo "\ -[general]\n\ -email = \"your-email@domain.com\"\n\ -" > ~/.streamlit/credentials.toml - -echo "\ -[server]\n\ -headless = true\n\ -enableCORS=false\n\ -port = $PORT\n\ -" > ~/.streamlit/config.toml \ No newline at end of file diff --git a/Background_Removal_and_Change/tempDir/R.jpg b/Background_Removal_and_Change/tempDir/R.jpg deleted file mode 100644 index 24a288d27be9d47ae60094d25cff8d026f664b55..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/tempDir/R.jpg and /dev/null differ diff --git a/Background_Removal_and_Change/tempDir/beach.jpg b/Background_Removal_and_Change/tempDir/beach.jpg deleted file mode 100644 index 07de4aee643e3c4506bacf55c5f31b5a0afada3f..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/tempDir/beach.jpg and /dev/null differ diff --git a/Background_Removal_and_Change/tempDir/messi.jpg b/Background_Removal_and_Change/tempDir/messi.jpg deleted file mode 100644 index 4681edd28b936c40d91afe1d1228b05cf91ebc87..0000000000000000000000000000000000000000 Binary files a/Background_Removal_and_Change/tempDir/messi.jpg and /dev/null differ diff --git a/Background_Removal_and_Change/utils_func.py b/Background_Removal_and_Change/utils_func.py deleted file mode 100644 index 9ade11b9be1df83a1860075bc4c7d4ea9903299b..0000000000000000000000000000000000000000 --- a/Background_Removal_and_Change/utils_func.py +++ /dev/null @@ -1,205 +0,0 @@ -from metrics import dice_loss, dice_coef, iou -from libs import * - - -os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2" - -""" Global parameters """ -H = 512 -W = 512 - - -def load_image(image_file): - img = Image.open(image_file) - return img - - -def choose_background(col1, col2, col3): - background_file = None - bg_image = None - with col3: - with st.spinner("[UPLOAD] Background uploading"): - try: - if background_file is None: - try: - background_file = st.file_uploader('[UPLOAD] Please upload your background:', type=["png", "jpg", "jpeg"]) - time.sleep(1) - except: - pass - except: - print("[ERROR] Sorry, something went wrong!") - pass - - if background_file is not None: - with col2: - st.success("Load background successfully!...") - - bg_image = load_image(background_file) - print(type(bg_image)) - save_path = "backgrounds/" + background_file.name - bg_image.save(save_path) - - return bg_image, save_path - - -def create_dir(path): - if not os.path.exists(path): - os.makedirs(path) - - -def check_clothe(model_path, img_path): - # Model - model = torch.hub.load('ultralytics/yolov5', 'custom', model_path) # or yolov5n - yolov5x6, custom - - # Inference - results = model(img_path) - - # Results - new_results = results.pandas().xyxy[0].sort_values("confidence").to_json(orient="records") - new_results = json.loads(new_results) - - classes_in_img = [] - classes_count_dict = {} - item = '' - if len(new_results) != 0: - for i in range(len(new_results)): - classes_in_img.append(new_results[i]['name']) - set_of_classes = set(classes_in_img) - list_of_classes = list(set_of_classes) - - older_value_count = 0 - for idx in range(len(list_of_classes)): - value_count = classes_in_img.count(list_of_classes[idx]) - if value_count > older_value_count: - item = list_of_classes[idx] - - else: - item = None - - return item - - - -def main_processing(col1, col2, col3, sport_bg_path, swim_bg_path, office_bg_path, img_path, name, detection_model_path, background_model_path): - """ Seeding """ - bg_path = None - np.random.seed(42) - tf.random.set_seed(42) - - model_path = detection_model_path - - stadium_sport_bg_path = sport_bg_path - beach_swim_bg_path = swim_bg_path - office_bg_path = office_bg_path - - """ Directory for storing files """ - create_dir("remove_bg") - - st.write('Auto detect or choosing background? ') - - if bg_path is None: - if st.checkbox('Choose background'): - try: - bg_img, save_path = choose_background(col1, col2, col3) - bg_path = save_path - except: - pass - - """ Directory for storing files """ - elif st.checkbox('Automatic background'): - item = check_clothe(model_path, img_path) - if item == 'sport': - bg_path = stadium_sport_bg_path - st.write("Hãy tiếp tục luyện tập TDTT chăm chỉ nhé!...") - if item == 'swim': - bg_path = beach_swim_bg_path - st.write("Thời tiết thế này không đi biển hơi phí nhé!...") - if item == 'office': - bg_path = office_bg_path - st.write("Chơi nhiều roài, đi làm chăm chỉ thuii...") - if item == None: - st.warning("Sorry, mô hình chúng tôi không biết bạn đang mặc cái quái gì hết...") - st.warning("Chọn background bạn muốn nhé!") - try: - background_img, save_path = choose_background(col1, col2, col3) - bg_path = save_path - except: - pass - - else: - pass - - else: - pass - - if bg_path is not None: - """ Loading model: DeepLabV3+ """ - with CustomObjectScope({'iou': iou, 'dice_coef': dice_coef, 'dice_loss': dice_loss}): - model = tf.keras.models.load_model(background_model_path) - - """ Read the image """ - image = cv2.imread(img_path, cv2.IMREAD_COLOR) - h, w, _ = image.shape - x = cv2.resize(image, (W, H)) - x = x / 255.0 - x = x.astype(np.float32) - x = np.expand_dims(x, axis=0) - - """ Prediction """ - y = model.predict(x)[0] - y = cv2.resize(y, (w, h)) - y = np.expand_dims(y, axis=-1) - y = y > 0.5 - - photo_mask = y - background_mask = np.abs(1 - y) - cv2.imwrite( - f"remove_bg\\{name}_1.png", - photo_mask * 255) - cv2.imwrite( - f"remove_bg\\{name}_2.png", - background_mask * 255) - - cv2.imwrite( - f"remove_bg\\{name}_3.png", - image * photo_mask) - cv2.imwrite( - f"remove_bg\\{name}_4.png", - image * background_mask) - - bg_img = cv2.imread(bg_path, cv2.IMREAD_COLOR) - print(bg_img.shape) - new_bg_img = cv2.resize(bg_img, (w, h)) - - new_new_bg_img = new_bg_img * background_mask - - cv2.imwrite( - f"remove_bg\\{name}_5.png", - new_new_bg_img) - - final_final_img = new_new_bg_img + image * photo_mask - - final_img_path = f"remove_bg\\{name}_6.png" - cv2.imwrite( - final_img_path, - final_final_img) - - return final_img_path - - -# if __name__ == '__main__': -# """ Seeding """ -# np.random.seed(42) -# tf.random.set_seed(42) -# -# bg_path = "" -# background_model_path = "weight_files\\model.h5" -# detection_model_path = "weight_files\\clothes_detection_model.pt" -# -# stadium_sport_bg_path = "backgrounds\\camnou_stadium.jpg" -# beach_swim_bg_path = "backgrounds\\beach.jpg" -# office_bg_path = "backgrounds\\office-bg.jpg" -# -# img_path = "images\\truong-van-bang-10163832.jpg" -# -# main(sport_bg_path=stadium_sport_bg_path, swim_bg_path=beach_swim_bg_path, office_bg_path=office_bg_path, name="a", img_path=img_path, detection_model_path=detection_model_path, background_model_path=background_model_path) \ No newline at end of file diff --git a/Background_Removal_and_Change/weight_files/clothes_detection_model.pt b/Background_Removal_and_Change/weight_files/clothes_detection_model.pt deleted file mode 100644 index 5c88c7b8d727b3c3733826d3b563b7e06b582bc4..0000000000000000000000000000000000000000 --- a/Background_Removal_and_Change/weight_files/clothes_detection_model.pt +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2a66f97acde7f676689cf65dd11175becebc2c35167bdbe47d0e610283eaa605 -size 173184733 diff --git a/Background_Removal_and_Change/weight_files/model.h5 b/Background_Removal_and_Change/weight_files/model.h5 deleted file mode 100644 index 3b69efe2c9587edc236e706771089f582d1e147d..0000000000000000000000000000000000000000 --- a/Background_Removal_and_Change/weight_files/model.h5 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:60a1b798e58cd022f78e891e94fa1b1dcbd84ca9d574d43ecfe50b678a31c6d1 -size 215146600