Spaces:
Sleeping
Sleeping
Update app.py v4
Browse files
app.py
CHANGED
@@ -29,12 +29,6 @@ def load_image_into_numpy_array(path):
|
|
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 |
model_dir = 'saved_model'
|
39 |
detection_model = tf.saved_model.load(str(model_dir))
|
40 |
return detection_model
|
@@ -43,12 +37,7 @@ def load_model2():
|
|
43 |
# image_path = 'test_samples/sample_balloon.jpeg
|
44 |
#
|
45 |
|
46 |
-
def predict(
|
47 |
-
|
48 |
-
image_np = pil_image_as_numpy_array(pilimg)
|
49 |
-
return predict2(image_np)
|
50 |
-
|
51 |
-
def predict2(image_np):
|
52 |
|
53 |
results = detection_model(image_np)
|
54 |
|
@@ -75,15 +64,14 @@ def predict2(image_np):
|
|
75 |
return result_pil_img
|
76 |
|
77 |
|
78 |
-
|
79 |
-
detection_model = load_model2()
|
80 |
# pil_image = Image.open(image_path)
|
81 |
# image_arr = pil_image_as_numpy_array(pil_image)
|
82 |
|
83 |
# predicted_img = predict(image_arr)
|
84 |
# predicted_img.save('predicted.jpg')
|
85 |
|
86 |
-
gr.Interface(fn=
|
87 |
inputs=gr.Image(type="pil"),
|
88 |
outputs=gr.Image(type="pil")
|
89 |
).launch(share=True)
|
|
|
29 |
return pil_image_as_numpy_array(image)
|
30 |
|
31 |
def load_model():
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
model_dir = 'saved_model'
|
33 |
detection_model = tf.saved_model.load(str(model_dir))
|
34 |
return detection_model
|
|
|
37 |
# image_path = 'test_samples/sample_balloon.jpeg
|
38 |
#
|
39 |
|
40 |
+
def predict(image_np):
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
results = detection_model(image_np)
|
43 |
|
|
|
64 |
return result_pil_img
|
65 |
|
66 |
|
67 |
+
detection_model = load_model()
|
|
|
68 |
# pil_image = Image.open(image_path)
|
69 |
# image_arr = pil_image_as_numpy_array(pil_image)
|
70 |
|
71 |
# predicted_img = predict(image_arr)
|
72 |
# predicted_img.save('predicted.jpg')
|
73 |
|
74 |
+
gr.Interface(fn=predict,
|
75 |
inputs=gr.Image(type="pil"),
|
76 |
outputs=gr.Image(type="pil")
|
77 |
).launch(share=True)
|