Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,6 +12,7 @@ from zipfile import ZipFile
|
|
| 12 |
import pathlib
|
| 13 |
import shutil
|
| 14 |
import pandas as pd
|
|
|
|
| 15 |
import deepsparse
|
| 16 |
|
| 17 |
rn50_embedding_pipeline = deepsparse.Pipeline.create(
|
|
@@ -38,7 +39,7 @@ def zip_ims(g):
|
|
| 38 |
def unzip_ims(zip_file_name):
|
| 39 |
print("call file")
|
| 40 |
if zip_file_name is None:
|
| 41 |
-
return {}
|
| 42 |
unzip_path = "img_dir"
|
| 43 |
if os.path.exists(unzip_path):
|
| 44 |
shutil.rmtree(unzip_path)
|
|
@@ -52,25 +53,25 @@ def unzip_ims(zip_file_name):
|
|
| 52 |
embeddings = rn50_embedding_pipeline(images=im_name_l)
|
| 53 |
if os.path.exists(unzip_path):
|
| 54 |
shutil.rmtree(unzip_path)
|
| 55 |
-
return {
|
| 56 |
"names": im_name_l,
|
| 57 |
"embs": embeddings.embeddings
|
| 58 |
-
}
|
| 59 |
|
| 60 |
|
| 61 |
def emb_img_func(im):
|
| 62 |
print("call im :")
|
| 63 |
if im is None:
|
| 64 |
-
return {}
|
| 65 |
im_obj = Image.fromarray(im)
|
| 66 |
im_name = "{}.png".format(uuid1())
|
| 67 |
im_obj.save(im_name)
|
| 68 |
embeddings = rn50_embedding_pipeline(images=[im_name])
|
| 69 |
os.remove(im_name)
|
| 70 |
-
return {
|
| 71 |
"names": [im_name],
|
| 72 |
"embs": embeddings.embeddings
|
| 73 |
-
}
|
| 74 |
|
| 75 |
'''
|
| 76 |
def emb_gallery_func(gallery):
|
|
|
|
| 12 |
import pathlib
|
| 13 |
import shutil
|
| 14 |
import pandas as pd
|
| 15 |
+
import json
|
| 16 |
import deepsparse
|
| 17 |
|
| 18 |
rn50_embedding_pipeline = deepsparse.Pipeline.create(
|
|
|
|
| 39 |
def unzip_ims(zip_file_name):
|
| 40 |
print("call file")
|
| 41 |
if zip_file_name is None:
|
| 42 |
+
return json.dumps({})
|
| 43 |
unzip_path = "img_dir"
|
| 44 |
if os.path.exists(unzip_path):
|
| 45 |
shutil.rmtree(unzip_path)
|
|
|
|
| 53 |
embeddings = rn50_embedding_pipeline(images=im_name_l)
|
| 54 |
if os.path.exists(unzip_path):
|
| 55 |
shutil.rmtree(unzip_path)
|
| 56 |
+
return json.dumps({
|
| 57 |
"names": im_name_l,
|
| 58 |
"embs": embeddings.embeddings
|
| 59 |
+
})
|
| 60 |
|
| 61 |
|
| 62 |
def emb_img_func(im):
|
| 63 |
print("call im :")
|
| 64 |
if im is None:
|
| 65 |
+
return json.dumps({})
|
| 66 |
im_obj = Image.fromarray(im)
|
| 67 |
im_name = "{}.png".format(uuid1())
|
| 68 |
im_obj.save(im_name)
|
| 69 |
embeddings = rn50_embedding_pipeline(images=[im_name])
|
| 70 |
os.remove(im_name)
|
| 71 |
+
return json.dumps({
|
| 72 |
"names": [im_name],
|
| 73 |
"embs": embeddings.embeddings
|
| 74 |
+
})
|
| 75 |
|
| 76 |
'''
|
| 77 |
def emb_gallery_func(gallery):
|