Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -12,6 +12,9 @@ def load_model():
|
|
12 |
model.to(device)
|
13 |
return model
|
14 |
|
|
|
|
|
|
|
15 |
@st.cache_data
|
16 |
def read_image_as_np_array(image_path):
|
17 |
if "http" in image_path:
|
@@ -20,8 +23,6 @@ def read_image_as_np_array(image_path):
|
|
20 |
image = Image.open(image_path).convert("L").convert("RGB")
|
21 |
image = np.array(image)
|
22 |
return image
|
23 |
-
|
24 |
-
model = load_model()
|
25 |
|
26 |
@st.cache_data
|
27 |
def predict_detections_and_associations(
|
@@ -44,6 +45,7 @@ def predict_detections_and_associations(
|
|
44 |
)[0]
|
45 |
return result
|
46 |
|
|
|
47 |
@st.cache_data
|
48 |
def predict_ocr(
|
49 |
image_path,
|
|
|
12 |
model.to(device)
|
13 |
return model
|
14 |
|
15 |
+
# Load the model outside caching
|
16 |
+
model = load_model() # Place this line here, right after defining load_model
|
17 |
+
|
18 |
@st.cache_data
|
19 |
def read_image_as_np_array(image_path):
|
20 |
if "http" in image_path:
|
|
|
23 |
image = Image.open(image_path).convert("L").convert("RGB")
|
24 |
image = np.array(image)
|
25 |
return image
|
|
|
|
|
26 |
|
27 |
@st.cache_data
|
28 |
def predict_detections_and_associations(
|
|
|
45 |
)[0]
|
46 |
return result
|
47 |
|
48 |
+
|
49 |
@st.cache_data
|
50 |
def predict_ocr(
|
51 |
image_path,
|