Spaces:
Sleeping
Sleeping
added pull model from hf
Browse files- README.md +1 -1
- app.py +10 -1
- requirements.txt +1 -0
README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
emoji: 🐢
|
4 |
colorFrom: indigo
|
5 |
colorTo: red
|
|
|
1 |
---
|
2 |
+
title: 230001A
|
3 |
emoji: 🐢
|
4 |
colorFrom: indigo
|
5 |
colorTo: red
|
app.py
CHANGED
@@ -9,7 +9,8 @@ from object_detection.utils import ops as utils_op
|
|
9 |
import tarfile
|
10 |
import wget
|
11 |
import gradio as gr
|
12 |
-
|
|
|
13 |
|
14 |
PATH_TO_LABELS = 'data/label_map.pbtxt'
|
15 |
category_index = label_map_util.create_category_index_from_labelmap(PATH_TO_LABELS, use_display_name=True)
|
@@ -28,6 +29,12 @@ def load_image_into_numpy_array(path):
|
|
28 |
return pil_image_as_numpy_array(image)
|
29 |
|
30 |
def load_model():
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
wget.download("https://nyp-aicourse.s3-ap-southeast-1.amazonaws.com/pretrained-models/balloon_model.tar.gz")
|
32 |
tarfile.open("balloon_model.tar.gz").extractall()
|
33 |
model_dir = 'saved_model'
|
@@ -69,6 +76,8 @@ def predict2(image_np):
|
|
69 |
|
70 |
return result_pil_img
|
71 |
|
|
|
|
|
72 |
detection_model = load_model()
|
73 |
# pil_image = Image.open(image_path)
|
74 |
# image_arr = pil_image_as_numpy_array(pil_image)
|
|
|
9 |
import tarfile
|
10 |
import wget
|
11 |
import gradio as gr
|
12 |
+
from huggingface_hub import snapshot_download
|
13 |
+
import os
|
14 |
|
15 |
PATH_TO_LABELS = 'data/label_map.pbtxt'
|
16 |
category_index = label_map_util.create_category_index_from_labelmap(PATH_TO_LABELS, use_display_name=True)
|
|
|
29 |
return pil_image_as_numpy_array(image)
|
30 |
|
31 |
def load_model():
|
32 |
+
download_dir = snapshot_download(REPO_ID)
|
33 |
+
saved_model_dir = os.path.join(download_dir, "saved_model")
|
34 |
+
detection_model = tf.saved_model.load(saved_model_dir)
|
35 |
+
return detection_model
|
36 |
+
|
37 |
+
def load_model2():
|
38 |
wget.download("https://nyp-aicourse.s3-ap-southeast-1.amazonaws.com/pretrained-models/balloon_model.tar.gz")
|
39 |
tarfile.open("balloon_model.tar.gz").extractall()
|
40 |
model_dir = 'saved_model'
|
|
|
76 |
|
77 |
return result_pil_img
|
78 |
|
79 |
+
|
80 |
+
REPO_ID = "khengkok/mkktfodmodel"
|
81 |
detection_model = load_model()
|
82 |
# pil_image = Image.open(image_path)
|
83 |
# image_arr = pil_image_as_numpy_array(pil_image)
|
requirements.txt
CHANGED
@@ -3,3 +3,4 @@ tf-models-research-object-detection
|
|
3 |
matplotlib
|
4 |
wget
|
5 |
Pillow==9.5
|
|
|
|
3 |
matplotlib
|
4 |
wget
|
5 |
Pillow==9.5
|
6 |
+
huggingface_hub
|