diff --git a/VITON-Extends-Train/data/__pycache__/__init__.cpython-36.pyc b/VITON-Extends-Train/data/__pycache__/__init__.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..750bf5a059fd664facd1b3c1bf312b28fa99bf39
Binary files /dev/null and b/VITON-Extends-Train/data/__pycache__/__init__.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/data/__pycache__/__init__.cpython-37.pyc b/VITON-Extends-Train/data/__pycache__/__init__.cpython-37.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..5b0a9e05358f2199b90bee2b69bd2e4d93c03ba3
Binary files /dev/null and b/VITON-Extends-Train/data/__pycache__/__init__.cpython-37.pyc differ
diff --git a/VITON-Extends-Train/data/__pycache__/base_data_loader.cpython-36.pyc b/VITON-Extends-Train/data/__pycache__/base_data_loader.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..2e002a233c807a095f1493bab003d1b0a6fbdcb2
Binary files /dev/null and b/VITON-Extends-Train/data/__pycache__/base_data_loader.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/data/__pycache__/custom_dataset_data_loader.cpython-36.pyc b/VITON-Extends-Train/data/__pycache__/custom_dataset_data_loader.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..1874d9f8e4987e51b02332232f5430eef3560c3c
Binary files /dev/null and b/VITON-Extends-Train/data/__pycache__/custom_dataset_data_loader.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/data/__pycache__/custom_dataset_data_loader_test.cpython-36.pyc b/VITON-Extends-Train/data/__pycache__/custom_dataset_data_loader_test.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..61ac5f7b8173530180db0948024163cabc3d3bf1
Binary files /dev/null and b/VITON-Extends-Train/data/__pycache__/custom_dataset_data_loader_test.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/data/__pycache__/data_loader.cpython-36.pyc b/VITON-Extends-Train/data/__pycache__/data_loader.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..fb37d9c15f5a633b55cb75b85a4ca10071060af8
Binary files /dev/null and b/VITON-Extends-Train/data/__pycache__/data_loader.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/data/__pycache__/data_loader_test.cpython-36.pyc b/VITON-Extends-Train/data/__pycache__/data_loader_test.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..373681f4ddd1fac8a9fd761ef4447a9d71148180
Binary files /dev/null and b/VITON-Extends-Train/data/__pycache__/data_loader_test.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/data/__pycache__/image_folder.cpython-36.pyc b/VITON-Extends-Train/data/__pycache__/image_folder.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..40a45b999c0d13c732fb9855f4c202c1567788a5
Binary files /dev/null and b/VITON-Extends-Train/data/__pycache__/image_folder.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/data/__pycache__/image_folder.cpython-37.pyc b/VITON-Extends-Train/data/__pycache__/image_folder.cpython-37.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..11311da6a6c8a45429aa4138f29064f669c03ab3
Binary files /dev/null and b/VITON-Extends-Train/data/__pycache__/image_folder.cpython-37.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/__init__.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/__init__.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..465fdaac9087a8cec42554530385727f0d8f4d58
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/__init__.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/__init__.cpython-37.pyc b/VITON-Extends-Train/models/__pycache__/__init__.cpython-37.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..40c5b68aed4f2882583c0cb4c15131492f13c4ea
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/__init__.cpython-37.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/afwm.cpython-37.pyc b/VITON-Extends-Train/models/__pycache__/afwm.cpython-37.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..70e40abe0f7aa35dcf7b16f67616e0f76d3c0758
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/afwm.cpython-37.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/base_model.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/base_model.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..9127e110a78dd69adfbe2ea06801a27c49f37fdb
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/base_model.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/flow_gmm.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/flow_gmm.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..9b80a7aedff75c2dfabe3988c1b9f197bf1c3166
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/flow_gmm.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/flow_gmm_add.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/flow_gmm_add.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..85174ad2ffb67596a4b47eab087688c9faff85a1
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/flow_gmm_add.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/flow_gmm_cor.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..68a5bd4e2aa2f74c860bf3bcd0974de705d449fb
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_add.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_add.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..6c03b757f69cc7feba945f4abe13a925fc8e635e
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_add.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..e5d39894a05a6b6ebf591102f44a4c2eb0ec2753
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_add.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_add.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..37a62f6d21d19f77d3cd4c251d8e188d05c61d74
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_add.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_feat.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_feat.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..df10cbc02f235b3fee454c5fc38b2201e0c3dad2
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_feat.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_grid_offset_sep.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_grid_offset_sep.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..4c05d402b599e71c9571b04fb23f15e41ce4ddc1
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_grid_offset_sep.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_grid_sep.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_grid_sep.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..a4efa920daa2c7829cb698dcec3cc92fc2708219
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_grid_sep.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_new.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_new.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..8fff6c24541e5e143a0f3128651fe74b01fa1e2f
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_new.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_offset.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_offset.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..26d031224168630cd2b7b97a3f5b107baf943c70
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_offset.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_revise.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_revise.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..5b804f2f394b1645bf678f7e76f74519f82c6e0c
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_revise.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_revise_new.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_revise_new.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..38d853f562e9767e295080e09803896ceb034565
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_revise_new.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_revise_new_sep.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_revise_new_sep.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..f6ef0cb7eaf12afd05436f840dda25718734769a
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_revise_new_sep.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_revise_new_sep_all.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_revise_new_sep_all.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..01597f82bc8eebebc9c1d7d3e05ad18259364ca6
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_revise_new_sep_all.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_revise_new_sep_all_more.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_revise_new_sep_all_more.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..d3d2308584a7a67f354b332dfe5c3202e36c69ac
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_revise_new_sep_all_more.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_revise_new_sep_all_more_heatmap.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_revise_new_sep_all_more_heatmap.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..036d85507b8bda0ee328843b7b22c3e966c83b40
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_revise_new_sep_all_more_heatmap.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_revise_new_sep_all_more_no_refine.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_revise_new_sep_all_more_no_refine.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..6bb8a447cba2cec510940d932b6a71160799d081
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_revise_new_sep_all_more_no_refine.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_revise_new_sep_all_more_trans.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_revise_new_sep_all_more_trans.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..03e6272ef16da78a9420e725a0e83c1cda2fa4b7
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_revise_new_sep_all_more_trans.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_sep.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_sep.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..8ffc6edc571aa1421cf07be425352c0176e0efcc
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_more_sep.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_sep.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_sep.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..baceca534d12ca813da92413d5d927456c31251e
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/flow_gmm_cor_sep.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/flow_gmm_smooth.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/flow_gmm_smooth.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..7c5ac3e49dd9dc25251e3fb76f228db2b82562a6
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/flow_gmm_smooth.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/flow_gmm_vis.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/flow_gmm_vis.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..b9e50ac03dc779c851fa74e8eeff4beda8d1588f
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/flow_gmm_vis.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/models.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/models.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..4f80faca3a54a277593777b1540a51ed03ba54a2
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/models.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/networks.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/networks.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..a2d2a000256bbcc0a194ab21912f28570d7bc264
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/networks.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/networks.cpython-37.pyc b/VITON-Extends-Train/models/__pycache__/networks.cpython-37.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..1e896fc46a2985bc546457f5cb2ce9e78d34bf55
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/networks.cpython-37.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/networks_flow.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/networks_flow.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..8eec01bca5ad2ac84b8a71666e45fc769b7b5d2a
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/networks_flow.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/pix2pixHD_model.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/pix2pixHD_model.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..9ae54fa9b3f8d389d3e6f48a4c9355b974bba12d
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/pix2pixHD_model.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/__pycache__/predict_mask.cpython-36.pyc b/VITON-Extends-Train/models/__pycache__/predict_mask.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..70ffddf0900e9a31ef849717d055a69b26934bb4
Binary files /dev/null and b/VITON-Extends-Train/models/__pycache__/predict_mask.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/correlation/README.md b/VITON-Extends-Train/models/correlation/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..a8e0ca529d50b7e09d521cc288daae7771514188
--- /dev/null
+++ b/VITON-Extends-Train/models/correlation/README.md
@@ -0,0 +1 @@
+This is an adaptation of the FlowNet2 implementation in order to compute cost volumes. Should you be making use of this work, please make sure to adhere to the licensing terms of the original authors. Should you be making use or modify this particular implementation, please acknowledge it appropriately.
\ No newline at end of file
diff --git a/VITON-Extends-Train/models/correlation/__pycache__/correlation.cpython-36.pyc b/VITON-Extends-Train/models/correlation/__pycache__/correlation.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..d58aede358fff8fe431f866104e5afc545c58464
Binary files /dev/null and b/VITON-Extends-Train/models/correlation/__pycache__/correlation.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/models/correlation/__pycache__/correlation.cpython-37.pyc b/VITON-Extends-Train/models/correlation/__pycache__/correlation.cpython-37.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..4e2091355fdabde848b84e356816dcce4ee85ec5
Binary files /dev/null and b/VITON-Extends-Train/models/correlation/__pycache__/correlation.cpython-37.pyc differ
diff --git a/VITON-Extends-Train/models/correlation/correlation.py b/VITON-Extends-Train/models/correlation/correlation.py
new file mode 100644
index 0000000000000000000000000000000000000000..2268bc427a0119952e44151af383ac6c61b12222
--- /dev/null
+++ b/VITON-Extends-Train/models/correlation/correlation.py
@@ -0,0 +1,405 @@
+#!/usr/bin/env python
+
+import torch
+
+import cupy
+import math
+import re
+
+kernel_Correlation_rearrange = '''
+ extern "C" __global__ void kernel_Correlation_rearrange(
+ const int n,
+ const float* input,
+ float* output
+ ) {
+ int intIndex = (blockIdx.x * blockDim.x) + threadIdx.x;
+
+ if (intIndex >= n) {
+ return;
+ }
+
+ int intSample = blockIdx.z;
+ int intChannel = blockIdx.y;
+
+ float fltValue = input[(((intSample * SIZE_1(input)) + intChannel) * SIZE_2(input) * SIZE_3(input)) + intIndex];
+
+ __syncthreads();
+
+ int intPaddedY = (intIndex / SIZE_3(input)) + 3*{{intStride}};
+ int intPaddedX = (intIndex % SIZE_3(input)) + 3*{{intStride}};
+ int intRearrange = ((SIZE_3(input) + 6*{{intStride}}) * intPaddedY) + intPaddedX;
+
+ output[(((intSample * SIZE_1(output) * SIZE_2(output)) + intRearrange) * SIZE_1(input)) + intChannel] = fltValue;
+ }
+'''
+
+kernel_Correlation_updateOutput = '''
+ extern "C" __global__ void kernel_Correlation_updateOutput(
+ const int n,
+ const float* rbot0,
+ const float* rbot1,
+ float* top
+ ) {
+ extern __shared__ char patch_data_char[];
+
+ float *patch_data = (float *)patch_data_char;
+
+ // First (upper left) position of kernel upper-left corner in current center position of neighborhood in image 1
+ int x1 = (blockIdx.x + 3) * {{intStride}};
+ int y1 = (blockIdx.y + 3) * {{intStride}};
+ int item = blockIdx.z;
+ int ch_off = threadIdx.x;
+
+ // Load 3D patch into shared shared memory
+ for (int j = 0; j < 1; j++) { // HEIGHT
+ for (int i = 0; i < 1; i++) { // WIDTH
+ int ji_off = (j + i) * SIZE_3(rbot0);
+ for (int ch = ch_off; ch < SIZE_3(rbot0); ch += 32) { // CHANNELS
+ int idx1 = ((item * SIZE_1(rbot0) + y1+j) * SIZE_2(rbot0) + x1+i) * SIZE_3(rbot0) + ch;
+ int idxPatchData = ji_off + ch;
+ patch_data[idxPatchData] = rbot0[idx1];
+ }
+ }
+ }
+
+ __syncthreads();
+
+ __shared__ float sum[32];
+
+ // Compute correlation
+ for (int top_channel = 0; top_channel < SIZE_1(top); top_channel++) {
+ sum[ch_off] = 0;
+
+ int s2o = (top_channel % 7 - 3) * {{intStride}};
+ int s2p = (top_channel / 7 - 3) * {{intStride}};
+
+ for (int j = 0; j < 1; j++) { // HEIGHT
+ for (int i = 0; i < 1; i++) { // WIDTH
+ int ji_off = (j + i) * SIZE_3(rbot0);
+ for (int ch = ch_off; ch < SIZE_3(rbot0); ch += 32) { // CHANNELS
+ int x2 = x1 + s2o;
+ int y2 = y1 + s2p;
+
+ int idxPatchData = ji_off + ch;
+ int idx2 = ((item * SIZE_1(rbot0) + y2+j) * SIZE_2(rbot0) + x2+i) * SIZE_3(rbot0) + ch;
+
+ sum[ch_off] += patch_data[idxPatchData] * rbot1[idx2];
+ }
+ }
+ }
+
+ __syncthreads();
+
+ if (ch_off == 0) {
+ float total_sum = 0;
+ for (int idx = 0; idx < 32; idx++) {
+ total_sum += sum[idx];
+ }
+ const int sumelems = SIZE_3(rbot0);
+ const int index = ((top_channel*SIZE_2(top) + blockIdx.y)*SIZE_3(top))+blockIdx.x;
+ top[index + item*SIZE_1(top)*SIZE_2(top)*SIZE_3(top)] = total_sum / (float)sumelems;
+ }
+ }
+ }
+'''
+
+kernel_Correlation_updateGradFirst = '''
+ #define ROUND_OFF 50000
+
+ extern "C" __global__ void kernel_Correlation_updateGradFirst(
+ const int n,
+ const int intSample,
+ const float* rbot0,
+ const float* rbot1,
+ const float* gradOutput,
+ float* gradFirst,
+ float* gradSecond
+ ) { for (int intIndex = (blockIdx.x * blockDim.x) + threadIdx.x; intIndex < n; intIndex += blockDim.x * gridDim.x) {
+ int n = intIndex % SIZE_1(gradFirst); // channels
+ int l = (intIndex / SIZE_1(gradFirst)) % SIZE_3(gradFirst) + 3*{{intStride}}; // w-pos
+ int m = (intIndex / SIZE_1(gradFirst) / SIZE_3(gradFirst)) % SIZE_2(gradFirst) + 3*{{intStride}}; // h-pos
+
+ // round_off is a trick to enable integer division with ceil, even for negative numbers
+ // We use a large offset, for the inner part not to become negative.
+ const int round_off = ROUND_OFF;
+ const int round_off_s1 = {{intStride}} * round_off;
+
+ // We add round_off before_s1 the int division and subtract round_off after it, to ensure the formula matches ceil behavior:
+ int xmin = (l - 3*{{intStride}} + round_off_s1 - 1) / {{intStride}} + 1 - round_off; // ceil (l - 3*{{intStride}}) / {{intStride}}
+ int ymin = (m - 3*{{intStride}} + round_off_s1 - 1) / {{intStride}} + 1 - round_off; // ceil (l - 3*{{intStride}}) / {{intStride}}
+
+ // Same here:
+ int xmax = (l - 3*{{intStride}} + round_off_s1) / {{intStride}} - round_off; // floor (l - 3*{{intStride}}) / {{intStride}}
+ int ymax = (m - 3*{{intStride}} + round_off_s1) / {{intStride}} - round_off; // floor (m - 3*{{intStride}}) / {{intStride}}
+
+ float sum = 0;
+ if (xmax>=0 && ymax>=0 && (xmin<=SIZE_3(gradOutput)-1) && (ymin<=SIZE_2(gradOutput)-1)) {
+ xmin = max(0,xmin);
+ xmax = min(SIZE_3(gradOutput)-1,xmax);
+
+ ymin = max(0,ymin);
+ ymax = min(SIZE_2(gradOutput)-1,ymax);
+
+ for (int p = -3; p <= 3; p++) {
+ for (int o = -3; o <= 3; o++) {
+ // Get rbot1 data:
+ int s2o = {{intStride}} * o;
+ int s2p = {{intStride}} * p;
+ int idxbot1 = ((intSample * SIZE_1(rbot0) + (m+s2p)) * SIZE_2(rbot0) + (l+s2o)) * SIZE_3(rbot0) + n;
+ float bot1tmp = rbot1[idxbot1]; // rbot1[l+s2o,m+s2p,n]
+
+ // Index offset for gradOutput in following loops:
+ int op = (p+3) * 7 + (o+3); // index[o,p]
+ int idxopoffset = (intSample * SIZE_1(gradOutput) + op);
+
+ for (int y = ymin; y <= ymax; y++) {
+ for (int x = xmin; x <= xmax; x++) {
+ int idxgradOutput = (idxopoffset * SIZE_2(gradOutput) + y) * SIZE_3(gradOutput) + x; // gradOutput[x,y,o,p]
+ sum += gradOutput[idxgradOutput] * bot1tmp;
+ }
+ }
+ }
+ }
+ }
+ const int sumelems = SIZE_1(gradFirst);
+ const int bot0index = ((n * SIZE_2(gradFirst)) + (m-3*{{intStride}})) * SIZE_3(gradFirst) + (l-3*{{intStride}});
+ gradFirst[bot0index + intSample*SIZE_1(gradFirst)*SIZE_2(gradFirst)*SIZE_3(gradFirst)] = sum / (float)sumelems;
+ } }
+'''
+
+kernel_Correlation_updateGradSecond = '''
+ #define ROUND_OFF 50000
+
+ extern "C" __global__ void kernel_Correlation_updateGradSecond(
+ const int n,
+ const int intSample,
+ const float* rbot0,
+ const float* rbot1,
+ const float* gradOutput,
+ float* gradFirst,
+ float* gradSecond
+ ) { for (int intIndex = (blockIdx.x * blockDim.x) + threadIdx.x; intIndex < n; intIndex += blockDim.x * gridDim.x) {
+ int n = intIndex % SIZE_1(gradSecond); // channels
+ int l = (intIndex / SIZE_1(gradSecond)) % SIZE_3(gradSecond) + 3*{{intStride}}; // w-pos
+ int m = (intIndex / SIZE_1(gradSecond) / SIZE_3(gradSecond)) % SIZE_2(gradSecond) + 3*{{intStride}}; // h-pos
+
+ // round_off is a trick to enable integer division with ceil, even for negative numbers
+ // We use a large offset, for the inner part not to become negative.
+ const int round_off = ROUND_OFF;
+ const int round_off_s1 = {{intStride}} * round_off;
+
+ float sum = 0;
+ for (int p = -3; p <= 3; p++) {
+ for (int o = -3; o <= 3; o++) {
+ int s2o = {{intStride}} * o;
+ int s2p = {{intStride}} * p;
+
+ //Get X,Y ranges and clamp
+ // We add round_off before_s1 the int division and subtract round_off after it, to ensure the formula matches ceil behavior:
+ int xmin = (l - 3*{{intStride}} - s2o + round_off_s1 - 1) / {{intStride}} + 1 - round_off; // ceil (l - 3*{{intStride}} - s2o) / {{intStride}}
+ int ymin = (m - 3*{{intStride}} - s2p + round_off_s1 - 1) / {{intStride}} + 1 - round_off; // ceil (l - 3*{{intStride}} - s2o) / {{intStride}}
+
+ // Same here:
+ int xmax = (l - 3*{{intStride}} - s2o + round_off_s1) / {{intStride}} - round_off; // floor (l - 3*{{intStride}} - s2o) / {{intStride}}
+ int ymax = (m - 3*{{intStride}} - s2p + round_off_s1) / {{intStride}} - round_off; // floor (m - 3*{{intStride}} - s2p) / {{intStride}}
+
+ if (xmax>=0 && ymax>=0 && (xmin<=SIZE_3(gradOutput)-1) && (ymin<=SIZE_2(gradOutput)-1)) {
+ xmin = max(0,xmin);
+ xmax = min(SIZE_3(gradOutput)-1,xmax);
+
+ ymin = max(0,ymin);
+ ymax = min(SIZE_2(gradOutput)-1,ymax);
+
+ // Get rbot0 data:
+ int idxbot0 = ((intSample * SIZE_1(rbot0) + (m-s2p)) * SIZE_2(rbot0) + (l-s2o)) * SIZE_3(rbot0) + n;
+ float bot0tmp = rbot0[idxbot0]; // rbot1[l+s2o,m+s2p,n]
+
+ // Index offset for gradOutput in following loops:
+ int op = (p+3) * 7 + (o+3); // index[o,p]
+ int idxopoffset = (intSample * SIZE_1(gradOutput) + op);
+
+ for (int y = ymin; y <= ymax; y++) {
+ for (int x = xmin; x <= xmax; x++) {
+ int idxgradOutput = (idxopoffset * SIZE_2(gradOutput) + y) * SIZE_3(gradOutput) + x; // gradOutput[x,y,o,p]
+ sum += gradOutput[idxgradOutput] * bot0tmp;
+ }
+ }
+ }
+ }
+ }
+ const int sumelems = SIZE_1(gradSecond);
+ const int bot1index = ((n * SIZE_2(gradSecond)) + (m-3*{{intStride}})) * SIZE_3(gradSecond) + (l-3*{{intStride}});
+ gradSecond[bot1index + intSample*SIZE_1(gradSecond)*SIZE_2(gradSecond)*SIZE_3(gradSecond)] = sum / (float)sumelems;
+ } }
+'''
+
+def cupy_kernel(strFunction, objVariables):
+ strKernel = globals()[strFunction].replace('{{intStride}}', str(objVariables['intStride']))
+
+ while True:
+ objMatch = re.search('(SIZE_)([0-4])(\()([^\)]*)(\))', strKernel)
+
+ if objMatch is None:
+ break
+ # end
+
+ intArg = int(objMatch.group(2))
+
+ strTensor = objMatch.group(4)
+ intSizes = objVariables[strTensor].size()
+
+ strKernel = strKernel.replace(objMatch.group(), str(intSizes[intArg]))
+ # end
+
+ while True:
+ objMatch = re.search('(VALUE_)([0-4])(\()([^\)]+)(\))', strKernel)
+
+ if objMatch is None:
+ break
+ # end
+
+ intArgs = int(objMatch.group(2))
+ strArgs = objMatch.group(4).split(',')
+
+ strTensor = strArgs[0]
+ intStrides = objVariables[strTensor].stride()
+ strIndex = [ '((' + strArgs[intArg + 1].replace('{', '(').replace('}', ')').strip() + ')*' + str(intStrides[intArg]) + ')' for intArg in range(intArgs) ]
+
+ strKernel = strKernel.replace(objMatch.group(0), strTensor + '[' + str.join('+', strIndex) + ']')
+ # end
+
+ return strKernel
+# end
+
+@cupy.util.memoize(for_each_device=True)
+def cupy_launch(strFunction, strKernel):
+ return cupy.cuda.compile_with_cache(strKernel).get_function(strFunction)
+# end
+
+class _FunctionCorrelation(torch.autograd.Function):
+ @staticmethod
+ def forward(self, first, second, intStride):
+ rbot0 = first.new_zeros([ first.shape[0], first.shape[2] + (6 * intStride), first.shape[3] + (6 * intStride), first.shape[1] ])
+ rbot1 = first.new_zeros([ first.shape[0], first.shape[2] + (6 * intStride), first.shape[3] + (6 * intStride), first.shape[1] ])
+
+ self.save_for_backward(first, second, rbot0, rbot1)
+
+ self.intStride = intStride
+
+ assert(first.is_contiguous() == True)
+ assert(second.is_contiguous() == True)
+
+ output = first.new_zeros([ first.shape[0], 49, int(math.ceil(first.shape[2] / intStride)), int(math.ceil(first.shape[3] / intStride)) ])
+
+ if first.is_cuda == True:
+ n = first.shape[2] * first.shape[3]
+ cupy_launch('kernel_Correlation_rearrange', cupy_kernel('kernel_Correlation_rearrange', {
+ 'intStride': self.intStride,
+ 'input': first,
+ 'output': rbot0
+ }))(
+ grid=tuple([ int((n + 16 - 1) / 16), first.shape[1], first.shape[0] ]),
+ block=tuple([ 16, 1, 1 ]),
+ args=[ n, first.data_ptr(), rbot0.data_ptr() ]
+ )
+
+ n = second.shape[2] * second.shape[3]
+ cupy_launch('kernel_Correlation_rearrange', cupy_kernel('kernel_Correlation_rearrange', {
+ 'intStride': self.intStride,
+ 'input': second,
+ 'output': rbot1
+ }))(
+ grid=tuple([ int((n + 16 - 1) / 16), second.shape[1], second.shape[0] ]),
+ block=tuple([ 16, 1, 1 ]),
+ args=[ n, second.data_ptr(), rbot1.data_ptr() ]
+ )
+
+ n = output.shape[1] * output.shape[2] * output.shape[3]
+ cupy_launch('kernel_Correlation_updateOutput', cupy_kernel('kernel_Correlation_updateOutput', {
+ 'intStride': self.intStride,
+ 'rbot0': rbot0,
+ 'rbot1': rbot1,
+ 'top': output
+ }))(
+ grid=tuple([ output.shape[3], output.shape[2], output.shape[0] ]),
+ block=tuple([ 32, 1, 1 ]),
+ shared_mem=first.shape[1] * 4,
+ args=[ n, rbot0.data_ptr(), rbot1.data_ptr(), output.data_ptr() ]
+ )
+
+ elif first.is_cuda == False:
+ raise NotImplementedError()
+
+ # end
+
+ return output
+ # end
+
+ @staticmethod
+ def backward(self, gradOutput):
+ first, second, rbot0, rbot1 = self.saved_tensors
+
+ assert(gradOutput.is_contiguous() == True)
+
+ gradFirst = first.new_zeros([ first.shape[0], first.shape[1], first.shape[2], first.shape[3] ]) if self.needs_input_grad[0] == True else None
+ gradSecond = first.new_zeros([ first.shape[0], first.shape[1], first.shape[2], first.shape[3] ]) if self.needs_input_grad[1] == True else None
+
+ if first.is_cuda == True:
+ if gradFirst is not None:
+ for intSample in range(first.shape[0]):
+ n = first.shape[1] * first.shape[2] * first.shape[3]
+ cupy_launch('kernel_Correlation_updateGradFirst', cupy_kernel('kernel_Correlation_updateGradFirst', {
+ 'intStride': self.intStride,
+ 'rbot0': rbot0,
+ 'rbot1': rbot1,
+ 'gradOutput': gradOutput,
+ 'gradFirst': gradFirst,
+ 'gradSecond': None
+ }))(
+ grid=tuple([ int((n + 512 - 1) / 512), 1, 1 ]),
+ block=tuple([ 512, 1, 1 ]),
+ args=[ n, intSample, rbot0.data_ptr(), rbot1.data_ptr(), gradOutput.data_ptr(), gradFirst.data_ptr(), None ]
+ )
+ # end
+ # end
+
+ if gradSecond is not None:
+ for intSample in range(first.shape[0]):
+ n = first.shape[1] * first.shape[2] * first.shape[3]
+ cupy_launch('kernel_Correlation_updateGradSecond', cupy_kernel('kernel_Correlation_updateGradSecond', {
+ 'intStride': self.intStride,
+ 'rbot0': rbot0,
+ 'rbot1': rbot1,
+ 'gradOutput': gradOutput,
+ 'gradFirst': None,
+ 'gradSecond': gradSecond
+ }))(
+ grid=tuple([ int((n + 512 - 1) / 512), 1, 1 ]),
+ block=tuple([ 512, 1, 1 ]),
+ args=[ n, intSample, rbot0.data_ptr(), rbot1.data_ptr(), gradOutput.data_ptr(), None, gradSecond.data_ptr() ]
+ )
+ # end
+ # end
+
+ elif first.is_cuda == False:
+ raise NotImplementedError()
+
+ # end
+
+ return gradFirst, gradSecond, None
+ # end
+# end
+
+def FunctionCorrelation(tenFirst, tenSecond, intStride):
+ return _FunctionCorrelation.apply(tenFirst, tenSecond, intStride)
+# end
+
+class ModuleCorrelation(torch.nn.Module):
+ def __init__(self):
+ super(ModuleCorrelation, self).__init__()
+ # end
+
+ def forward(self, tenFirst, tenSecond, intStride):
+ return _FunctionCorrelation.apply(tenFirst, tenSecond, intStride)
+ # end
+# end
\ No newline at end of file
diff --git a/VITON-Extends-Train/options/__pycache__/__init__.cpython-36.pyc b/VITON-Extends-Train/options/__pycache__/__init__.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..542f32a9faa6d1ea52543787cc5db88758debe2f
Binary files /dev/null and b/VITON-Extends-Train/options/__pycache__/__init__.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/options/__pycache__/__init__.cpython-37.pyc b/VITON-Extends-Train/options/__pycache__/__init__.cpython-37.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..dba454f30ae4da91a2233f30fe94113af7b47bdf
Binary files /dev/null and b/VITON-Extends-Train/options/__pycache__/__init__.cpython-37.pyc differ
diff --git a/VITON-Extends-Train/options/__pycache__/base_options.cpython-36.pyc b/VITON-Extends-Train/options/__pycache__/base_options.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..413777935aaa9ca326573fe8cd041719b404c009
Binary files /dev/null and b/VITON-Extends-Train/options/__pycache__/base_options.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/options/__pycache__/base_options.cpython-37.pyc b/VITON-Extends-Train/options/__pycache__/base_options.cpython-37.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..88afa1737c19e58b23ed879b5178db61ffeb68fe
Binary files /dev/null and b/VITON-Extends-Train/options/__pycache__/base_options.cpython-37.pyc differ
diff --git a/VITON-Extends-Train/options/__pycache__/test_options.cpython-36.pyc b/VITON-Extends-Train/options/__pycache__/test_options.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..9f048aec72270b9c72b07e5ce76b73498efaaeaf
Binary files /dev/null and b/VITON-Extends-Train/options/__pycache__/test_options.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/options/__pycache__/train_options.cpython-36.pyc b/VITON-Extends-Train/options/__pycache__/train_options.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..68baf84005e3919467a0dd1695a663bfda2617ac
Binary files /dev/null and b/VITON-Extends-Train/options/__pycache__/train_options.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/options/__pycache__/train_options.cpython-37.pyc b/VITON-Extends-Train/options/__pycache__/train_options.cpython-37.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..e775ce5c79b5b1472c2322eb42b0886b6e62c5e9
Binary files /dev/null and b/VITON-Extends-Train/options/__pycache__/train_options.cpython-37.pyc differ
diff --git a/VITON-Extends-Train/util/__pycache__/__init__.cpython-36.pyc b/VITON-Extends-Train/util/__pycache__/__init__.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..c2158e2ca05b9375d40c268e41eb095b65f8f453
Binary files /dev/null and b/VITON-Extends-Train/util/__pycache__/__init__.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/util/__pycache__/__init__.cpython-37.pyc b/VITON-Extends-Train/util/__pycache__/__init__.cpython-37.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..9363ffbb56f3c2dc1b0b7014dc02f3f9978d5fb8
Binary files /dev/null and b/VITON-Extends-Train/util/__pycache__/__init__.cpython-37.pyc differ
diff --git a/VITON-Extends-Train/util/__pycache__/image_pool.cpython-36.pyc b/VITON-Extends-Train/util/__pycache__/image_pool.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..0b81fdeb186a11e340d2823c8a1817bc234e01d8
Binary files /dev/null and b/VITON-Extends-Train/util/__pycache__/image_pool.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/util/__pycache__/util.cpython-36.pyc b/VITON-Extends-Train/util/__pycache__/util.cpython-36.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..6396a7b877d36a4cc87887d8a4cc8c711fb959a3
Binary files /dev/null and b/VITON-Extends-Train/util/__pycache__/util.cpython-36.pyc differ
diff --git a/VITON-Extends-Train/util/__pycache__/util.cpython-37.pyc b/VITON-Extends-Train/util/__pycache__/util.cpython-37.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..818ba45379f9e52947fe1ecddf0970693482d7c6
Binary files /dev/null and b/VITON-Extends-Train/util/__pycache__/util.cpython-37.pyc differ
diff --git a/VITON-Extends_test/app/globals.css b/VITON-Extends_test/app/globals.css
new file mode 100644
index 0000000000000000000000000000000000000000..20c923782c4d477e06ccb543b687ec65288183f1
--- /dev/null
+++ b/VITON-Extends_test/app/globals.css
@@ -0,0 +1,108 @@
+@tailwind base;
+@tailwind components;
+@tailwind utilities;
+
+@layer base {
+ :root {
+ --background: 0 0% 100%;
+ --foreground: 222.2 84% 4.9%;
+
+ --card: 0 0% 100%;
+ --card-foreground: 222.2 84% 4.9%;
+
+ --popover: 0 0% 100%;
+ --popover-foreground: 222.2 84% 4.9%;
+
+ --primary: 271 81% 56%;
+ --primary-foreground: 210 40% 98%;
+
+ --secondary: 210 40% 96.1%;
+ --secondary-foreground: 222.2 47.4% 11.2%;
+
+ --muted: 210 40% 96.1%;
+ --muted-foreground: 215.4 16.3% 46.9%;
+
+ --accent: 210 40% 96.1%;
+ --accent-foreground: 222.2 47.4% 11.2%;
+
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 210 40% 98%;
+
+ --border: 214.3 31.8% 91.4%;
+ --input: 214.3 31.8% 91.4%;
+ --ring: 271 81% 56%;
+
+ --radius: 0.5rem;
+ }
+
+ .dark {
+ --background: 0 0% 0%;
+ --foreground: 210 40% 98%;
+
+ --card: 0 0% 5%;
+ --card-foreground: 210 40% 98%;
+
+ --popover: 0 0% 0%;
+ --popover-foreground: 210 40% 98%;
+
+ --primary: 271 81% 56%;
+ --primary-foreground: 222.2 47.4% 11.2%;
+
+ --secondary: 0 0% 10%;
+ --secondary-foreground: 210 40% 98%;
+
+ --muted: 0 0% 10%;
+ --muted-foreground: 215 20.2% 65.1%;
+
+ --accent: 0 0% 15%;
+ --accent-foreground: 210 40% 98%;
+
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 210 40% 98%;
+
+ --border: 0 0% 15%;
+ --input: 0 0% 15%;
+ --ring: 271 81% 56%;
+ }
+}
+
+@layer base {
+ * {
+ @apply border-border;
+ }
+ body {
+ @apply bg-background text-foreground;
+ }
+}
+
+@keyframes sparkle {
+ 0%,
+ 100% {
+ opacity: 0;
+ transform: scale(0);
+ }
+ 50% {
+ opacity: 1;
+ transform: scale(1);
+ }
+}
+
+@keyframes float {
+ 0%,
+ 100% {
+ transform: translateY(0) rotate(0deg);
+ }
+ 50% {
+ transform: translateY(-20px) rotate(10deg);
+ }
+}
+
+@keyframes pulse {
+ 0%,
+ 100% {
+ opacity: 0.5;
+ }
+ 50% {
+ opacity: 1;
+ }
+}
diff --git a/VITON-Extends_test/app/layout.tsx b/VITON-Extends_test/app/layout.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..65b0e642ad6885e124252ae263d794012f0cbf4a
--- /dev/null
+++ b/VITON-Extends_test/app/layout.tsx
@@ -0,0 +1,28 @@
+import type React from "react"
+import "./globals.css"
+import { Inter } from "next/font/google"
+import { ThemeProvider } from "@/components/theme-provider"
+
+const inter = Inter({ subsets: ["latin"] })
+
+export const metadata = {
+ title: "MiRRA - Style in Sight",
+ description: "Virtual try-on and smart stylist for fashion lovers",
+ generator: 'v0.dev'
+}
+
+export default function RootLayout({
+ children,
+}: {
+ children: React.ReactNode
+}) {
+ return (
+
+
+
+ {children}
+
+
+
+ )
+}
diff --git a/VITON-Extends_test/app/page.tsx b/VITON-Extends_test/app/page.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..c5892d36b997e3801d8b259ab399cbf8a2791cac
--- /dev/null
+++ b/VITON-Extends_test/app/page.tsx
@@ -0,0 +1,908 @@
+"use client"
+
+import { useState, useRef, useEffect } from "react"
+import Image from "next/image"
+import { motion, useScroll, useTransform } from "framer-motion"
+import { Button } from "@/components/ui/button"
+import { Input } from "@/components/ui/input"
+import { Textarea } from "@/components/ui/textarea"
+import { Card } from "@/components/ui/card"
+import { Camera, Upload, MessageSquare, ChevronRight, ChevronLeft, Send, ArrowRight } from "lucide-react"
+
+// Sparkle component
+const Sparkle = ({ size = "sm", color = "white", delay = 0, duration = 2, className = "" }) => {
+ const sizeMap = {
+ xs: "w-1 h-1",
+ sm: "w-1.5 h-1.5",
+ md: "w-2 h-2",
+ lg: "w-3 h-3",
+ }
+
+ const colorMap = {
+ white: "bg-white",
+ purple: "bg-purple-400",
+ pink: "bg-pink-400",
+ blue: "bg-blue-400",
+ }
+
+ return (
+
+ )
+}
+
+// Animation variants
+const fadeIn = {
+ hidden: { opacity: 0, y: 40 },
+ visible: {
+ opacity: 1,
+ y: 0,
+ transition: { duration: 0.8, ease: "easeOut" },
+ },
+}
+
+const fadeInLeft = {
+ hidden: { opacity: 0, x: -60 },
+ visible: {
+ opacity: 1,
+ x: 0,
+ transition: { duration: 0.8, ease: "easeOut" },
+ },
+}
+
+const fadeInRight = {
+ hidden: { opacity: 0, x: 60 },
+ visible: {
+ opacity: 1,
+ x: 0,
+ transition: { duration: 0.8, ease: "easeOut" },
+ },
+}
+
+const staggerContainer = {
+ hidden: { opacity: 0 },
+ visible: {
+ opacity: 1,
+ transition: {
+ staggerChildren: 0.3,
+ },
+ },
+}
+
+export default function Home() {
+ const [activeSlide, setActiveSlide] = useState(0)
+ const [messages, setMessages] = useState([
+ { text: "Hi there! I'm your smart stylist. What's your style preference today?", sender: "bot" },
+ ])
+ const [messageInput, setMessageInput] = useState("")
+
+ const featuresRef = useRef(null)
+ const tryOnRef = useRef(null)
+ const stylistRef = useRef(null)
+ const shopRef = useRef(null)
+ const contactRef = useRef(null)
+ const carouselRef = useRef(null)
+
+ const { scrollYProgress: featuresScrollProgress } = useScroll({
+ target: featuresRef,
+ offset: ["start end", "end start"],
+ })
+
+ const { scrollYProgress: tryOnScrollProgress } = useScroll({
+ target: tryOnRef,
+ offset: ["start end", "end start"],
+ })
+
+ const { scrollYProgress: stylistScrollProgress } = useScroll({
+ target: stylistRef,
+ offset: ["start end", "end start"],
+ })
+
+ const { scrollYProgress: shopScrollProgress } = useScroll({
+ target: shopRef,
+ offset: ["start end", "end start"],
+ })
+
+ const { scrollYProgress: contactScrollProgress } = useScroll({
+ target: contactRef,
+ offset: ["start end", "end start"],
+ })
+
+ const featuresOpacity = useTransform(featuresScrollProgress, [0, 0.3, 0.7, 1], [0, 1, 1, 0])
+ const featuresY = useTransform(featuresScrollProgress, [0, 0.3, 0.7, 1], [100, 0, 0, 100])
+
+ const tryOnOpacity = useTransform(tryOnScrollProgress, [0, 0.3, 0.7, 1], [0, 1, 1, 0])
+ const tryOnY = useTransform(tryOnScrollProgress, [0, 0.3, 0.7, 1], [100, 0, 0, 100])
+
+ const stylistOpacity = useTransform(stylistScrollProgress, [0, 0.3, 0.7, 1], [0, 1, 1, 0])
+ const stylistY = useTransform(stylistScrollProgress, [0, 0.3, 0.7, 1], [100, 0, 0, 100])
+
+ const shopOpacity = useTransform(shopScrollProgress, [0, 0.3, 0.7, 1], [0, 1, 1, 0])
+ const shopY = useTransform(shopScrollProgress, [0, 0.3, 0.7, 1], [100, 0, 0, 100])
+
+ const contactOpacity = useTransform(contactScrollProgress, [0, 0.3, 0.7, 1], [0, 1, 1, 0])
+ const contactY = useTransform(contactScrollProgress, [0, 0.3, 0.7, 1], [100, 0, 0, 100])
+
+ const products = [
+ { id: 1, name: "Summer Dress", price: "$49.99", image: "/placeholder.svg?height=300&width=300" },
+ { id: 2, name: "Casual Jeans", price: "$39.99", image: "/placeholder.svg?height=300&width=300" },
+ { id: 3, name: "Elegant Blouse", price: "$29.99", image: "/placeholder.svg?height=300&width=300" },
+ { id: 4, name: "Formal Suit", price: "$99.99", image: "/placeholder.svg?height=300&width=300" },
+ { id: 5, name: "Winter Coat", price: "$79.99", image: "/placeholder.svg?height=300&width=300" },
+ ]
+
+ const recommendedItems = [
+ { id: 1, name: "Striped T-Shirt", price: "$24.99", image: "/placeholder.svg?height=150&width=150" },
+ { id: 2, name: "Denim Jacket", price: "$59.99", image: "/placeholder.svg?height=150&width=150" },
+ { id: 3, name: "Black Pants", price: "$34.99", image: "/placeholder.svg?height=150&width=150" },
+ ]
+
+ // Auto-scroll carousel
+ useEffect(() => {
+ const interval = setInterval(() => {
+ setActiveSlide((prev) => (prev === products.length - 1 ? 0 : prev + 1))
+ }, 3000)
+
+ return () => clearInterval(interval)
+ }, [products.length])
+
+ const nextSlide = () => {
+ setActiveSlide((prev) => (prev === products.length - 1 ? 0 : prev + 1))
+ }
+
+ const prevSlide = () => {
+ setActiveSlide((prev) => (prev === 0 ? products.length - 1 : prev - 1))
+ }
+
+ const sendMessage = () => {
+ if (messageInput.trim()) {
+ setMessages([...messages, { text: messageInput, sender: "user" }])
+
+ // Simulate bot response
+ setTimeout(() => {
+ setMessages((prev) => [
+ ...prev,
+ {
+ text: "Based on your style, I recommend checking out our new collection of casual wear. Here are some items that might interest you.",
+ sender: "bot",
+ },
+ ])
+ }, 1000)
+
+ setMessageInput("")
+ }
+ }
+
+ const scrollToSection = (ref) => {
+ ref.current.scrollIntoView({ behavior: "smooth" })
+ }
+
+ return (
+
+ {/* Hero Section */}
+
+
+
+ {/* Sparkle effects */}
+
+ {/* Large sparkles */}
+ {[...Array(20)].map((_, i) => (
+ 0.7 ? "lg" : Math.random() > 0.5 ? "md" : "sm"}
+ color={Math.random() > 0.7 ? "white" : Math.random() > 0.5 ? "purple" : "pink"}
+ delay={Math.random() * 5}
+ duration={Math.random() * 2 + 1.5}
+ />
+ ))}
+
+ {/* Floating light particles */}
+ {[...Array(30)].map((_, i) => (
+
+ ))}
+
+ {/* Glowing orbs */}
+ {[...Array(5)].map((_, i) => (
+
+ ))}
+
+
+
+
+
+ MiRRA
+
+
+ {/* Logo sparkles */}
+ {[...Array(8)].map((_, i) => (
+
+ ))}
+
+
+ style in sight
+
+
+ scrollToSection(featuresRef)}
+ >
+ Discover More
+
+
+
+
+
+
+
+ {/* Overview Section */}
+
+
+
+ Welcome to MiRRA
+
+
+
+
+
+
+
+
+
+ Redefining Fashion Experience
+
+ MiRRA combines cutting-edge technology with fashion expertise to create a personalized shopping
+ experience. Our platform offers virtual try-on capabilities and AI-powered styling recommendations to
+ help you discover your perfect look without leaving your home.
+
+
+
+
+
+
+
+
Virtual Try-On
+
See how clothes look on you before buying
+
+
+
+
+
+
+
+
+
Smart Stylist
+
AI-powered fashion advice tailored to you
+
+
+
+
+ scrollToSection(tryOnRef)}
+ >
+ Try It Now
+
+
+
+
+
+
+ {/* Virtual Try-On Section */}
+
+
+
+ Virtual Try-On
+
+
+
+
+ Upload Your Photo
+
+ See how our clothes look on you by uploading your photo or using your camera. Our AI will fit the
+ garments to your body shape and size.
+
+
+
+
+ Upload Photo
+
+
+
+ Use Camera
+
+
+
+ Drag and drop your photo here or use the buttons above
+
+
+
+
+
+ Try-On Results
+
+
+
+
+ {[1, 2, 3, 4].map((item) => (
+
+
+
+ ))}
+
+
+
+
+
+
+ {/* Smart Stylist Section */}
+
+
+
+ Smart Stylist
+
+
+
+
+ Chat with Your Personal Stylist
+
+
+ {messages.map((message, index) => (
+
+ ))}
+
+
+
+ setMessageInput(e.target.value)}
+ onKeyPress={(e) => e.key === "Enter" && sendMessage()}
+ className="flex-grow bg-gray-800 border-purple-700 text-white"
+ />
+
+
+
+
+
+
+
+ Recommended for You
+
+ {recommendedItems.map((item) => (
+
+
+
+
{item.name}
+
{item.price}
+
+ View Details
+
+
+
+ ))}
+
+
+
+
+
+
+ {/* Shop Section */}
+
+
+
+ Our Shop
+
+
+
+
+
+ {products.map((product) => (
+
+
+
+
{product.name}
+
+ {product.price}
+
+
+ Add to Cart
+
+
+
+ ))}
+
+
+
+
+
+
+
+
+
+
+
+
+ {products.map((_, index) => (
+ setActiveSlide(index)}
+ />
+ ))}
+
+
+
+
+
+ View All Products
+
+
+
+
+
+ {/* Contact Section */}
+
+
+
+ Contact Us
+
+
+
+
+ Get in Touch
+
+ Have questions about our products or services? We'd love to hear from you. Fill out the form and our
+ team will get back to you as soon as possible.
+
+
+
+
+
+
+
+
+
+
123 Fashion Street, New York, NY 10001
+
+
+
+
+
+
+
+
+
+
+
+ {/* Footer */}
+
+
+
+
+
+ MiRRA
+
+
style in sight
+
+
+
+
+
+
+
© {new Date().getFullYear()} MiRRA. All rights reserved.
+
+
+
+
+ )
+}
diff --git a/VITON-Extends_test/components/theme-provider.tsx b/VITON-Extends_test/components/theme-provider.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..7e42555f315ae1a3aaac8c88afd0370c62a3607b
--- /dev/null
+++ b/VITON-Extends_test/components/theme-provider.tsx
@@ -0,0 +1,11 @@
+'use client'
+
+import * as React from 'react'
+import {
+ ThemeProvider as NextThemesProvider,
+ type ThemeProviderProps,
+} from 'next-themes'
+
+export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
+ return {children}
+}
diff --git a/VITON-Extends_test/data/__init__.py b/VITON-Extends_test/data/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..60c2d13722aa08b7207ba3fb7137376bbf385629
--- /dev/null
+++ b/VITON-Extends_test/data/__init__.py
@@ -0,0 +1 @@
+# data_init
\ No newline at end of file
diff --git a/VITON-Extends_test/data/aligned_dataset_test.py b/VITON-Extends_test/data/aligned_dataset_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..bca563c5c36feabde2f19c5b17c35d0d88d93f89
--- /dev/null
+++ b/VITON-Extends_test/data/aligned_dataset_test.py
@@ -0,0 +1,54 @@
+import os.path
+from data.base_dataset import BaseDataset, get_params, get_transform
+from PIL import Image
+import linecache
+
+class AlignedDataset(BaseDataset):
+ def initialize(self, opt):
+ self.opt = opt
+ self.root = opt.dataroot
+
+ self.fine_height=256
+ self.fine_width=192
+
+ self.dataset_size = len(open('demo.txt').readlines())
+
+ dir_I = '_img'
+ self.dir_I = os.path.join(opt.dataroot, opt.phase + dir_I)
+
+ dir_C = '_clothes'
+ self.dir_C = os.path.join(opt.dataroot, opt.phase + dir_C)
+
+ dir_E = '_edge'
+ self.dir_E = os.path.join(opt.dataroot, opt.phase + dir_E)
+
+ def __getitem__(self, index):
+
+ file_path ='demo.txt'
+ im_name, c_name = linecache.getline(file_path, index+1).strip().split()
+
+ I_path = os.path.join(self.dir_I,im_name)
+ I = Image.open(I_path).convert('RGB')
+
+ params = get_params(self.opt, I.size)
+ transform = get_transform(self.opt, params)
+ transform_E = get_transform(self.opt, params, method=Image.NEAREST, normalize=False)
+
+ I_tensor = transform(I)
+
+ C_path = os.path.join(self.dir_C,c_name)
+ C = Image.open(C_path).convert('RGB')
+ C_tensor = transform(C)
+
+ E_path = os.path.join(self.dir_E,c_name)
+ E = Image.open(E_path).convert('L')
+ E_tensor = transform_E(E)
+
+ input_dict = { 'image': I_tensor,'clothes': C_tensor, 'edge': E_tensor}
+ return input_dict
+
+ def __len__(self):
+ return self.dataset_size
+
+ def name(self):
+ return 'AlignedDataset'
diff --git a/VITON-Extends_test/data/base_data_loader.py b/VITON-Extends_test/data/base_data_loader.py
new file mode 100644
index 0000000000000000000000000000000000000000..5a8ecff39f75b16b89fe2cb8cae54a59fe992590
--- /dev/null
+++ b/VITON-Extends_test/data/base_data_loader.py
@@ -0,0 +1,14 @@
+
+class BaseDataLoader():
+ def __init__(self):
+ pass
+
+ def initialize(self, opt):
+ self.opt = opt
+ pass
+
+ def load_data():
+ return None
+
+
+
diff --git a/VITON-Extends_test/data/base_dataset.py b/VITON-Extends_test/data/base_dataset.py
new file mode 100644
index 0000000000000000000000000000000000000000..90506d5be2178afa30823e0803f0e805d2be43b7
--- /dev/null
+++ b/VITON-Extends_test/data/base_dataset.py
@@ -0,0 +1,113 @@
+import torch.utils.data as data
+from PIL import Image
+import torchvision.transforms as transforms
+import numpy as np
+import random
+
+class BaseDataset(data.Dataset):
+ def __init__(self):
+ super(BaseDataset, self).__init__()
+
+ def name(self):
+ return 'BaseDataset'
+
+ def initialize(self, opt):
+ pass
+
+def get_params(opt, size):
+ w, h = size
+ new_h = h
+ new_w = w
+ if opt.resize_or_crop == 'resize_and_crop':
+ new_h = new_w = opt.loadSize
+ elif opt.resize_or_crop == 'scale_width_and_crop':
+ new_w = opt.loadSize
+ new_h = opt.loadSize * h // w
+
+ x = random.randint(0, np.maximum(0, new_w - opt.fineSize))
+ y = random.randint(0, np.maximum(0, new_h - opt.fineSize))
+
+ flip = 0
+ return {'crop_pos': (x, y), 'flip': flip}
+
+def get_transform_resize(opt, params, method=Image.BICUBIC, normalize=True):
+ transform_list = []
+ transform_list.append(transforms.Lambda(lambda img: __scale_width(img, opt.loadSize, method)))
+ osize = [256,192]
+ transform_list.append(transforms.Scale(osize, method))
+ if 'crop' in opt.resize_or_crop:
+ transform_list.append(transforms.Lambda(lambda img: __crop(img, params['crop_pos'], opt.fineSize)))
+
+ if opt.resize_or_crop == 'none':
+ base = float(2 ** opt.n_downsample_global)
+ if opt.netG == 'local':
+ base *= (2 ** opt.n_local_enhancers)
+ transform_list.append(transforms.Lambda(lambda img: __make_power_2(img, base, method)))
+
+ if opt.isTrain and not opt.no_flip:
+ transform_list.append(transforms.Lambda(lambda img: __flip(img, params['flip'])))
+
+ transform_list += [transforms.ToTensor()]
+
+ if normalize:
+ transform_list += [transforms.Normalize((0.5, 0.5, 0.5),
+ (0.5, 0.5, 0.5))]
+ return transforms.Compose(transform_list)
+
+def get_transform(opt, params, method=Image.BICUBIC, normalize=True):
+ transform_list = []
+ if 'resize' in opt.resize_or_crop:
+ osize = [opt.loadSize, opt.loadSize]
+ transform_list.append(transforms.Scale(osize, method))
+ elif 'scale_width' in opt.resize_or_crop:
+ transform_list.append(transforms.Lambda(lambda img: __scale_width(img, opt.loadSize, method)))
+ osize = [256,192]
+ transform_list.append(transforms.Resize(osize, method))
+ if 'crop' in opt.resize_or_crop:
+ transform_list.append(transforms.Lambda(lambda img: __crop(img, params['crop_pos'], opt.fineSize)))
+
+ if opt.resize_or_crop == 'none':
+ base = float(16)
+ transform_list.append(transforms.Lambda(lambda img: __make_power_2(img, base, method)))
+
+ if opt.isTrain and not opt.no_flip:
+ transform_list.append(transforms.Lambda(lambda img: __flip(img, params['flip'])))
+
+ transform_list += [transforms.ToTensor()]
+
+ if normalize:
+ transform_list += [transforms.Normalize((0.5, 0.5, 0.5),
+ (0.5, 0.5, 0.5))]
+ return transforms.Compose(transform_list)
+
+def normalize():
+ return transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
+
+def __make_power_2(img, base, method=Image.BICUBIC):
+ ow, oh = img.size
+ h = int(round(oh / base) * base)
+ w = int(round(ow / base) * base)
+ if (h == oh) and (w == ow):
+ return img
+ return img.resize((w, h), method)
+
+def __scale_width(img, target_width, method=Image.BICUBIC):
+ ow, oh = img.size
+ if (ow == target_width):
+ return img
+ w = target_width
+ h = int(target_width * oh / ow)
+ return img.resize((w, h), method)
+
+def __crop(img, pos, size):
+ ow, oh = img.size
+ x1, y1 = pos
+ tw = th = size
+ if (ow > tw or oh > th):
+ return img.crop((x1, y1, x1 + tw, y1 + th))
+ return img
+
+def __flip(img, flip):
+ if flip:
+ return img.transpose(Image.FLIP_LEFT_RIGHT)
+ return img
diff --git a/VITON-Extends_test/data/custom_dataset_data_loader_test.py b/VITON-Extends_test/data/custom_dataset_data_loader_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..57f906339acb240cda1ead0046248726e7813451
--- /dev/null
+++ b/VITON-Extends_test/data/custom_dataset_data_loader_test.py
@@ -0,0 +1,31 @@
+import torch.utils.data
+from data.base_data_loader import BaseDataLoader
+
+
+def CreateDataset(opt):
+ dataset = None
+ from data.aligned_dataset_test import AlignedDataset
+ dataset = AlignedDataset()
+
+ print("dataset [%s] was created" % (dataset.name()))
+ dataset.initialize(opt)
+ return dataset
+
+class CustomDatasetDataLoader(BaseDataLoader):
+ def name(self):
+ return 'CustomDatasetDataLoader'
+
+ def initialize(self, opt):
+ BaseDataLoader.initialize(self, opt)
+ self.dataset = CreateDataset(opt)
+ self.dataloader = torch.utils.data.DataLoader(
+ self.dataset,
+ batch_size=opt.batchSize,
+ shuffle = False,
+ num_workers=int(opt.nThreads))
+
+ def load_data(self):
+ return self.dataloader
+
+ def __len__(self):
+ return min(len(self.dataset), self.opt.max_dataset_size)
diff --git a/VITON-Extends_test/data/data_loader_test.py b/VITON-Extends_test/data/data_loader_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..ce4c3189a9f5ee7f25a54de8ddb4d6ee455a9f12
--- /dev/null
+++ b/VITON-Extends_test/data/data_loader_test.py
@@ -0,0 +1,7 @@
+
+def CreateDataLoader(opt):
+ from data.custom_dataset_data_loader_test import CustomDatasetDataLoader
+ data_loader = CustomDatasetDataLoader()
+ print(data_loader.name())
+ data_loader.initialize(opt)
+ return data_loader
diff --git a/VITON-Extends_test/data/image_folder.py b/VITON-Extends_test/data/image_folder.py
new file mode 100644
index 0000000000000000000000000000000000000000..4e6e1a7d109201d8a653073e9b45c48392fb3fe4
--- /dev/null
+++ b/VITON-Extends_test/data/image_folder.py
@@ -0,0 +1,73 @@
+import torch.utils.data as data
+from PIL import Image
+import os
+
+IMG_EXTENSIONS = [
+ '.jpg', '.JPG', '.jpeg', '.JPEG',
+ '.png', '.PNG', '.ppm', '.PPM', '.bmp', '.BMP', '.tiff'
+]
+
+
+def is_image_file(filename):
+ return any(filename.endswith(extension) for extension in IMG_EXTENSIONS)
+
+def make_dataset(dir):
+ images = []
+ assert os.path.isdir(dir), '%s is not a valid directory' % dir
+
+ f = dir.split('/')[-1].split('_')[-1]
+ print (dir, f)
+ dirs= os.listdir(dir)
+ for img in dirs:
+
+ path = os.path.join(dir, img)
+ #print(path)
+ images.append(path)
+ return images
+
+def make_dataset_test(dir):
+ images = []
+ assert os.path.isdir(dir), '%s is not a valid directory' % dir
+
+ f = dir.split('/')[-1].split('_')[-1]
+ for i in range(len([name for name in os.listdir(dir) if os.path.isfile(os.path.join(dir, name))])):
+ if f == 'label' or f == 'labelref':
+ img = str(i) + '.png'
+ else:
+ img = str(i) + '.jpg'
+ path = os.path.join(dir, img)
+ images.append(path)
+ return images
+
+def default_loader(path):
+ return Image.open(path).convert('RGB')
+
+
+class ImageFolder(data.Dataset):
+
+ def __init__(self, root, transform=None, return_paths=False,
+ loader=default_loader):
+ imgs = make_dataset(root)
+ if len(imgs) == 0:
+ raise(RuntimeError("Found 0 images in: " + root + "\n"
+ "Supported image extensions are: " +
+ ",".join(IMG_EXTENSIONS)))
+
+ self.root = root
+ self.imgs = imgs
+ self.transform = transform
+ self.return_paths = return_paths
+ self.loader = loader
+
+ def __getitem__(self, index):
+ path = self.imgs[index]
+ img = self.loader(path)
+ if self.transform is not None:
+ img = self.transform(img)
+ if self.return_paths:
+ return img, path
+ else:
+ return img
+
+ def __len__(self):
+ return len(self.imgs)
diff --git a/VITON-Extends_test/hooks/use-mobile.tsx b/VITON-Extends_test/hooks/use-mobile.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..1461fc059faf6a57e1ee789d8564781af45c0a10
--- /dev/null
+++ b/VITON-Extends_test/hooks/use-mobile.tsx
@@ -0,0 +1,19 @@
+import * as React from "react"
+
+const MOBILE_BREAKPOINT = 768
+
+export function useIsMobile() {
+ const [isMobile, setIsMobile] = React.useState(undefined)
+
+ React.useEffect(() => {
+ const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
+ const onChange = () => {
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
+ }
+ mql.addEventListener("change", onChange)
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
+ return () => mql.removeEventListener("change", onChange)
+ }, [])
+
+ return !!isMobile
+}
diff --git a/VITON-Extends_test/hooks/use-toast.ts b/VITON-Extends_test/hooks/use-toast.ts
new file mode 100644
index 0000000000000000000000000000000000000000..db8af9a4bc82c0285c609fac79ac05c73e1d186b
--- /dev/null
+++ b/VITON-Extends_test/hooks/use-toast.ts
@@ -0,0 +1,194 @@
+"use client"
+
+// Inspired by react-hot-toast library
+import * as React from "react"
+
+import type {
+ ToastActionElement,
+ ToastProps,
+} from "@/components/ui/toast"
+
+const TOAST_LIMIT = 1
+const TOAST_REMOVE_DELAY = 1000000
+
+type ToasterToast = ToastProps & {
+ id: string
+ title?: React.ReactNode
+ description?: React.ReactNode
+ action?: ToastActionElement
+}
+
+const actionTypes = {
+ ADD_TOAST: "ADD_TOAST",
+ UPDATE_TOAST: "UPDATE_TOAST",
+ DISMISS_TOAST: "DISMISS_TOAST",
+ REMOVE_TOAST: "REMOVE_TOAST",
+} as const
+
+let count = 0
+
+function genId() {
+ count = (count + 1) % Number.MAX_SAFE_INTEGER
+ return count.toString()
+}
+
+type ActionType = typeof actionTypes
+
+type Action =
+ | {
+ type: ActionType["ADD_TOAST"]
+ toast: ToasterToast
+ }
+ | {
+ type: ActionType["UPDATE_TOAST"]
+ toast: Partial
+ }
+ | {
+ type: ActionType["DISMISS_TOAST"]
+ toastId?: ToasterToast["id"]
+ }
+ | {
+ type: ActionType["REMOVE_TOAST"]
+ toastId?: ToasterToast["id"]
+ }
+
+interface State {
+ toasts: ToasterToast[]
+}
+
+const toastTimeouts = new Map>()
+
+const addToRemoveQueue = (toastId: string) => {
+ if (toastTimeouts.has(toastId)) {
+ return
+ }
+
+ const timeout = setTimeout(() => {
+ toastTimeouts.delete(toastId)
+ dispatch({
+ type: "REMOVE_TOAST",
+ toastId: toastId,
+ })
+ }, TOAST_REMOVE_DELAY)
+
+ toastTimeouts.set(toastId, timeout)
+}
+
+export const reducer = (state: State, action: Action): State => {
+ switch (action.type) {
+ case "ADD_TOAST":
+ return {
+ ...state,
+ toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT),
+ }
+
+ case "UPDATE_TOAST":
+ return {
+ ...state,
+ toasts: state.toasts.map((t) =>
+ t.id === action.toast.id ? { ...t, ...action.toast } : t
+ ),
+ }
+
+ case "DISMISS_TOAST": {
+ const { toastId } = action
+
+ // ! Side effects ! - This could be extracted into a dismissToast() action,
+ // but I'll keep it here for simplicity
+ if (toastId) {
+ addToRemoveQueue(toastId)
+ } else {
+ state.toasts.forEach((toast) => {
+ addToRemoveQueue(toast.id)
+ })
+ }
+
+ return {
+ ...state,
+ toasts: state.toasts.map((t) =>
+ t.id === toastId || toastId === undefined
+ ? {
+ ...t,
+ open: false,
+ }
+ : t
+ ),
+ }
+ }
+ case "REMOVE_TOAST":
+ if (action.toastId === undefined) {
+ return {
+ ...state,
+ toasts: [],
+ }
+ }
+ return {
+ ...state,
+ toasts: state.toasts.filter((t) => t.id !== action.toastId),
+ }
+ }
+}
+
+const listeners: Array<(state: State) => void> = []
+
+let memoryState: State = { toasts: [] }
+
+function dispatch(action: Action) {
+ memoryState = reducer(memoryState, action)
+ listeners.forEach((listener) => {
+ listener(memoryState)
+ })
+}
+
+type Toast = Omit
+
+function toast({ ...props }: Toast) {
+ const id = genId()
+
+ const update = (props: ToasterToast) =>
+ dispatch({
+ type: "UPDATE_TOAST",
+ toast: { ...props, id },
+ })
+ const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id })
+
+ dispatch({
+ type: "ADD_TOAST",
+ toast: {
+ ...props,
+ id,
+ open: true,
+ onOpenChange: (open) => {
+ if (!open) dismiss()
+ },
+ },
+ })
+
+ return {
+ id: id,
+ dismiss,
+ update,
+ }
+}
+
+function useToast() {
+ const [state, setState] = React.useState(memoryState)
+
+ React.useEffect(() => {
+ listeners.push(setState)
+ return () => {
+ const index = listeners.indexOf(setState)
+ if (index > -1) {
+ listeners.splice(index, 1)
+ }
+ }
+ }, [state])
+
+ return {
+ ...state,
+ toast,
+ dismiss: (toastId?: string) => dispatch({ type: "DISMISS_TOAST", toastId }),
+ }
+}
+
+export { useToast, toast }
diff --git a/VITON-Extends_test/lib/utils.ts b/VITON-Extends_test/lib/utils.ts
new file mode 100644
index 0000000000000000000000000000000000000000..2f00a256c299a07d69112cba03d9fe194313e00e
--- /dev/null
+++ b/VITON-Extends_test/lib/utils.ts
@@ -0,0 +1,6 @@
+import { clsx, type ClassValue } from "clsx"
+import { twMerge } from "tailwind-merge"
+
+export function cn(...inputs: ClassValue[]) {
+ return twMerge(clsx(inputs))
+}
diff --git a/VITON-Extends_test/models/afwm.py b/VITON-Extends_test/models/afwm.py
new file mode 100644
index 0000000000000000000000000000000000000000..e4dd6b4e94ef83d9f8710bf0d88b4d2b3db08fd2
--- /dev/null
+++ b/VITON-Extends_test/models/afwm.py
@@ -0,0 +1,199 @@
+import torch
+import torch.nn as nn
+import torch.nn.functional as F
+from .correlation import correlation
+
+def apply_offset(offset):
+
+ sizes = list(offset.size()[2:])
+ grid_list = torch.meshgrid([torch.arange(size, device=offset.device) for size in sizes],
+ indexing='ij' )
+ grid_list = reversed(grid_list)
+
+ grid_list = [grid.float().unsqueeze(0) + offset[:, dim, ...]
+ for dim, grid in enumerate(grid_list)]
+
+ grid_list = [grid / ((size - 1.0) / 2.0) - 1.0
+ for grid, size in zip(grid_list, reversed(sizes))]
+
+ return torch.stack(grid_list, dim=-1)
+
+
+class ResBlock(nn.Module):
+ def __init__(self, in_channels):
+ super(ResBlock, self).__init__()
+ self.block = nn.Sequential(
+ nn.BatchNorm2d(in_channels),
+ nn.ReLU(inplace=True),
+ nn.Conv2d(in_channels, in_channels, kernel_size=3, padding=1, bias=False),
+ nn.BatchNorm2d(in_channels),
+ nn.ReLU(inplace=True),
+ nn.Conv2d(in_channels, in_channels, kernel_size=3, padding=1, bias=False)
+ )
+
+ def forward(self, x):
+ return self.block(x) + x
+
+
+class DownSample(nn.Module):
+ def __init__(self, in_channels, out_channels):
+ super(DownSample, self).__init__()
+ self.block= nn.Sequential(
+ nn.BatchNorm2d(in_channels),
+ nn.ReLU(inplace=True),
+ nn.Conv2d(in_channels, out_channels, kernel_size=3, stride=2, padding=1, bias=False)
+ )
+
+ def forward(self, x):
+ return self.block(x)
+
+
+
+class FeatureEncoder(nn.Module):
+ def __init__(self, in_channels, chns=[64,128,256,256,256]):
+ super(FeatureEncoder, self).__init__()
+ self.encoders = []
+ for i, out_chns in enumerate(chns):
+ if i == 0:
+ encoder = nn.Sequential(DownSample(in_channels, out_chns),
+ ResBlock(out_chns),
+ ResBlock(out_chns))
+ else:
+ encoder = nn.Sequential(DownSample(chns[i-1], out_chns),
+ ResBlock(out_chns),
+ ResBlock(out_chns))
+
+ self.encoders.append(encoder)
+
+ self.encoders = nn.ModuleList(self.encoders)
+
+
+ def forward(self, x):
+ encoder_features = []
+ for encoder in self.encoders:
+ x = encoder(x)
+ encoder_features.append(x)
+ return encoder_features
+
+class RefinePyramid(nn.Module):
+ def __init__(self, chns=[64,128,256,256,256], fpn_dim=256):
+ super(RefinePyramid, self).__init__()
+ self.chns = chns
+
+ self.adaptive = []
+ for in_chns in list(reversed(chns)):
+ adaptive_layer = nn.Conv2d(in_chns, fpn_dim, kernel_size=1)
+ self.adaptive.append(adaptive_layer)
+ self.adaptive = nn.ModuleList(self.adaptive)
+
+ self.smooth = []
+ for i in range(len(chns)):
+ smooth_layer = nn.Conv2d(fpn_dim, fpn_dim, kernel_size=3, padding=1)
+ self.smooth.append(smooth_layer)
+ self.smooth = nn.ModuleList(self.smooth)
+
+ def forward(self, x):
+ conv_ftr_list = x
+
+ feature_list = []
+ last_feature = None
+ for i, conv_ftr in enumerate(list(reversed(conv_ftr_list))):
+ feature = self.adaptive[i](conv_ftr)
+
+ if last_feature is not None:
+ feature = feature + F.interpolate(last_feature, scale_factor=2, mode='nearest')
+
+ feature = self.smooth[i](feature)
+ last_feature = feature
+ feature_list.append(feature)
+
+ return tuple(reversed(feature_list))
+
+
+class AFlowNet(nn.Module):
+ def __init__(self, num_pyramid, fpn_dim=256):
+ super(AFlowNet, self).__init__()
+ self.netMain = []
+ self.netRefine = []
+ for i in range(num_pyramid):
+ netMain_layer = torch.nn.Sequential(
+ torch.nn.Conv2d(in_channels=49, out_channels=128, kernel_size=3, stride=1, padding=1),
+ torch.nn.LeakyReLU(inplace=False, negative_slope=0.1),
+ torch.nn.Conv2d(in_channels=128, out_channels=64, kernel_size=3, stride=1, padding=1),
+ torch.nn.LeakyReLU(inplace=False, negative_slope=0.1),
+ torch.nn.Conv2d(in_channels=64, out_channels=32, kernel_size=3, stride=1, padding=1),
+ torch.nn.LeakyReLU(inplace=False, negative_slope=0.1),
+ torch.nn.Conv2d(in_channels=32, out_channels=2, kernel_size=3, stride=1, padding=1)
+ )
+
+ netRefine_layer = torch.nn.Sequential(
+ torch.nn.Conv2d(2 * fpn_dim, out_channels=128, kernel_size=3, stride=1, padding=1),
+ torch.nn.LeakyReLU(inplace=False, negative_slope=0.1),
+ torch.nn.Conv2d(in_channels=128, out_channels=64, kernel_size=3, stride=1, padding=1),
+ torch.nn.LeakyReLU(inplace=False, negative_slope=0.1),
+ torch.nn.Conv2d(in_channels=64, out_channels=32, kernel_size=3, stride=1, padding=1),
+ torch.nn.LeakyReLU(inplace=False, negative_slope=0.1),
+ torch.nn.Conv2d(in_channels=32, out_channels=2, kernel_size=3, stride=1, padding=1)
+ )
+ self.netMain.append(netMain_layer)
+ self.netRefine.append(netRefine_layer)
+
+ self.netMain = nn.ModuleList(self.netMain)
+ self.netRefine = nn.ModuleList(self.netRefine)
+
+
+ def forward(self, x, x_warps, x_conds, warp_feature=True):
+ last_flow = None
+
+ for i in range(len(x_warps)):
+ x_warp = x_warps[len(x_warps) - 1 - i]
+ x_cond = x_conds[len(x_warps) - 1 - i]
+
+ if last_flow is not None and warp_feature:
+ x_warp_after = F.grid_sample(x_warp, last_flow.detach().permute(0, 2, 3, 1),
+ mode='bilinear', padding_mode='border', align_corners=True)
+ else:
+ x_warp_after = x_warp
+
+ tenCorrelation = F.leaky_relu(input=correlation.FunctionCorrelation(tenFirst=x_warp_after, tenSecond=x_cond, intStride=1), negative_slope=0.1, inplace=False)
+ flow = self.netMain[i](tenCorrelation)
+ flow = apply_offset(flow)
+
+ if last_flow is not None:
+ flow = F.grid_sample(last_flow, flow, mode='bilinear', padding_mode='border', align_corners=True)
+ else:
+ flow = flow.permute(0, 3, 1, 2)
+
+ last_flow = flow
+ x_warp = F.grid_sample(x_warp, flow.permute(0, 2, 3, 1),mode='bilinear', padding_mode='border', align_corners=True)
+ concat = torch.cat([x_warp,x_cond],1)
+ flow = self.netRefine[i](concat)
+ flow = apply_offset(flow)
+ flow = F.grid_sample(last_flow, flow, mode='bilinear', padding_mode='border', align_corners=True)
+
+ last_flow = F.interpolate(flow, scale_factor=2, mode='bilinear')
+
+ x_warp = F.grid_sample(x, last_flow.permute(0, 2, 3, 1),
+ mode='bilinear', padding_mode='border',align_corners=True)
+ return x_warp, last_flow,
+
+
+class AFWM(nn.Module):
+
+ def __init__(self, opt, input_nc):
+ super(AFWM, self).__init__()
+ num_filters = [64,128,256,256,256]
+ self.image_features = FeatureEncoder(3, num_filters)
+ self.cond_features = FeatureEncoder(input_nc, num_filters)
+ self.image_FPN = RefinePyramid(num_filters)
+ self.cond_FPN = RefinePyramid(num_filters)
+ self.aflow_net = AFlowNet(len(num_filters))
+
+ def forward(self, cond_input, image_input):
+ cond_pyramids = self.cond_FPN(self.cond_features(cond_input)) # maybe use nn.Sequential
+ image_pyramids = self.image_FPN(self.image_features(image_input))
+
+ x_warp, last_flow = self.aflow_net(image_input, image_pyramids, cond_pyramids)
+
+ return x_warp, last_flow
+
diff --git a/VITON-Extends_test/models/networks.py b/VITON-Extends_test/models/networks.py
new file mode 100644
index 0000000000000000000000000000000000000000..9a044c4ac75550e6414067e3ad3949487b6247c1
--- /dev/null
+++ b/VITON-Extends_test/models/networks.py
@@ -0,0 +1,186 @@
+import torch
+import torch.nn as nn
+import torch.nn.parallel
+import os
+
+class UnetSkipConnectionBlock(nn.Module):
+ def __init__(self, outer_nc, inner_nc, input_nc=None,
+ submodule=None, outermost=False, innermost=False, norm_layer=nn.BatchNorm2d, use_dropout=False):
+ super(UnetSkipConnectionBlock, self).__init__()
+ self.outermost = outermost
+ use_bias = norm_layer == nn.InstanceNorm2d
+
+ if input_nc is None:
+ input_nc = outer_nc
+ downconv = nn.Conv2d(input_nc, inner_nc, kernel_size=4,
+ stride=2, padding=1, bias=use_bias)
+ downrelu = nn.LeakyReLU(0.2, True)
+ uprelu = nn.ReLU(True)
+ if norm_layer != None:
+ downnorm = norm_layer(inner_nc)
+ upnorm = norm_layer(outer_nc)
+
+ if outermost:
+ upsample = nn.Upsample(scale_factor=2, mode='bilinear')
+ upconv = nn.Conv2d(inner_nc * 2, outer_nc, kernel_size=3, stride=1, padding=1, bias=use_bias)
+ down = [downconv]
+ up = [uprelu, upsample, upconv]
+ model = down + [submodule] + up
+ elif innermost:
+ upsample = nn.Upsample(scale_factor=2, mode='bilinear')
+ upconv = nn.Conv2d(inner_nc, outer_nc, kernel_size=3, stride=1, padding=1, bias=use_bias)
+ down = [downrelu, downconv]
+ if norm_layer == None:
+ up = [uprelu, upsample, upconv]
+ else:
+ up = [uprelu, upsample, upconv, upnorm]
+ model = down + up
+ else:
+ upsample = nn.Upsample(scale_factor=2, mode='bilinear')
+ upconv = nn.Conv2d(inner_nc*2, outer_nc, kernel_size=3, stride=1, padding=1, bias=use_bias)
+ if norm_layer == None:
+ down = [downrelu, downconv]
+ up = [uprelu, upsample, upconv]
+ else:
+ down = [downrelu, downconv, downnorm]
+ up = [uprelu, upsample, upconv, upnorm]
+
+ if use_dropout:
+ model = down + [submodule] + up + [nn.Dropout(0.5)]
+ else:
+ model = down + [submodule] + up
+
+ self.model = nn.Sequential(*model)
+
+ def forward(self, x):
+ if self.outermost:
+ return self.model(x)
+ else:
+ return torch.cat([x, self.model(x)], 1)
+
+class ResidualBlock(nn.Module):
+ def __init__(self, in_features=64, norm_layer=nn.BatchNorm2d):
+ super(ResidualBlock, self).__init__()
+ self.relu = nn.ReLU(True)
+ if norm_layer == None:
+ self.block = nn.Sequential(
+ nn.Conv2d(in_features, in_features, 3, 1, 1, bias=False),
+ nn.ReLU(inplace=True),
+ nn.Conv2d(in_features, in_features, 3, 1, 1, bias=False),
+ )
+ else:
+ self.block = nn.Sequential(
+ nn.Conv2d(in_features, in_features, 3, 1, 1, bias=False),
+ norm_layer(in_features),
+ nn.ReLU(inplace=True),
+ nn.Conv2d(in_features, in_features, 3, 1, 1, bias=False),
+ norm_layer(in_features)
+ )
+
+ def forward(self, x):
+ residual = x
+ out = self.block(x)
+ out += residual
+ out = self.relu(out)
+ return out
+
+class ResUnetGenerator(nn.Module):
+ def __init__(self, input_nc, output_nc, num_downs, ngf=64,
+ norm_layer=nn.BatchNorm2d, use_dropout=False):
+ super(ResUnetGenerator, self).__init__()
+ unet_block = ResUnetSkipConnectionBlock(ngf * 8, ngf * 8, input_nc=None, submodule=None, norm_layer=norm_layer, innermost=True)
+
+ for i in range(num_downs - 5):
+ unet_block = ResUnetSkipConnectionBlock(ngf * 8, ngf * 8, input_nc=None, submodule=unet_block, norm_layer=norm_layer, use_dropout=use_dropout)
+ unet_block = ResUnetSkipConnectionBlock(ngf * 4, ngf * 8, input_nc=None, submodule=unet_block, norm_layer=norm_layer)
+ unet_block = ResUnetSkipConnectionBlock(ngf * 2, ngf * 4, input_nc=None, submodule=unet_block, norm_layer=norm_layer)
+ unet_block = ResUnetSkipConnectionBlock(ngf, ngf * 2, input_nc=None, submodule=unet_block, norm_layer=norm_layer)
+ unet_block = ResUnetSkipConnectionBlock(output_nc, ngf, input_nc=input_nc, submodule=unet_block, outermost=True, norm_layer=norm_layer)
+
+ self.model = unet_block
+
+ def forward(self, input):
+ return self.model(input)
+
+
+class ResUnetSkipConnectionBlock(nn.Module):
+ def __init__(self, outer_nc, inner_nc, input_nc=None,
+ submodule=None, outermost=False, innermost=False, norm_layer=nn.BatchNorm2d, use_dropout=False):
+ super(ResUnetSkipConnectionBlock, self).__init__()
+ self.outermost = outermost
+ use_bias = norm_layer == nn.InstanceNorm2d
+
+ if input_nc is None:
+ input_nc = outer_nc
+ downconv = nn.Conv2d(input_nc, inner_nc, kernel_size=3,
+ stride=2, padding=1, bias=use_bias)
+
+ res_downconv = [ResidualBlock(inner_nc, norm_layer), ResidualBlock(inner_nc, norm_layer)]
+ res_upconv = [ResidualBlock(outer_nc, norm_layer), ResidualBlock(outer_nc, norm_layer)]
+
+ downrelu = nn.ReLU(True)
+ uprelu = nn.ReLU(True)
+ if norm_layer != None:
+ downnorm = norm_layer(inner_nc)
+ upnorm = norm_layer(outer_nc)
+
+ if outermost:
+ upsample = nn.Upsample(scale_factor=2, mode='nearest')
+ upconv = nn.Conv2d(inner_nc * 2, outer_nc, kernel_size=3, stride=1, padding=1, bias=use_bias)
+ down = [downconv, downrelu] + res_downconv
+ up = [upsample, upconv]
+ model = down + [submodule] + up
+ elif innermost:
+ upsample = nn.Upsample(scale_factor=2, mode='nearest')
+ upconv = nn.Conv2d(inner_nc, outer_nc, kernel_size=3, stride=1, padding=1, bias=use_bias)
+ down = [downconv, downrelu] + res_downconv
+ if norm_layer == None:
+ up = [upsample, upconv, uprelu] + res_upconv
+ else:
+ up = [upsample, upconv, upnorm, uprelu] + res_upconv
+ model = down + up
+ else:
+ upsample = nn.Upsample(scale_factor=2, mode='nearest')
+ upconv = nn.Conv2d(inner_nc*2, outer_nc, kernel_size=3, stride=1, padding=1, bias=use_bias)
+ if norm_layer == None:
+ down = [downconv, downrelu] + res_downconv
+ up = [upsample, upconv, uprelu] + res_upconv
+ else:
+ down = [downconv, downnorm, downrelu] + res_downconv
+ up = [upsample, upconv, upnorm, uprelu] + res_upconv
+
+ if use_dropout:
+ model = down + [submodule] + up + [nn.Dropout(0.5)]
+ else:
+ model = down + [submodule] + up
+
+ self.model = nn.Sequential(*model)
+
+ def forward(self, x):
+ if self.outermost:
+ return self.model(x)
+ else:
+ return torch.cat([x, self.model(x)], 1)
+
+
+def save_checkpoint(model, save_path):
+ if not os.path.exists(os.path.dirname(save_path)):
+ os.makedirs(os.path.dirname(save_path))
+ torch.save(model.state_dict(), save_path)
+
+
+def load_checkpoint(model, checkpoint_path):
+
+ if not os.path.exists(checkpoint_path):
+ print('No checkpoint!')
+ return
+
+ checkpoint = torch.load(checkpoint_path, weights_only=True)
+ checkpoint_new = model.state_dict()
+ for param in checkpoint_new:
+ checkpoint_new[param] = checkpoint[param]
+
+ model.load_state_dict(checkpoint_new)
+
+
+
diff --git a/VITON-Extends_test/options/base_options.py b/VITON-Extends_test/options/base_options.py
new file mode 100644
index 0000000000000000000000000000000000000000..77378da2c4a2b48754e4bfcb1ca201ce325c95da
--- /dev/null
+++ b/VITON-Extends_test/options/base_options.py
@@ -0,0 +1,59 @@
+import argparse
+import torch
+
+class BaseOptions():
+ def __init__(self):
+ self.parser = argparse.ArgumentParser()
+ self.initialized = False
+
+ def initialize(self):
+ self.parser.add_argument('--name', type=str, default='demo', help='name of the experiment. It decides where to store samples and models')
+ self.parser.add_argument('--gpu_ids', type=str, default='0', help='gpu ids: e.g. 0 0,1,2, 0,2. use -1 for CPU')
+ self.parser.add_argument('--norm', type=str, default='instance', help='instance normalization or batch normalization')
+ self.parser.add_argument('--use_dropout', action='store_true', help='use dropout for the generator')
+ self.parser.add_argument('--data_type', default=32, type=int, choices=[8, 16, 32], help="Supported data type i.e. 8, 16, 32 bit")
+ self.parser.add_argument('--verbose', action='store_true', default=False, help='toggles verbose')
+
+ self.parser.add_argument('--batchSize', type=int, default=1, help='input batch size')
+ self.parser.add_argument('--loadSize', type=int, default=512, help='scale images to this size')
+ self.parser.add_argument('--fineSize', type=int, default=512, help='then crop to this size')
+ self.parser.add_argument('--input_nc', type=int, default=3, help='# of input image channels')
+ self.parser.add_argument('--output_nc', type=int, default=3, help='# of output image channels')
+
+ self.parser.add_argument('--dataroot', type=str,
+ default='dataset/')
+ self.parser.add_argument('--resize_or_crop', type=str, default='scale_width', help='scaling and cropping of images at load time [resize_and_crop|crop|scale_width|scale_width_and_crop]')
+ self.parser.add_argument('--serial_batches', action='store_true', help='if true, takes images in order to make batches, otherwise takes them randomly')
+ self.parser.add_argument('--no_flip', action='store_true', help='if specified, do not flip the images for data argumentation')
+ self.parser.add_argument('--nThreads', default=1, type=int, help='# threads for loading data')
+ self.parser.add_argument('--max_dataset_size', type=int, default=float("inf"), help='Maximum number of samples allowed per dataset. If the dataset directory contains more than max_dataset_size, only a subset is loaded.')
+
+ self.parser.add_argument('--display_winsize', type=int, default=512, help='display window size')
+ self.parser.add_argument('--tf_log', action='store_true', help='if specified, use tensorboard logging. Requires tensorflow installed')
+
+ self.initialized = True
+
+ def parse(self, save=True):
+ if not self.initialized:
+ self.initialize()
+ self.opt = self.parser.parse_args()
+ self.opt.isTrain = self.isTrain # train or test
+
+ str_ids = self.opt.gpu_ids.split(',')
+ self.opt.gpu_ids = []
+ for str_id in str_ids:
+ id = int(str_id)
+ if id >= 0:
+ self.opt.gpu_ids.append(id)
+
+ if len(self.opt.gpu_ids) > 0:
+ torch.cuda.set_device(self.opt.gpu_ids[0])
+
+ args = vars(self.opt)
+
+ print('------------ Options -------------')
+ for k, v in sorted(args.items()):
+ print('%s: %s' % (str(k), str(v)))
+ print('-------------- End ----------------')
+
+ return self.opt