Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,7 @@ import cv2
|
|
7 |
import insightface
|
8 |
import onnxruntime as ort
|
9 |
import huggingface_hub
|
|
|
10 |
|
11 |
app = Flask(__name__)
|
12 |
|
@@ -82,5 +83,20 @@ def detect():
|
|
82 |
except Exception as e:
|
83 |
return jsonify({'error': str(e)}), 500
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
if __name__ == "__main__":
|
86 |
app.run(debug=True, host="0.0.0.0", port=7860)
|
|
|
7 |
import insightface
|
8 |
import onnxruntime as ort
|
9 |
import huggingface_hub
|
10 |
+
from SegCloth import segment_clothing
|
11 |
|
12 |
app = Flask(__name__)
|
13 |
|
|
|
83 |
except Exception as e:
|
84 |
return jsonify({'error': str(e)}), 500
|
85 |
|
86 |
+
|
87 |
+
def segment_image(img, clothes):
|
88 |
+
img = decode_image_from_base64(img)
|
89 |
+
return segment_clothing(img, clothes)
|
90 |
+
|
91 |
+
# Route pour l'API REST
|
92 |
+
@app.route('/api/classify', methods=['POST'])
|
93 |
+
def classify():
|
94 |
+
data = request.json
|
95 |
+
print(data)
|
96 |
+
clothes = ["Upper-clothes", "Skirt", "Pants", "Dress"]
|
97 |
+
image = data['image']
|
98 |
+
result = segment_image(image,clothes)
|
99 |
+
return jsonify({'result': result})
|
100 |
+
|
101 |
if __name__ == "__main__":
|
102 |
app.run(debug=True, host="0.0.0.0", port=7860)
|