Spaces:
Runtime error
Runtime error
Uploaded 7 changes
Browse files- .gitattributes +35 -35
- Dockerfile +14 -0
- README.md +10 -10
- default +49 -0
- default.pub +1 -0
- main.py +95 -0
- requirements.txt +4 -0
.gitattributes
CHANGED
@@ -1,35 +1,35 @@
|
|
1 |
-
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
-
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
-
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
-
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
-
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
-
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
-
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
-
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
-
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
-
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
-
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
-
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
-
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
-
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
Dockerfile
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
2 |
+
# you will also find guides on how best to write your Dockerfile
|
3 |
+
|
4 |
+
FROM python:3.9
|
5 |
+
|
6 |
+
WORKDIR /code
|
7 |
+
|
8 |
+
COPY ./requirements.txt /code/requirements.txt
|
9 |
+
|
10 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
11 |
+
|
12 |
+
COPY . .
|
13 |
+
|
14 |
+
CMD ["gunicorn", "-b", "0.0.0.0:7860", "app.main:app"]
|
README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
-
---
|
2 |
-
title: Wearon
|
3 |
-
emoji: 🌍
|
4 |
-
colorFrom: green
|
5 |
-
colorTo: gray
|
6 |
-
sdk: docker
|
7 |
-
pinned: false
|
8 |
-
---
|
9 |
-
|
10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
+
---
|
2 |
+
title: Wearon
|
3 |
+
emoji: 🌍
|
4 |
+
colorFrom: green
|
5 |
+
colorTo: gray
|
6 |
+
sdk: docker
|
7 |
+
pinned: false
|
8 |
+
---
|
9 |
+
|
10 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
default
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
-----BEGIN OPENSSH PRIVATE KEY-----
|
2 |
+
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAACFwAAAAdzc2gtcn
|
3 |
+
NhAAAAAwEAAQAAAgEAqJTGiCvjc/h/PvPH0OjruQJIm1Q/keXiDRtZzAESUz3sP+DHfyaq
|
4 |
+
dUXbD+CP441+bKGxT3huW0DbWQbyw59QBWeLaE9xvPjTTE2UEXE3VegiJpyVjeW76LKJ88
|
5 |
+
zWs7aV11h7vzUTx2D6dwDxTT7UjJw8hef/Z8sDvS5waJNt9pbSXzoqRGHxtrUsrmw2iZtB
|
6 |
+
8cdMVsgLgX7k+MHeRQ2ZgxJkbCBJ2s3GdISippnUmcV9Qrkcztg7nsf/88NUrHZASBJxFW
|
7 |
+
z3EfikFrJK8putOZSjZBse3SP0v7FslXTNSw3DT9oQnXwcimBpkOU+tJU48xlGDgkAuSDF
|
8 |
+
bYWudo6WKcKBwn6HKB1/DwqiHQrw0uzd1sgtM7DLbJsLOaEmhfRI6U+ztc9ckQPdd7T2UP
|
9 |
+
/+PzPcnojSgSYIeMLBnF0mhhYpdoS2yNsIge+hi3KzHUMrjd5Ep94VBwl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|
|
|
|
|
1 |
+
from flask import Flask, request, jsonify, send_from_directory
|
2 |
+
from gradio_client import Client, file
|
3 |
+
from flask_cors import CORS
|
4 |
+
import os
|
5 |
+
import traceback
|
6 |
+
import shutil
|
7 |
+
import base64
|
8 |
+
|
9 |
+
app = Flask(__name__)
|
10 |
+
CORS(app)
|
11 |
+
|
12 |
+
client = Client("yisol/IDM-VTON")
|
13 |
+
|
14 |
+
# Directory to save uploaded and processed files
|
15 |
+
UPLOAD_FOLDER = 'static/uploads'
|
16 |
+
RESULT_FOLDER = 'static/results'
|
17 |
+
if not os.path.exists(UPLOAD_FOLDER):
|
18 |
+
os.makedirs(UPLOAD_FOLDER)
|
19 |
+
if not os.path.exists(RESULT_FOLDER):
|
20 |
+
os.makedirs(RESULT_FOLDER)
|
21 |
+
|
22 |
+
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
|
23 |
+
app.config['RESULT_FOLDER'] = RESULT_FOLDER
|
24 |
+
|
25 |
+
@app.route('/process', methods=['POST'])
|
26 |
+
def predict():
|
27 |
+
try:
|
28 |
+
# Get the product image URL from the request
|
29 |
+
product_image_url = request.form.get('product_image_url')
|
30 |
+
|
31 |
+
# Handle the uploaded model image
|
32 |
+
if 'model_image' not in request.files:
|
33 |
+
return jsonify(error='No model image file provided'), 400
|
34 |
+
|
35 |
+
model_image = request.files['model_image']
|
36 |
+
if model_image.filename == '':
|
37 |
+
return jsonify(error='No selected file'), 400
|
38 |
+
|
39 |
+
# Save the uploaded file to the upload directory
|
40 |
+
filename = os.path.join(app.config['UPLOAD_FOLDER'], model_image.filename)
|
41 |
+
model_image.save(filename)
|
42 |
+
|
43 |
+
base_path = os.getcwd()
|
44 |
+
full_filename = os.path.normpath(os.path.join(base_path, filename))
|
45 |
+
|
46 |
+
print("Product image = ", product_image_url)
|
47 |
+
print("Model image = ", full_filename)
|
48 |
+
|
49 |
+
# Perform prediction
|
50 |
+
try:
|
51 |
+
result = client.predict(
|
52 |
+
dict={"background": file(full_filename), "layers": [], "composite": None},
|
53 |
+
garm_img=file(product_image_url),
|
54 |
+
garment_des="Hello!!",
|
55 |
+
is_checked=True,
|
56 |
+
is_checked_crop=False,
|
57 |
+
denoise_steps=30,
|
58 |
+
seed=42,
|
59 |
+
api_name="/tryon"
|
60 |
+
)
|
61 |
+
except Exception as e:
|
62 |
+
traceback.print_exc()
|
63 |
+
raise
|
64 |
+
|
65 |
+
print(result)
|
66 |
+
# Extract the path of the first output image
|
67 |
+
output_image_path = result[0]
|
68 |
+
|
69 |
+
# Copy the output image to the RESULT_FOLDER
|
70 |
+
output_image_filename = os.path.basename(output_image_path)
|
71 |
+
local_output_path = os.path.join(app.config['RESULT_FOLDER'], output_image_filename)
|
72 |
+
shutil.copy(output_image_path, local_output_path)
|
73 |
+
|
74 |
+
# Remove the uploaded file after processing
|
75 |
+
os.remove(filename)
|
76 |
+
|
77 |
+
# Encode the output image in base64
|
78 |
+
with open(local_output_path, "rb") as image_file:
|
79 |
+
encoded_image = base64.b64encode(image_file.read()).decode('utf-8')
|
80 |
+
|
81 |
+
# Return the output image in JSON format
|
82 |
+
return jsonify(image=encoded_image), 200
|
83 |
+
|
84 |
+
except Exception as e:
|
85 |
+
traceback.print_exc()
|
86 |
+
return jsonify(error=str(e)), 500
|
87 |
+
|
88 |
+
@app.route('/uploads/<filename>')
|
89 |
+
def uploaded_file(filename):
|
90 |
+
return send_from_directory(app.config['UPLOAD_FOLDER'], filename)
|
91 |
+
|
92 |
+
if __name__ == '__main__':
|
93 |
+
app.run(host='0.0.0.0', port=5000)
|
94 |
+
|
95 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
flask
|
2 |
+
flask-cors
|
3 |
+
gradio_client
|
4 |
+
gunicorn
|