Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -11,7 +11,6 @@ from PIL import Image
|
|
11 |
from huggingface_hub import hf_hub_download
|
12 |
from onnxruntime import InferenceSession
|
13 |
import io
|
14 |
-
from flask import Flask, request, jsonify
|
15 |
|
16 |
# noinspection PyUnresolvedReferences
|
17 |
def make_square(img, target_size):
|
@@ -164,25 +163,6 @@ def image_to_wd14_tags(image:Image.Image, link:str, model_name: str, threshold:
|
|
164 |
|
165 |
return ratings, output_text, filtered_tags
|
166 |
|
167 |
-
app = Flask(__name__)
|
168 |
-
|
169 |
-
@app.route('/api/tag_image', methods=['POST'])
|
170 |
-
def tag_image():
|
171 |
-
data = request.get_json()
|
172 |
-
|
173 |
-
input_image = data.get('input_image', None)
|
174 |
-
input_text = data.get('url', None)
|
175 |
-
model = data.get('model', 'wd14-vit-v2')
|
176 |
-
threshold = data.get('threshold', 0.35)
|
177 |
-
space = data.get('space', True)
|
178 |
-
escape = data.get('escape', True)
|
179 |
-
confidence = data.get('confidence', False)
|
180 |
-
order = data.get('order', True)
|
181 |
-
|
182 |
-
result = image_to_wd14_tags(input_image, input_text, model, threshold, space, escape, confidence, order)
|
183 |
-
|
184 |
-
return jsonify(result)
|
185 |
-
|
186 |
if __name__ == '__main__':
|
187 |
with gr.Blocks() as demo:
|
188 |
with gr.Row():
|
@@ -215,5 +195,4 @@ if __name__ == '__main__':
|
|
215 |
outputs=[gr_ratings, gr_output_text, gr_tags],
|
216 |
)
|
217 |
|
218 |
-
|
219 |
-
demo.queue(os.cpu_count()).launch()
|
|
|
11 |
from huggingface_hub import hf_hub_download
|
12 |
from onnxruntime import InferenceSession
|
13 |
import io
|
|
|
14 |
|
15 |
# noinspection PyUnresolvedReferences
|
16 |
def make_square(img, target_size):
|
|
|
163 |
|
164 |
return ratings, output_text, filtered_tags
|
165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
if __name__ == '__main__':
|
167 |
with gr.Blocks() as demo:
|
168 |
with gr.Row():
|
|
|
195 |
outputs=[gr_ratings, gr_output_text, gr_tags],
|
196 |
)
|
197 |
|
198 |
+
demo.queue(os.cpu_count()).launch()
|
|