tonyassi commited on
Commit
968b6f5
β€’
1 Parent(s): b26195a

Upload 10 files

Browse files
README.md CHANGED
@@ -1,10 +1,10 @@
1
  ---
2
- title: Domi Try On
3
- emoji: πŸ’»
4
- colorFrom: yellow
5
- colorTo: yellow
6
  sdk: gradio
7
- sdk_version: 5.9.1
8
  app_file: app.py
9
  pinned: false
10
  ---
 
1
  ---
2
+ title: Try On Dev
3
+ emoji: πŸ“‰
4
+ colorFrom: gray
5
+ colorTo: purple
6
  sdk: gradio
7
+ sdk_version: 5.9.0
8
  app_file: app.py
9
  pinned: false
10
  ---
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ flask
2
+ imagekitio
static/.DS_Store ADDED
Binary file (6.15 kB). View file
 
static/1.png ADDED
static/2.png ADDED
static/3.png ADDED
static/4.png ADDED
static/icon.png ADDED
static/spinner.gif ADDED
templates/index.html ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Virtual Fitting</title>
7
+ <style>
8
+ body {
9
+ display: flex; flex-direction: column; margin: 0; padding: 0;
10
+ font-family: Arial, sans-serif;
11
+ }
12
+ .row { display: flex; flex: 1; margin-top: 10px; }
13
+ .left, .right { flex: 1; }
14
+ .right { display: flex; flex-direction: column; align-items: center; }
15
+ .right img, .left img, .top img {
16
+ width: 100%; margin-bottom: 10px; object-fit: cover;
17
+ }
18
+ .button-container { margin-bottom: 10px; text-align: center; }
19
+ .try-on-button {
20
+ background-color: #ff9487;
21
+ color: white; border: none; border-radius: 5px;
22
+ padding: 15px 40px; font-size: 24px; cursor: pointer;
23
+ }
24
+ .popup-overlay {
25
+ position: fixed; top: 0; left: 0; width: 100%; height: 100%;
26
+ background: rgba(0, 0, 0, 0.7); display: none; justify-content: center; align-items: center;
27
+ z-index: 999;
28
+ }
29
+ .popup-content {
30
+ background: white; padding: 20px; border-radius: 10px; text-align: center; width: 400px; position: relative;
31
+ }
32
+ .close-btn {
33
+ position: absolute; top: 10px; right: 10px; cursor: pointer; font-size: 20px; color: #888;
34
+ }
35
+ .drag-box {
36
+ border: 2px dashed #ccc; padding: 20px; border-radius: 10px;
37
+ display: flex; flex-direction: column; align-items: center; justify-content: center;
38
+ height: 200px; position: relative;
39
+ }
40
+ .drag-box img { max-height: 50px; margin-bottom: 10px; }
41
+ .hidden { display: none; }
42
+ .loading-container {
43
+ position: relative; opacity: 0.5;
44
+ }
45
+ .loading-container::after {
46
+ content: '';
47
+ position: absolute;
48
+ top: 50%; left: 50%;
49
+ width: 50px; height: 50px;
50
+ background: url('/static/spinner.gif') no-repeat center center;
51
+ background-size: contain;
52
+ transform: translate(-50%, -50%);
53
+ z-index: 10;
54
+ }
55
+ </style>
56
+ </head>
57
+ <body>
58
+ <div class="top">
59
+ <img src="/static/1.png" alt="Top Image">
60
+ </div>
61
+ <div class="row">
62
+ <div class="left">
63
+ <img src="/static/2.png" alt="Left Image">
64
+ </div>
65
+ <div class="right">
66
+ <img src="/static/3.png" alt="Right Top Image">
67
+ <div class="button-container">
68
+ <button class="try-on-button" onclick="showPopup()">Try On!</button>
69
+ </div>
70
+ <img src="/static/4.png" alt="Right Bottom Image">
71
+ </div>
72
+ </div>
73
+
74
+ <!-- Popup -->
75
+ <div class="popup-overlay" id="popup">
76
+ <div class="popup-content">
77
+ <span class="close-btn" onclick="closePopup()">&#10005;</span>
78
+ <h2>Virtual Fitting</h2>
79
+ <div id="drag-container">
80
+ <div class="drag-box" id="drop-area">
81
+ <img src="/static/icon.png" alt="Icon">
82
+ <p>Drag your image file here or click to select</p>
83
+ <input type="file" id="file-input" style="display: none;">
84
+ </div>
85
+ </div>
86
+ <div id="uploaded-image" style="margin-top: 10px;"></div>
87
+ </div>
88
+ </div>
89
+
90
+ <script>
91
+ const popup = document.getElementById('popup');
92
+ const dragContainer = document.getElementById('drag-container');
93
+ const uploadedImageContainer = document.getElementById('uploaded-image');
94
+
95
+ function showPopup() {
96
+ popup.style.display = 'flex';
97
+ resetDragAndDrop();
98
+ }
99
+
100
+ function closePopup() {
101
+ popup.style.display = 'none';
102
+ uploadedImageContainer.innerHTML = "";
103
+ dragContainer.classList.remove('hidden');
104
+ }
105
+
106
+ function resetDragAndDrop() {
107
+ // Reset the drag-and-drop container
108
+ dragContainer.innerHTML = `
109
+ <div class="drag-box" id="drop-area">
110
+ <img src="/static/icon.png" alt="Icon">
111
+ <p>Drag your image file here or click to select</p>
112
+ <input type="file" id="file-input" style="display: none;">
113
+ </div>
114
+ `;
115
+ attachEvents();
116
+ }
117
+
118
+ function attachEvents() {
119
+ const dropArea = document.getElementById('drop-area');
120
+ const fileInput = dropArea.querySelector('#file-input');
121
+
122
+ dropArea.addEventListener('click', () => fileInput.click());
123
+ dropArea.addEventListener('dragover', (e) => e.preventDefault());
124
+ dropArea.addEventListener('drop', (e) => {
125
+ e.preventDefault();
126
+ uploadImage(e.dataTransfer.files[0]);
127
+ });
128
+ fileInput.addEventListener('change', (e) => uploadImage(e.target.files[0]));
129
+ }
130
+
131
+ function uploadImage(file) {
132
+ const formData = new FormData();
133
+ formData.append('file', file);
134
+
135
+ dragContainer.classList.add('hidden');
136
+ uploadedImageContainer.innerHTML = `
137
+ <div class="loading-container">
138
+ <img src="${URL.createObjectURL(file)}" style="width: 100%;">
139
+ </div>
140
+ `;
141
+
142
+ fetch("/upload", { method: "POST", body: formData })
143
+ .then(response => response.json())
144
+ .then(data => {
145
+ if (data.processed_image) {
146
+ uploadedImageContainer.innerHTML = `
147
+ <img src="${data.processed_image}" style="width: 100%;">
148
+ `;
149
+ }
150
+ });
151
+ }
152
+
153
+ // Initialize events on page load
154
+ attachEvents();
155
+ </script>
156
+ </body>
157
+ </html>