Saad0KH commited on
Commit
7713aa5
Β·
verified Β·
1 Parent(s): 8da9807

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -0
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)