Spaces:
Runtime error
Runtime error
Soham Chandratre
commited on
Commit
·
59442d5
1
Parent(s):
a3bc0c1
minor changes
Browse files
model/__pycache__/pothole_model.cpython-311.pyc
CHANGED
|
Binary files a/model/__pycache__/pothole_model.cpython-311.pyc and b/model/__pycache__/pothole_model.cpython-311.pyc differ
|
|
|
model/pothole_model.py
CHANGED
|
@@ -26,6 +26,8 @@
|
|
| 26 |
from keras.models import load_model # TensorFlow is required for Keras to work
|
| 27 |
from PIL import Image, ImageOps # Install pillow instead of PIL
|
| 28 |
import numpy as np
|
|
|
|
|
|
|
| 29 |
|
| 30 |
|
| 31 |
def load_image_model(image):
|
|
@@ -33,7 +35,10 @@ def load_image_model(image):
|
|
| 33 |
np.set_printoptions(suppress=True)
|
| 34 |
|
| 35 |
# Load the model
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
# Load the labels
|
| 39 |
class_names = open("labels.txt", "r").readlines()
|
|
@@ -44,7 +49,7 @@ def load_image_model(image):
|
|
| 44 |
data = np.ndarray(shape=(1, 224, 224, 3), dtype=np.float32)
|
| 45 |
|
| 46 |
# Replace this with the path to your image
|
| 47 |
-
image = Image.open(image).convert("RGB")
|
| 48 |
|
| 49 |
# resizing the image to be at least 224x224 and then cropping from the center
|
| 50 |
size = (224, 224)
|
|
|
|
| 26 |
from keras.models import load_model # TensorFlow is required for Keras to work
|
| 27 |
from PIL import Image, ImageOps # Install pillow instead of PIL
|
| 28 |
import numpy as np
|
| 29 |
+
from io import BytesIO
|
| 30 |
+
import requests
|
| 31 |
|
| 32 |
|
| 33 |
def load_image_model(image):
|
|
|
|
| 35 |
np.set_printoptions(suppress=True)
|
| 36 |
|
| 37 |
# Load the model
|
| 38 |
+
model_url = "https://huggingface.co/spaces/Soham0708/pothole_detect/blob/main/keras_model.h5"
|
| 39 |
+
response = requests.get(model_url)
|
| 40 |
+
response.raise_for_status() # Raise an exception if the download fails
|
| 41 |
+
model = load_model(BytesIO(response.content))
|
| 42 |
|
| 43 |
# Load the labels
|
| 44 |
class_names = open("labels.txt", "r").readlines()
|
|
|
|
| 49 |
data = np.ndarray(shape=(1, 224, 224, 3), dtype=np.float32)
|
| 50 |
|
| 51 |
# Replace this with the path to your image
|
| 52 |
+
image = Image.open(BytesIO(image)).convert("RGB")
|
| 53 |
|
| 54 |
# resizing the image to be at least 224x224 and then cropping from the center
|
| 55 |
size = (224, 224)
|