Spaces:
Sleeping
Sleeping
Commit
·
30cd121
1
Parent(s):
51c5500
Update app.py
Browse files
app.py
CHANGED
@@ -36,6 +36,41 @@ utils_ops.tf = tf.compat.v1
|
|
36 |
|
37 |
# Patch the location of gfile
|
38 |
tf.gfile = tf.io.gfile
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
def segment(image):
|
40 |
pass # Implement your image segmentation model here...
|
41 |
|
|
|
36 |
|
37 |
# Patch the location of gfile
|
38 |
tf.gfile = tf.io.gfile
|
39 |
+
os.system('python object_detection/builders/model_builder_tf2_test.py')
|
40 |
+
def load_model(model_dir):
|
41 |
+
model = tf.saved_model.load(str(model_dir))
|
42 |
+
model = model.signatures['serving_default']
|
43 |
+
return model
|
44 |
+
os.system('mkdir "Tortoise"')
|
45 |
+
os.chdir('Tortoise/')
|
46 |
+
os.system('curl -L "https://app.roboflow.com/ds/jCjxJgk04M?key=3JE38XqESy" > roboflow.zip; unzip roboflow.zip; rm roboflow.zip')
|
47 |
+
os.chdir('..')
|
48 |
+
os.system('mkdir "COCO"')
|
49 |
+
os.chdir('COCO/')
|
50 |
+
os.system('curl -L "https://app.roboflow.com/ds/Yb2OGQm2xb?key=pbWEWpS5ec" > roboflow.zip; unzip roboflow.zip; rm roboflow.zip')
|
51 |
+
os.chdir('..')
|
52 |
+
|
53 |
+
PATH_TO_TEST_IMAGES_DIR = pathlib.Path("COCO" + '/test/')
|
54 |
+
TEST_IMAGE_PATHS = sorted(list(PATH_TO_TEST_IMAGES_DIR.glob("*.jpg")))
|
55 |
+
dataset = 'Tortoise'
|
56 |
+
test_record_fname = dataset + '/test/tortoise.tfrecord'
|
57 |
+
train_record_fname = dataset + '/train/tortoise.tfrecord'
|
58 |
+
label_map_pbtxt_fname = dataset + '/train/tortoise_label_map.pbtxt'
|
59 |
+
PATH_TO_LABELS = dataset + '/train/tortoise_label_map.pbtxt'
|
60 |
+
category_index = label_map_util.create_category_index_from_labelmap(PATH_TO_LABELS, use_display_name=False)
|
61 |
+
|
62 |
+
|
63 |
+
test_data_json = 'COCO/test/_annotations.coco.json'
|
64 |
+
with open(test_data_json, 'r') as f:
|
65 |
+
test_metadata = json.load(f)
|
66 |
+
for im in test_metadata['images']:
|
67 |
+
im['date_captured'] = str(datetime.strptime(im['file_name'][6:21],"%Y%m%d-%H%M%S"))
|
68 |
+
|
69 |
+
image_id_to_datetime = {im['id']:im['date_captured'] for im in test_metadata['images']}
|
70 |
+
image_path_to_id = {im['file_name']: im['id']
|
71 |
+
for im in test_metadata['images']}
|
72 |
+
faster_rcnn_model = load_model('../../Faster_RCNN_SS1_imagetensor/saved_model')
|
73 |
+
|
74 |
def segment(image):
|
75 |
pass # Implement your image segmentation model here...
|
76 |
|