Harsh-7300 commited on
Commit
78299c1
·
verified ·
1 Parent(s): 7f93cb7

Delete SWAPON

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. SWAPON/.DS_Store +0 -0
  2. SWAPON/README.md +0 -12
  3. SWAPON/app.py +0 -169
  4. SWAPON/examples/basemodel.png +0 -0
  5. SWAPON/examples/garment1.jpg +0 -0
  6. SWAPON/examples/garment1.png +0 -0
  7. SWAPON/examples/garment2.jpg +0 -0
  8. SWAPON/examples/garment2.png +0 -0
  9. SWAPON/examples/garment3.png +0 -0
  10. SWAPON/examples/result1.png +0 -0
  11. SWAPON/examples/result2.png +0 -0
  12. SWAPON/examples/result3.png +0 -0
  13. SWAPON/garments/bottom1.png +0 -0
  14. SWAPON/garments/bottom2.PNG +0 -0
  15. SWAPON/garments/bottom3.JPG +0 -0
  16. SWAPON/garments/bottom4.PNG +0 -0
  17. SWAPON/garments/bottom5.png +0 -0
  18. SWAPON/garments/dress1.png +0 -0
  19. SWAPON/garments/dress2.png +0 -0
  20. SWAPON/garments/top111.png +0 -0
  21. SWAPON/garments/top222.JPG +0 -0
  22. SWAPON/garments/top3.JPG +0 -0
  23. SWAPON/garments/top333.png +0 -0
  24. SWAPON/garments/top4.png +0 -0
  25. SWAPON/garments/top5.png +0 -0
  26. SWAPON/models/eva/Eva_0.png +0 -0
  27. SWAPON/models/eva/Eva_1.png +0 -0
  28. SWAPON/models/rouyan_new/0/densepose.png +0 -0
  29. SWAPON/models/rouyan_new/0/humanmask.png +0 -0
  30. SWAPON/models/rouyan_new/0/initmask.png +0 -0
  31. SWAPON/models/rouyan_new/0/model.png +0 -0
  32. SWAPON/models/rouyan_new/1/a +0 -1
  33. SWAPON/models/rouyan_new/1/humanmask.png +0 -0
  34. SWAPON/models/rouyan_new/1/initmask.png +0 -0
  35. SWAPON/models/rouyan_new/1/mdensepose.png +0 -0
  36. SWAPON/models/rouyan_new/1/model.png +0 -0
  37. SWAPON/models/rouyan_new/2/a +0 -1
  38. SWAPON/models/rouyan_new/2/densepose.png +0 -0
  39. SWAPON/models/rouyan_new/2/humanmask.png +0 -0
  40. SWAPON/models/rouyan_new/2/initmask.png +0 -0
  41. SWAPON/models/rouyan_new/2/model.png +0 -0
  42. SWAPON/models/rouyan_new/Rouyan_0.png +0 -0
  43. SWAPON/models/rouyan_new/Rouyan_1.png +0 -0
  44. SWAPON/models/rouyan_new/Rouyan_2.png +0 -0
  45. SWAPON/models/simon_online/Simon_0.png +0 -0
  46. SWAPON/models/simon_online/Simon_1.png +0 -0
  47. SWAPON/models/simon_online/a +0 -1
  48. SWAPON/models/xiaoxuan/a +0 -1
  49. SWAPON/models/xiaoxuan/model.png +0 -0
  50. SWAPON/models/xiaoxuan_online/Xuanxuan_0.png +0 -0
SWAPON/.DS_Store DELETED
Binary file (6.15 kB)
 
SWAPON/README.md DELETED
@@ -1,12 +0,0 @@
1
- ---
2
- title: OutfitAnyone
3
- emoji: 🏢
4
- colorFrom: red
5
- colorTo: pink
6
- sdk: gradio
7
- sdk_version: 4.8.0
8
- app_file: app.py
9
- pinned: false
10
- license: cc-by-nc-4.0
11
- ---
12
-
 
 
 
 
 
 
 
 
 
 
 
 
 
SWAPON/app.py DELETED
@@ -1,169 +0,0 @@
1
- import os
2
- import cv2 as cv
3
- import numpy as np
4
- import json
5
- import random
6
- from PIL import Image, ImageDraw, ImageFont
7
- import asyncio
8
- import socket
9
- import requests
10
- import base64
11
- import gradio as gr
12
- # from IPython import embed
13
-
14
-
15
- machine_number = 0
16
- model = os.path.join(os.path.dirname(__file__), "models/eva/Eva_0.png")
17
-
18
- MODEL_MAP = {
19
- "AI Model Rouyan_0": 'models/rouyan_new/Rouyan_0.png',
20
- "AI Model Rouyan_1": 'models/rouyan_new/Rouyan_1.png',
21
- "AI Model Rouyan_2": 'models/rouyan_new/Rouyan_2.png',
22
- "AI Model Eva_0": 'models/eva/Eva_0.png',
23
- "AI Model Eva_1": 'models/eva/Eva_1.png',
24
- "AI Model Simon_0": 'models/simon_online/Simon_0.png',
25
- "AI Model Simon_1": 'models/simon_online/Simon_1.png',
26
- "AI Model Xuanxuan_0": 'models/xiaoxuan_online/Xuanxuan_0.png',
27
- "AI Model Xuanxuan_1": 'models/xiaoxuan_online/Xuanxuan_1.png',
28
- "AI Model Xuanxuan_2": 'models/xiaoxuan_online/Xuanxuan_2.png',
29
- "AI Model Yaqi_0": 'models/yaqi/Yaqi_0.png',
30
- "AI Model Yaqi_1": 'models/yaqi/Yaqi_1.png',
31
- "AI Model Yaqi_2": 'models/yaqi/Yaqi_2.png',
32
- "AI Model Yaqi_3": 'models/yaqi/Yaqi_3.png',
33
- "AI Model Yifeng_0": 'models/yifeng_online/Yifeng_0.png',
34
- "AI Model Yifeng_1": 'models/yifeng_online/Yifeng_1.png',
35
- "AI Model Yifeng_2": 'models/yifeng_online/Yifeng_2.png',
36
- "AI Model Yifeng_3": 'models/yifeng_online/Yifeng_3.png',
37
- }
38
-
39
- def add_waterprint(img: cv.Mat) -> cv.Mat:
40
- h, w, _ = img.shape
41
- img = cv.putText(img, 'Powered by OutfitAnyone', (int(0.3*w), h-20), cv.FONT_HERSHEY_PLAIN, 2, (128, 128, 128), 2, cv.LINE_AA)
42
- return img
43
-
44
-
45
- def get_tryon_result(model_name: str, garment1: cv.Mat, garment2: cv.Mat | None, seed: int = 1234) -> cv.Mat:
46
- #model_name = "AI Model " + model_name.split("\\")[-1].split(".")[0] # windows
47
- model_name = "AI Model " + model_name.split("/")[-1].split(".")[0] # linux
48
- print(model_name)
49
- encoded_garment1 = cv.imencode('.jpg', garment1)[1].tobytes()
50
- encoded_garment1 = base64.b64encode(encoded_garment1).decode('utf-8')
51
-
52
- if garment2 is not None:
53
- encoded_garment2 = cv.imencode('.jpg', garment2)[1].tobytes()
54
- encoded_garment2 = base64.b64encode(encoded_garment2).decode('utf-8')
55
- else:
56
- encoded_garment2 = ''
57
-
58
- host_ip = socket.gethostbyname(socket.gethostname())
59
- url = f"https://{host_ip}:192.168.115.27"
60
- headers = {'Content-Type': 'application/json'}
61
- seed = random.randint(0, 1222222222)
62
- data = {
63
- "garment1": encoded_garment1,
64
- "garment2": encoded_garment2,
65
- "model_name": model_name,
66
- "seed": seed
67
- }
68
- response = requests.post(url, headers=headers, data=json.dumps(data))
69
- print("response code", response.status_code)
70
- if response.status_code == 200:
71
- result = response.json()
72
- result = base64.b64decode(result['images'][0])
73
- result_np = np.frombuffer(result, np.uint8)
74
- result_img = cv.imdecode(result_np, cv.IMREAD_UNCHANGED)
75
- else:
76
- print('server error!')
77
-
78
-
79
- final_img = add_waterprint(result_img)
80
-
81
- return final_img
82
-
83
- '''height, width = 500, 500 # Adjust dimensions as needed
84
- channels = 3 # 3 for RGB, 1 for grayscale
85
- result_img = np.zeros((height, width, channels), dtype=np.uint8)
86
- result_img[:] = (255, 0, 0) # Set the image to solid blue color
87
-
88
- # final_img = add_waterprint(result_img)
89
- return result_img'''
90
-
91
-
92
-
93
- with gr.Blocks(css = ".output-image, .input-image, .image-preview {height: 400px !important} ") as demo:
94
- # gr.Markdown("# Outfit Anyone v0.9")
95
- gr.HTML(
96
- """
97
- <div>
98
- <h1 >Outfit Anyone: Ultra-high quality virtual try-on for Any Clothing and Any Person</h1>
99
- </div>
100
- """)
101
- with gr.Row():
102
- with gr.Column():
103
- init_image = gr.Image(type="filepath", label="model", value=model)
104
- example = gr.Examples(inputs=init_image,
105
- examples_per_page=4,
106
- examples=[os.path.join(os.path.dirname(__file__), MODEL_MAP.get('AI Model Rouyan_0')),
107
- os.path.join(os.path.dirname(__file__), MODEL_MAP.get('AI Model Rouyan_2')),
108
- os.path.join(os.path.dirname(__file__), MODEL_MAP.get('AI Model Eva_0')),
109
- os.path.join(os.path.dirname(__file__), MODEL_MAP.get('AI Model Simon_1')),
110
- os.path.join(os.path.dirname(__file__), MODEL_MAP.get('AI Model Eva_1')),
111
- os.path.join(os.path.dirname(__file__), MODEL_MAP.get('AI Model Simon_0')),
112
- os.path.join(os.path.dirname(__file__), MODEL_MAP.get('AI Model Xuanxuan_0')),
113
- os.path.join(os.path.dirname(__file__), MODEL_MAP.get('AI Model Xuanxuan_2')),
114
- os.path.join(os.path.dirname(__file__), MODEL_MAP.get('AI Model Yaqi_1')),
115
- os.path.join(os.path.dirname(__file__), MODEL_MAP.get('AI Model Yifeng_0')),
116
- os.path.join(os.path.dirname(__file__), MODEL_MAP.get('AI Model Yifeng_3')),
117
- os.path.join(os.path.dirname(__file__), MODEL_MAP.get('AI Model Rouyan_1')),
118
- os.path.join(os.path.dirname(__file__), MODEL_MAP.get('AI Model Yifeng_2')),
119
- os.path.join(os.path.dirname(__file__), MODEL_MAP.get('AI Model Yaqi_0')),
120
- ])
121
- with gr.Column():
122
- gr.HTML(
123
- """
124
- <div style="display: flex; justify-content: center; align-items: center; text-align: center;">
125
- <div>
126
- <h3>Models are fixed and cannot be uploaded or modified; we only support users uploading their own garments.</h3>
127
- <h4 style="margin: 0;">For a one-piece dress or coat, you only need to upload the image to the 'top garment' section and leave the 'lower garment' section empty.</h4>
128
- </div>
129
- </div>
130
- """)
131
- with gr.Row():
132
- garment_top = gr.Image(type="numpy", label="top garment")
133
- garment_down = gr.Image(type="numpy", label="lower garment")
134
-
135
- run_button = gr.Button(value="Run")
136
- with gr.Column():
137
- gallery = gr.Image()
138
-
139
- run_button.click(fn=get_tryon_result,
140
- inputs=[
141
- init_image,
142
- garment_top,
143
- garment_down,
144
- ],
145
- outputs=[gallery],
146
- show_progress=True,
147
- concurrency_limit=2)
148
-
149
- # Examples
150
- gr.Markdown("## Examples")
151
- with gr.Row():
152
- reference_image1 = gr.Image(label="model", scale=1, value="examples/basemodel.png")
153
- reference_image2 = gr.Image(label="garment", scale=1, value="examples/garment1.jpg")
154
- reference_image3 = gr.Image(label="result", scale=1, value="examples/result1.png")
155
- gr.Examples(
156
- examples=[
157
- ["examples/basemodel.png", "examples/garment1.png", "examples/result1.png"],
158
- ["examples/basemodel.png", "examples/garment2.png", "examples/result2.png"],
159
- ["examples/basemodel.png", "examples/garment3.png", "examples/result3.png"],
160
- ],
161
- inputs=[reference_image1, reference_image2, reference_image3],
162
- label=None,
163
- )
164
-
165
- if __name__ == "__main__":
166
- ip = requests.get('http://ifconfig.me/ip', timeout=1).text.strip()
167
- print("ip address alibaba", ip)
168
- demo.queue(max_size=10)
169
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
SWAPON/examples/basemodel.png DELETED
Binary file (851 kB)
 
SWAPON/examples/garment1.jpg DELETED
Binary file (403 kB)
 
SWAPON/examples/garment1.png DELETED
Binary file (560 kB)
 
SWAPON/examples/garment2.jpg DELETED
Binary file (168 kB)
 
SWAPON/examples/garment2.png DELETED
Binary file (469 kB)
 
SWAPON/examples/garment3.png DELETED
Binary file (607 kB)
 
SWAPON/examples/result1.png DELETED
Binary file (696 kB)
 
SWAPON/examples/result2.png DELETED
Binary file (994 kB)
 
SWAPON/examples/result3.png DELETED
Binary file (532 kB)
 
SWAPON/garments/bottom1.png DELETED
Binary file (395 kB)
 
SWAPON/garments/bottom2.PNG DELETED
Binary file (747 kB)
 
SWAPON/garments/bottom3.JPG DELETED
Binary file (22.2 kB)
 
SWAPON/garments/bottom4.PNG DELETED
Binary file (314 kB)
 
SWAPON/garments/bottom5.png DELETED
Binary file (306 kB)
 
SWAPON/garments/dress1.png DELETED
Binary file (165 kB)
 
SWAPON/garments/dress2.png DELETED
Binary file (315 kB)
 
SWAPON/garments/top111.png DELETED
Binary file (732 kB)
 
SWAPON/garments/top222.JPG DELETED
Binary file (15.6 kB)
 
SWAPON/garments/top3.JPG DELETED
Binary file (211 kB)
 
SWAPON/garments/top333.png DELETED
Binary file (653 kB)
 
SWAPON/garments/top4.png DELETED
Binary file (816 kB)
 
SWAPON/garments/top5.png DELETED
Binary file (455 kB)
 
SWAPON/models/eva/Eva_0.png DELETED
Binary file (843 kB)
 
SWAPON/models/eva/Eva_1.png DELETED
Binary file (851 kB)
 
SWAPON/models/rouyan_new/0/densepose.png DELETED
Binary file (21.1 kB)
 
SWAPON/models/rouyan_new/0/humanmask.png DELETED
Binary file (50 kB)
 
SWAPON/models/rouyan_new/0/initmask.png DELETED
Binary file (10.5 kB)
 
SWAPON/models/rouyan_new/0/model.png DELETED
Binary file (905 kB)
 
SWAPON/models/rouyan_new/1/a DELETED
@@ -1 +0,0 @@
1
-
 
 
SWAPON/models/rouyan_new/1/humanmask.png DELETED
Binary file (51 kB)
 
SWAPON/models/rouyan_new/1/initmask.png DELETED
Binary file (10.8 kB)
 
SWAPON/models/rouyan_new/1/mdensepose.png DELETED
Binary file (21.3 kB)
 
SWAPON/models/rouyan_new/1/model.png DELETED
Binary file (960 kB)
 
SWAPON/models/rouyan_new/2/a DELETED
@@ -1 +0,0 @@
1
-
 
 
SWAPON/models/rouyan_new/2/densepose.png DELETED
Binary file (21.6 kB)
 
SWAPON/models/rouyan_new/2/humanmask.png DELETED
Binary file (50.3 kB)
 
SWAPON/models/rouyan_new/2/initmask.png DELETED
Binary file (10.2 kB)
 
SWAPON/models/rouyan_new/2/model.png DELETED
Binary file (961 kB)
 
SWAPON/models/rouyan_new/Rouyan_0.png DELETED
Binary file (905 kB)
 
SWAPON/models/rouyan_new/Rouyan_1.png DELETED
Binary file (960 kB)
 
SWAPON/models/rouyan_new/Rouyan_2.png DELETED
Binary file (961 kB)
 
SWAPON/models/simon_online/Simon_0.png DELETED
Binary file (868 kB)
 
SWAPON/models/simon_online/Simon_1.png DELETED
Binary file (816 kB)
 
SWAPON/models/simon_online/a DELETED
@@ -1 +0,0 @@
1
-
 
 
SWAPON/models/xiaoxuan/a DELETED
@@ -1 +0,0 @@
1
-
 
 
SWAPON/models/xiaoxuan/model.png DELETED
Binary file (685 kB)
 
SWAPON/models/xiaoxuan_online/Xuanxuan_0.png DELETED
Binary file (685 kB)